void BUF_writeomfstr(Buffer_t *buffer, const char* text) { assert(buffer != NULL); uint8_t size; size = strlen(text); BUF_write8(buffer, size); BUF_write(buffer, text, size); }
void BUF_writebuffer(Buffer_t *buffer, const Buffer_t *src) { assert(buffer != NULL); BUF_write(buffer, src->data, src->size); }
void BUF_writecstr(Buffer_t *buffer, const char* text) { assert(buffer != NULL); int size = strlen(text); BUF_write(buffer, text, size + 1); }
int main(void) { initUSART(); _delay_ms(200); uint8_t i; uint8_t tempCharStorage; while (1) { dumpBuffer(); printString(" Demo: adding characters to buffer\n"); uint8_t coolString[] = "Howdy"; i = 0; while(i < sizeof(coolString) - 1){ BUF_write(&buffer, coolString[i]); ++i; dumpBuffer(); } printString(" Demo: reading out the first three characters\n"); for (i = 0; i<3 ; i++){ BUF_read(&buffer, &tempCharStorage); transmitByte(tempCharStorage); printString("\n"); dumpBuffer(); } printString(" Demo: adding more characters to buffer\n"); uint8_t anotherString[] = "Hello"; i = 0; while(i < sizeof(anotherString) - 1){ BUF_write(&buffer, anotherString[i]); ++i; dumpBuffer(); } // And read it back out using return code printString(" Demo: reading everything back out\n"); while (BUF_read(&buffer, &tempCharStorage) == BUFFER_OK){ transmitByte(tempCharStorage); } printString("\n"); dumpBuffer(); printString(" Demo: empty! (newest = oldest)\n"); // Fill up buffer, using return code i = 0; while(BUF_write(&buffer, 'A'+i) == BUFFER_OK){ ++i; dumpBuffer(); } printString(" Note: never fills up whole buffer\n"); printString(" it's full when first index equals last\n"); return 0; } /* End event loop */ return 0; /* This line is never reached */ }