Threads in xbee 3
Threads in xbee 3
Hi,
Programming my XBee 3 RF Zigbee module via MicroPython, I have faced some issues that I believe I could overcome by using threads.
So, I would like to ask, how can I program with threads in the MicroPython environment of the XBee3?
Shall I install the Xbee-Python Library (by the command: pip install digi-xbee)?
Any kind of guidance or useful links is more than welcomed!!!
Thanks in advance!
Programming my XBee 3 RF Zigbee module via MicroPython, I have faced some issues that I believe I could overcome by using threads.
So, I would like to ask, how can I program with threads in the MicroPython environment of the XBee3?
Shall I install the Xbee-Python Library (by the command: pip install digi-xbee)?
Any kind of guidance or useful links is more than welcomed!!!
Thanks in advance!
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Threads in xbee 3
I would only consider threads after studying uasyncio and having a good reason for rejecting it. This is for reasons discussed here and here.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Threads in xbee 3
Thanks for your reply!
I will check it, but I am not sure if this module already exists in the MIcroPython environment of the XBee 3...
At least, import uasyncio raises an error: ImportError: no module named 'uasyncio'
Do you know how can I install it?
Thanks again
I will check it, but I am not sure if this module already exists in the MIcroPython environment of the XBee 3...
At least, import uasyncio raises an error: ImportError: no module named 'uasyncio'
Do you know how can I install it?
Thanks again
Re: Threads in xbee 3
There is no thread or uasyncio support in XBEE micropython.
Re: Threads in xbee 3
Hey,
Thanks for your answer. Some (3) extra questions:
1) Does that mean that there is no way that I can program in threads???
Moreover, I have noticed that in the xbee-python library (which I still don't know when/where this library shall be used, so maybe it is irrelevant - please let me know if it is so or not) there are some samples of code where there is a module imported named "threading". Is that something that might be useful?
2) So, when is xbee-python library (https://xbplib.readthedocs.io/en/latest ... brary.html)
suggested to be used and can it provide a solution with programming in threads?
Lastly, sorry for persisting but XBee comes with a tranceiver chipset (Silicon Labs EFR32MG SoC) which I guess has various functionalities, so in a way, this kind of problem(not being able to utilize some of the abilities provided by the microprocessor) might occur and therefore is important to me. Is there any way to overcome this type of problems and if so, which are those?
3) Maybe a way would be that I program the microprocessor in "bare metal" (i.e in C) and then use this module to "extend" Micropython environment's ability?
Thanks in advance!
Thanks for your answer. Some (3) extra questions:
1) Does that mean that there is no way that I can program in threads???
Moreover, I have noticed that in the xbee-python library (which I still don't know when/where this library shall be used, so maybe it is irrelevant - please let me know if it is so or not) there are some samples of code where there is a module imported named "threading". Is that something that might be useful?
2) So, when is xbee-python library (https://xbplib.readthedocs.io/en/latest ... brary.html)
suggested to be used and can it provide a solution with programming in threads?
Lastly, sorry for persisting but XBee comes with a tranceiver chipset (Silicon Labs EFR32MG SoC) which I guess has various functionalities, so in a way, this kind of problem(not being able to utilize some of the abilities provided by the microprocessor) might occur and therefore is important to me. Is there any way to overcome this type of problems and if so, which are those?
3) Maybe a way would be that I program the microprocessor in "bare metal" (i.e in C) and then use this module to "extend" Micropython environment's ability?
Thanks in advance!
Re: Threads in xbee 3
As far as I can tell, there is not way to work with threads or asyncio on the XBEE 3, especially given the small heap size of the MP implementation. The platform for xbee-python library seems to be PC or the like, not the XBEE module itself.
Sorry that I cannot answer the questions under 3.
Sorry that I cannot answer the questions under 3.
Re: Threads in xbee 3
@Roberthh thank you so much!!! Your help is really important to me!
Don't worry about the third question, maybe someone else can lend a hand.
Regarding the xbee-python library, you mean that is a library which is installed in a PC and is simulating the XBee? Although, I don't really understand what that can actually mean...
Lastly, thank you again for your answer and particularly for clearing up the issue with threads or uasyncio and mp's heap.
Don't worry about the third question, maybe someone else can lend a hand.
Regarding the xbee-python library, you mean that is a library which is installed in a PC and is simulating the XBee? Although, I don't really understand what that can actually mean...
Lastly, thank you again for your answer and particularly for clearing up the issue with threads or uasyncio and mp's heap.
Re: Threads in xbee 3
I had the impression that this library interfaces with the XBEE 3 and uas it for instance as modem for communication. But I may be wrong.Regarding the xbee-python library, you mean that is a library which is installed in a PC and is simulating the XBee? Although, I don't really understand what that can actually mean...
Re: Threads in xbee 3
Ok, so in that case you install xbee-python library in the host pc. Then you somehow connect xbee with the host pc and without accessing the MicroPython environment of the xbee, you manage the xbee to work as a modem (in the example you mentioned) from the MicroPython environment of your pc (probably through some serial communication)? Or am I getting it wrong?
Moreover, I would like to ask, if you know whether the xbee offers the ability to use timers and interrupts or it it not feasible, as threading for instance?
Thanks again
Moreover, I would like to ask, if you know whether the xbee offers the ability to use timers and interrupts or it it not feasible, as threading for instance?
Thanks again
Re: Threads in xbee 3
Looking through the classes of the digimesh module I have here and the manual, I see no evidence of timers or interrupts.
In the micropython module there is micropython.schedule(). And in the communication modules for BLE and xbee there are various callbacks. But they cannot be reliably used for some kind of parallel execution.
In the micropython module there is micropython.schedule(). And in the communication modules for BLE and xbee there are various callbacks. But they cannot be reliably used for some kind of parallel execution.