Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet backlog when receiving on Windows #248

Open
LarsLeferenz opened this issue Jul 9, 2021 · 1 comment
Open

Packet backlog when receiving on Windows #248

LarsLeferenz opened this issue Jul 9, 2021 · 1 comment

Comments

@LarsLeferenz
Copy link

LarsLeferenz commented Jul 9, 2021

Hello.
I ran into a weird issue when receiving ZigBee packets on Windows. I'm currently sending packets from a drone every 0.8s, but on Windows, the callback method is only executed about every ~5s. I'm not loosing packets, as the received packet ID's increment correctly. The strange thing is, when using an Ubuntu VM on the same computer it works perfectly, and I receive at about ~0.8s.
And if I stop sending from the drone, I continue to receive packets for quite some time.

I'm using v1.4 and a "Xbee SMT Grove Dev Board" connected by USB for both sending and receiving.

Here is the code were using to receive on both Windows and Ubuntu:

def connect(self):
        self._device = XBeeDevice(self._port, self._baudRate)
        self._device.open()
        self._device.set_16bit_addr(XBee16BitAddress(utils.int_to_bytes(int(self._address))))
        self._network = self._device.get_network()
        self._device.add_packet_received_callback(self._packetReceivedCallback)

def _packetReceivedCallback(self, packet):
        print("Received!")
        #Processing after this

I also tried using pyserial on Windows to print the serial output with:

x = serial.Serial(port="COM4", baudrate=230400 )

while True:
     y = x.read(100)
     print(y)

Which resulted in 100 Bytes every ~0.8s, so the expected behavior.
My best guess at the moment is, that somehow windows takes too long when spawning the threads to handle the packet_recieved_callback, but I really got no clue.

@Artyrm
Copy link

Artyrm commented Aug 19, 2021

My take is on Windows and serial buffers maybe it just caching arrived data. Try perhaps set port buffers on minimum?

https://www.digi.com/support/knowledge-base/optimizing-usb-to-serial-port-settings

Also baudrate 230400 may be not what Windows likes. You may give a try to 115200, which always gave me good results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants