[Twisted-Python] send_UDP?
Sven-Erik Tiberg
Sven-Erik.Tiberg at ltu.se
Sun Feb 25 12:52:47 MST 2007
Hi.
Just need a small tip, how to send a string by UDP, should I use socket from python or can I use any twisted class.
BTW:
Put together a rough code for reciving a string of data from simulink ( matlab ) to a H3D ( Haptic Interactive X3D ) application www.h3d.org
#import H3D fields and types
from H3DInterface import *
recived_vect = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
class Set_Position( AutoUpdate( SFVec3f ) ):
def update( self,event ):
set_pos[1] = recived_vect[2]
set_pos[2] = recived_vect[3]
set_pos[3] = recived_vect[4]
return set_pos
set_a_position=Set_position()
class Speedo_value( AutoUpdate( SFVec3f ) ):
def update( self,event ):
set_rot[1] = 0.0
set_rot[2] = 0.0
set_rot[3] = recived_vect[1]
return set_rot
set_speedo=Speedo_value()
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
class Recive_UDP_Package(DatagramProtocol):
def datagramRecived(self, data):
recived_vect=data # need to work on this to convert the data string to list element
set_a_position()
set_speedo()
reactor.listenUDP(7999, Recived_UDP_Package())
reactor.run()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4471 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20070225/19bb7446/attachment-0002.bin>
More information about the Twisted-Python
mailing list