Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Comments

Add udp#5

Open
ty19 wants to merge 9 commits intomasterfrom
add_udp
Open

Add udp#5
ty19 wants to merge 9 commits intomasterfrom
add_udp

Conversation

@ty19
Copy link
Member

@ty19 ty19 commented Jan 20, 2019

Moved udp sample from sample_client.py into networker. Changed the sample code so it sends packages that follow the format of OtherInfo. Running sample_server.py with the GUI code shows dummy data in the load cell main plot.

Will update after I test this code (probably tomorrow)

ty19 added 9 commits January 18, 2019 22:53
These changes are based on networking/udp_client.py
Debug works by running sample_server.py and controller.py.
sample_server sends header and payload messages using the
format for OtherInfo defined in server_info.py. Graph will
have output on main load cell plot. Note that graph may
look strange due to calibration.

Code is very hacky right now as it assumes nbytes=16 for all
headers.
Not sure if this work was worthwhile, but oh well.
Also added back some old code in sample_server.py
in case anyone wants to use sample_client.py.
There seem to be minor timing issues when reconnecting,
since the header and payload are both 16 bytes and
interpreting one as the other messes things up. To fix
this, we can combine the message types into one so ordering
isn't an issue. For now the problem seems to have been solved
by removing the 5ms delay between sending the header and payload.
I'm not sure why this works though.

Also removed the NWThread class. Instead a new thread is started
using the @run_async decorator every time we connect. Threads using
old socket information return automatically when the sockets are
closed.
Read some stuff and learned that UDP communicates through
datagrams, which are like discrete units. This is in contrast
to TCP, which uses streams. sample_server.py now sends the
header and a single payload in one datagram rather than in
two separate datagrams. networker.py reads the header and all
payload data in a single datagram. The method of reading a
header then data doesn't work for UDP (I think, which explains
the errors I was getting previously).
Found a bug where we weren't actually writing to the
data logs. Good thing we found this before the test.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants