// Process any queued messages static void read(SENSOR* sensor){ GPS_NMEA* gps = (GPS_NMEA*)sensor; // Keep looping whilst there is a message while(bufferBytesUsed(&gps->msgQueueBuf)){ uint8_t byte; // Got a message so unqueue it size_t dstIndex = 0; do{ byte = 0; bufferGet(&gps->msgQueueBuf,&byte); msgBuf[dstIndex++] = byte; }while(byte != 0); // Now process the message in 'msgBuf' #ifdef DEBUG // Dump out the message PRINTF(stdout,"%s\n",msgBuf); #endif // Process the msg if(msgBuf[3]=='R' && msgBuf[4]=='M' && msgBuf[5]=='C' ){ // $GPRMC msg _gps_process_gprmc(gps,7); }else if(msgBuf[3]=='G' && msgBuf[4]=='G' && msgBuf[5]=='A' ){ // $GPGGA msg _gps_process_gpgga(gps,7); } } __gps_read(sensor); }
otError otPlatRandomGetTrue(uint8_t *aOutput, uint16_t aOutputLength) { otError error = OT_ERROR_NONE; uint8_t copyLength; uint16_t index = 0; otEXPECT_ACTION(aOutput && aOutputLength, error = OT_ERROR_INVALID_ARGS); do { copyLength = (uint8_t)bufferCount(); if (copyLength > aOutputLength - index) { copyLength = aOutputLength - index; } if (copyLength > 0) { for (uint32_t i = 0; i < copyLength; i++) { aOutput[i + index] = bufferGet(); } generatorStart(); index += copyLength; } } while (index < aOutputLength); exit: return error; }
// Flush the current word buffer // out to the phraseBuffer static void flushWord(void){ uint8_t data; size_t wordLen = wordBuffer.datalength; // If the phrase cannot accept the entire // word then say the current phrase first if(bufferFreeSpace(&phraseBuffer) <= wordLen){ flushPhrase(); } // Write the word to the phrase buffer while(bufferGet(&wordBuffer,&data)){ bufferPut(&phraseBuffer,data); } }
static inline uint32_t bufferGetUint32() { uint32_t retVal = 0; if (bufferIsUint32Ready()) { for (uint32_t i = 0; i < 4; i++) { retVal <<= 8; retVal |= bufferGet(); } } return retVal; }