(Oct-19-2017, 11:41 AM)Larz60+ Wrote: The ten may be the number base.
Check to see if you need to be sending a tuple
check out: http://www.wellho.net/resources/ex.php4?..._client.py
That example sends a string, which I don't have a problem with. There are some vague examples that send binary or hex by using struct to pack but I can't get any of them to work. I think it must be something in Matlab, but I have it working fine with a C program doing the same thing.
This is the segment of code:
for i in range(0, 21):
print('Sending command {} to {}.' .format('A', host_address))
host_socket.sendto('A', host_address) # Accept command.
host_socket.sendto('\n', host_address)
# val = i
# val = bytes(i)
# val = struct.pack('!i', i)
val = str(i)
# val = bytearray()
# val.append(i)
print('Sending value {} to {}.' .format(val, host_address))
host_socket.sendto(val, host_address) # Value.
host_socket.sendto('\n', host_address)
print('Sending command {} to {}.' .format('Q', host_address))
host_socket.sendto('Q', host_address) # Quit command.
host_socket.sendto('\n', host_address)
The commented out bits are what I have tried. Surely converting to a string should work at the very least!