From eb58fce25a42c0695eef72bada29c9ace66dad41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 23 Dec 2017 16:31:52 +0100 Subject: [PATCH] updated tf --- TinyFrame/TF_Integration.c | 7 +++++++ TinyFrame/TinyFrame.c | 18 +++++++++++------- TinyFrame/TinyFrame.h | 8 ++++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/TinyFrame/TF_Integration.c b/TinyFrame/TF_Integration.c index de2cf0a..5ddae3d 100644 --- a/TinyFrame/TF_Integration.c +++ b/TinyFrame/TF_Integration.c @@ -23,6 +23,13 @@ void TF_WriteImpl(TinyFrame *tf, const uint8_t *buff, size_t len) assert_param(osOK == osSemaphoreWait(semVcomTxReadyHandle, 5000)); uint16_t chunksize = (uint16_t) MIN(total, CHUNK); assert_param(USBD_OK == CDC_Transmit_FS((uint8_t *) buff, chunksize)); + + PUTS("Tx: "); + for(int i=0;ilen == 0) { + // if the message has no body, we're done. TF_HandleReceivedMessage(tf); TF_ResetParser(tf); break; @@ -773,16 +774,19 @@ static bool _TF_FN TF_SendFrame(TinyFrame *tf, TF_Msg *msg, TF_Listener listener } } - // Flush if checksum wouldn't fit in the buffer - if (TF_SENDBUF_LEN - len < sizeof(TF_CKSUM)) { - TF_WriteImpl(tf, (const uint8_t *) tf->sendbuf, len); - len = 0; + // Checksum only if message had a body + if (msg->len > 0) { + // Flush if checksum wouldn't fit in the buffer + if (TF_SENDBUF_LEN - len < sizeof(TF_CKSUM)) { + TF_WriteImpl(tf, (const uint8_t *) tf->sendbuf, len); + len = 0; + } + + // Add checksum, flush what remains to be sent + len += TF_ComposeTail(tf->sendbuf + len, &cksum); } - // Add checksum, flush what remains to be sent - len += TF_ComposeTail(tf->sendbuf+len, &cksum); TF_WriteImpl(tf, (const uint8_t *) tf->sendbuf, len); - TF_ReleaseTx(tf); return true; diff --git a/TinyFrame/TinyFrame.h b/TinyFrame/TinyFrame.h index a4d92df..a588309 100644 --- a/TinyFrame/TinyFrame.h +++ b/TinyFrame/TinyFrame.h @@ -3,14 +3,14 @@ /** * TinyFrame protocol library - * - * (c) Ondřej Hruška 2017, MIT License + * + * (c) Ondřej Hruška 2017, MIT License * no liability/warranty, free for any use, must retain this notice & license - * + * * Upstream URL: https://github.com/MightyPork/TinyFrame */ -#define TF_VERSION "2.0.1" +#define TF_VERSION "2.0.3" //--------------------------------------------------------------------------- #include // for uint8_t etc