Udp listen example
I am new here coming from Codea.
There are no access to an udp stream in Codea but looks like it is possible in Pytonista.
Does anyone have an example to start out with ?
I see the snipperts in the documentation, but from previous experience with Python, I know that some kind of threading is needed, so any help to get started is appreciated.
Thanks for the links.
I have tried to strip your code to the udp stuff only but did not succeed to make something usable with threading.
However I found another more straight forward solution.
I define a socket like this:
port = 49020
s = socket.socket(socket.AF_INET. socket.SOCK_DGRAM)
and in the draw() of a scene listening and unpacking floats:
d = s.recvfrom(1024)
bytes = d
test_float_ex = struct.unpack('f', bytes+bytes+ bytes+bytes)
The code is blocking, but since I need the float values to drive gauges, I think it must be valid.
Have to check the frame rate at some point though .....
By the way, how do you put formatted code in the forum ?
How do you put formatted code in the forum?
Use HTML < pre > and < /pre > tags.