src/circbuf.c
/**
 * Gets a packet out of the buffer
 * 
 * @param cbuf   The circular buffer to use
 * @param buffer The buffer to put the packet into
 * @param length The size of the buffer to put the packet into
 * 
 * @return The number of bytes put into the buffer
 */
Gets a packet out of the buffer

@param cbuf   The circular buffer to use
@param buffer The buffer to put the packet into
@param length The size of the buffer to put the packet into

@return The number of bytes put into the buffer
Gets a packet out of the buffer @param cbuf The circular buffer to use @param buffer The buffer to put the packet into @param length The size of the buffer to put the packet into @return The number of bytes put into the buffer
uint16_t circbuf_getPacket(volatile CircBuf *cbuf, uint8_t *buffer, uint16_t length)
{
    uint16_t i;
    uint8_t byte;
    if (cbuf->packets == 0) {
        return 0;
    }
    i = 0;
    while (!circbuf_isEmpty(cbuf) && (i < length)) {
        byte = circbuf_pop(cbuf);
        buffer[i] = byte;
        i++;
        if (byte == '\r') {
            cbuf->packets--;
            break;
        }
    }
    return i;
}
uint16_t circbuf_getPacket ( volatile CircBuf * cbuf , uint8_t * buffer , uint16_t length ) { uint16_t i ; uint8_t byte ; if ( cbuf -> packets == 0 ) { return 0 ; } i = 0 ; while ( ! circbuf_isEmpty ( cbuf ) && ( i < length ) ) { byte = circbuf_pop ( cbuf ) ; buffer [ i ] = byte ; i ++ ; if ( byte == ' \r ' ) { cbuf -> packets -- ; break ; } } return i ; }
Gets a packet out of the buffer
Gets a packet out of the buffer