sipo
Ondřej Hruška 7 years ago
parent ccbff578b3
commit eb58fce25a
  1. 7
      TinyFrame/TF_Integration.c
  2. 18
      TinyFrame/TinyFrame.c
  3. 8
      TinyFrame/TinyFrame.h

@ -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;i<chunksize; i++) {
PRINTF("%02X ", buff[i]);
}
PUTS("\r\n");
buff += chunksize;
total -= chunksize;
}

@ -537,6 +537,7 @@ void _TF_FN TF_AcceptChar(TinyFrame *tf, unsigned char c)
}
if (tf->len == 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;

@ -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 <stdint.h> // for uint8_t etc

Loading…
Cancel
Save