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

Random timeout in xbee sender using crontab on Raspberry pi #263

Open
zrion opened this issue Nov 9, 2021 · 0 comments
Open

Random timeout in xbee sender using crontab on Raspberry pi #263

zrion opened this issue Nov 9, 2021 · 0 comments

Comments

@zrion
Copy link

zrion commented Nov 9, 2021

Hello,

I am building a system where I have a remote Xbee sending packets continuously, and I'm using Raspberry Pi 4 as the host for the Xbee (connected to Xbee grove dev kit) , powered by a battery pack. I have a script that is loaded at Pi startup using crontab:

from digi.xbee.devices import XBeeDevice
import time


PORT = "/dev/ttyUSB0"
BAUD_RATE = 9600

DATA_TO_SEND = "Hello XBee! Sending packet "


def main():
    device = XBeeDevice(PORT, BAUD_RATE)

    packet_counter = 0

    try:
        device.open()

        print(device.set_sync_ops_timeout(15))
        while True:
            packet_counter += 1
            data = DATA_TO_SEND + str(packet_counter)

            print("Sending broadcast data: %s..." % data)

            device.send_data_broadcast(data)

            print("Success")
            time.sleep(0.03)

    finally:
        if device is not None and device.is_open():
            device.close()


if __name__ == '__main__':
    main()

What I observe is that the operation is experiencing random timeouts that cause the broadcasting interrupted, although sometimes it works smoothly. I tried to increase the timeout duration device.set_sync_ops_timeout(10) but the problem still persists. One thing to note is that manually running the script doesn't have this issue.

Any ideas to solve this problem is appreciated. I also want to ask a broader question: Is there any way to do something similar for the XBee without the Raspberry Pi (Xbee powered directly by a battery pack)?

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

1 participant