From aedcc28e689bcc831a9870fe06ce5a2882532cef Mon Sep 17 00:00:00 2001 From: klueska Date: Mon, 3 Sep 2007 20:29:08 +0000 Subject: [PATCH] Update to allow buffer size to be changed at compile time --- tos/lib/printf/PrintfP.nc | 6 +++--- tos/lib/printf/printf.h | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tos/lib/printf/PrintfP.nc b/tos/lib/printf/PrintfP.nc index deda30c6..c69c809a 100644 --- a/tos/lib/printf/PrintfP.nc +++ b/tos/lib/printf/PrintfP.nc @@ -69,12 +69,12 @@ implementation { S_STOPPED, S_FLUSHING, }; - + message_t printfMsg; nx_uint8_t buffer[PRINTF_BUFFER_SIZE]; norace nx_uint8_t* next_byte; uint8_t state = S_STOPPED; - uint8_t bytes_left_to_flush; + uint32_t bytes_left_to_flush; uint8_t length_to_send; task void retrySend() { @@ -86,7 +86,7 @@ implementation { printf_msg_t* m = (printf_msg_t*)call Packet.getPayload(&printfMsg, NULL); length_to_send = (bytes_left_to_flush < sizeof(printf_msg_t)) ? bytes_left_to_flush : sizeof(printf_msg_t); memset(m->buffer, 0, sizeof(printf_msg_t)); - memcpy(m->buffer, (uint8_t*)next_byte, length_to_send); + memcpy(m->buffer, (nx_uint8_t*)next_byte, length_to_send); if(call AMSend.send(AM_BROADCAST_ADDR, &printfMsg, sizeof(printf_msg_t)) != SUCCESS) post retrySend(); else { diff --git a/tos/lib/printf/printf.h b/tos/lib/printf/printf.h index a7cb005a..fcaee280 100644 --- a/tos/lib/printf/printf.h +++ b/tos/lib/printf/printf.h @@ -30,6 +30,10 @@ #ifndef PRINTF_H #define PRINTF_H +#ifndef PRINTF_BUFFER_SIZE +#define PRINTF_BUFFER_SIZE 250 +#endif + #ifdef _H_msp430hardware_h #include #endif @@ -38,8 +42,6 @@ #endif #include "message.h" -#define PRINTF_BUFFER_SIZE 250 - typedef nx_struct printf_msg { nx_uint8_t buffer[TOSH_DATA_LENGTH]; } printf_msg_t; -- 2.39.2