![]() |
|
#1
|
|||
|
|||
I just got them communicated successfully. PORT = xxxx seems to be used to specify the remote port to receive from. Please forget my previous question.
My next problem is I would like to send two values from vizard to simulink every 0.05 second. My code would be like this: Code:
import viz viz.go() import socket import random COMPUTER_IP_ADDRESS = '129.59.82.229' PORT = 25000 OutSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) OutSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) def SendData(data): OutSocket.sendto(data,(COMPUTER_IP_ADDRESS,PORT)) def mytimer(num): value1 = random.randint(0, 70) value2 = random.randint(1, 100) SendData(value1, value2) viz.callback(viz.TIMER_EVENT, mytimer) viz.starttimer(0,0.05,viz.FOREVER) Thanks a lot. |
#2
|
|||
|
|||
When sending data using the socket module, the data needs to be a string containing the raw byte data. Have a look at the Python struct module for packing Python integer/float values into raw byte data. The following example shows how to generate raw byte data from 2 integer values:
Code:
import struct data = struct.pack('ii',value1,value2) |
#3
|
|||
|
|||
Thanks a lot. That really helps.
|
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
real time collision on animation path | whj | Vizard | 10 | 10-06-2008 04:38 PM |
Real Time Audio Data | lomendil | Vizard | 2 | 06-02-2008 08:18 PM |
Can I get real time Intersense tracking data from another computer on the network? | GoldenSun | Vizard | 4 | 04-30-2008 07:42 PM |
Flagging the Data | Elittdogg | Vizard | 5 | 04-11-2008 11:40 AM |
timer question | Elittdogg | Vizard | 5 | 10-10-2007 02:49 PM |