Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

UART.ANY()
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

UART.ANY()

by narrab on Sat Aug 26, 2017 4:03 pm

Does Circuit Python have an equivalent command to UART.any() used in MicroPython UART module?

narrab
 
Posts: 15
Joined: Tue Oct 09, 2012 11:09 am

Re: UART.ANY()

by tannewt on Sat Aug 26, 2017 5:47 pm

Not yet though others have asked. Could you give an example of where you'd like to use it? Thanks!

tannewt
 
Posts: 1837
Joined: Thu Oct 06, 2016 8:48 pm

Re: UART.ANY()

by narrab on Sat Aug 26, 2017 8:58 pm

I am not an experienced programer but I have tried to find the MicroPython UART code to see how it could write function to emulate this. I believe it works in the same way as Serial.available() in the arduino language.

If Serial.available() {
do something
}

Here is the link to an example of its use in Micropython

https://github.com/inmcm/micropyGPS/blo ... rt_test.py

How can I dig down into the MicroPython code to see how this function works? I figure a good way to learn is by studying the code.

It might be as simple as checking the UART buffer and if it >0 then it returns true. Thats why I tried to look for the code in micropython.

narrab
 
Posts: 15
Joined: Tue Oct 09, 2012 11:09 am

Re: UART.ANY()

by tannewt on Sun Aug 27, 2017 2:04 am

I believe you should be able to call read() and get None back if nothing is available. If we do add it then calling available like Arduino makes more sense to me.

If you want to dig into the code, its a bit tricky with the UART. It basically starts here: https://github.com/adafruit/circuitpyth ... ART.c#L265

tannewt
 
Posts: 1837
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.