/* * Read and update the current GPS data. */ void EM411Update(void) { int count=0; /* * Get message */ while((curMsg[count] = chIOGet(&SD2)) != '\n' && count < EMEA_BUFFER_SIZE) { //curMsg[count] = chIOGet(&SD2); count++; } /* * Copy message to output buffer * Also fill data structure. */ chMtxLock(&em411mtx); strncpy(lastMsg, curMsg, EMEA_BUFFER_SIZE-1); EM411Decode(lastMsg); chMtxUnlock(); /* * Clear buffer. */ memset(curMsg, 0, EMEA_BUFFER_SIZE); }
/** * @brief Reads a whole line from the input channel. * * @param[in] chp pointer to a @p BaseChannel object * @param[in] line pointer to the line buffer * @param[in] size buffer maximum length * @return The operation status. * @retval TRUE the channel was reset or CTRL-D pressed. * @retval FALSE operation successful. */ bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size) { char *p = line; while (TRUE) { short c = (short)chIOGet(chp); if (c < 0) return TRUE; if (c == 4) { chprintf(chp, "^D"); return TRUE; } if (c == 8) { if (p != line) { chIOPut(chp, (uint8_t)c); chIOPut(chp, 0x20); chIOPut(chp, (uint8_t)c); p--; } continue; } if (c == '\r') { chprintf(chp, "\r\n"); *p = 0; return FALSE; } if (c < 0x20) continue; if (p < line + size - 1) { chIOPut(chp, (uint8_t)c); *p++ = (char)c; } } }