UART Flag Values


#1

When I check the UART flags I’m not getting the codes shown in the table in your documentation:

I’m checking uart.flags() after reading from hardware.uartBCAW on my IMP004m.

HW_UART002 <- hardware.uartBCAW;
HW_UART002.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS, readbackGPS);

I’m reading from a GPS receiver GP-735 https://www.sparkfun.com/products/13670

The GPS broadcasts its data every second.

I get values like 0, 33, 65, and 97.

I can receive GPS strings from the GP-735, but I also get some corrupted strings, which prompted me to check the uart.flags() to see what the problem is. Perhaps I’m doing too much in the readbackGPS function, which is causing me to miss characters.

If you have some tips on managing the incoming data, that would also be helpful. I’m using the GPSParser routines.


#2

I found the uart.setrxfifosize(size) function and bumped up the size to 1k bytes. This cut down the errors dramatically, which tells me the FIFO was being overrun.


#3

The values returned by uart.flags() are a binary bitset:

33 = OVERRUN_ERROR and READ_READY
65 = LINE_IDLE and READ_READY
97 = LINE_IDLE, OVERRUN_ERROR and READ_READY

Yep, worth setting a bigger buffer.

If the GPS is standard NMEA output then the GPS parser library may help you https://developer.electricimp.com/libraries/hardware/gps


#4

I should have picked up on that! I appreciate your patience Hugo.

Indeed, I was seeing lots of overruns, based on the flags, until I increased the buffer size. UART communication is working reliably now.

Yes, it is standard NMEA output, and the GPS parser library works like a champ.

-Frank