I tried to run your first commit since what you've done is kind of like what I am trying to do with xbee. But I am getting this error when running the UDP side of the code.
Discovering Devices...
Finished: [<digi.xbee.devices.RemoteDigiMeshDevice object at 0x7f7c39df5588>]
0013a200419b5ad8
Created UDP link for wireless connection with 0013a200419b5ad8
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
15.77s | 0013a200419b5ad8
IN[0] | 00, 00, D2, 20, DC, 3C, 6C, D0, CC, 3C, 9F, 72, 0A, 3D, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, D4, 87
Exception in thread Thread-4:
Traceback (most recent call last):
File "/home/abhish/anaconda3/envs/xbee/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/abhish/anaconda3/envs/xbee/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "udp.py", line 125, in udp_thread
outdata, _ = sock.recvfrom(KiB) # TODO blocking by default
ConnectionRefusedError: [Errno 111] Connection refused
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
15.77s | 0013a200419b5ad8
IN[0] | FE, 1C, EC, 01, 01, 1E, 69, CD, 04, 00, D2, E8, 8B, 3D, 34, FE, 18, BC, 7E, 2D, 0D, C0, 9D, 4F, 17, BB, D7, E7, 99, B9, 05, 1A, 10, 39, 75, 98, FE, 1C, ED, 01, 01, 21, 69, CD, 04, 00, 00, 00, 00, 00
IN[1] | 00, 00, 00, 00, B6, 08, 00, 00, BE, 08, 00, 00, F2, FF, 06, 00, 1A, 00, 42, 5B
Exception in thread Thread-2:
Traceback (most recent call last):
File "/home/abhish/anaconda3/envs/xbee/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/abhish/anaconda3/envs/xbee/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "udp.py", line 82, in primary_loop
sent = self.sockets[key].send(queued_data)
ConnectionRefusedError: [Errno 111] Connection refused
The change that I did compared to code of yours is, my XBee device supports sending only 73 bytes at a time. So, I changed
if 100 <= px4.in_waiting < 4095:
data = px4.read(px4.in_waiting)
while data:
print('[PX4 -> XBee] {}'.format(data[:255]))
pkt_sent = xb.send_data(GCS, data[:255])
data = data[255:]
elif px4.in_waiting == 4095:
px4.reset_input_buffer()
else:
pass
if 100 <= px4.in_waiting < 4095:
data = px4.read(px4.in_waiting)
while data:
print('[PX4 -> XBee] {}'.format(data[:70]))
pkt_sent = xb.send_data(GCS, data[:70])
data = data[70:]
elif px4.in_waiting == 4095:
px4.reset_input_buffer()
else:
pass
Can you please help me with this.