From 9f9bca0f197ee7920dc4daa81cbb4c6698e660a7 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 5 Jun 2013 11:50:33 +0200 Subject: Bridge protocol frame lenght is now a 16-bit field. Added more efficient Bridge.trasnfer() methods. --- libraries/Bridge/Bridge.cpp | 46 ++++++++++++++++++++++++++++++++------------- libraries/Bridge/Bridge.h | 16 ++++++++++++++-- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/libraries/Bridge/Bridge.cpp b/libraries/Bridge/Bridge.cpp index f13f909..2aafc52 100644 --- a/libraries/Bridge/Bridge.cpp +++ b/libraries/Bridge/Bridge.cpp @@ -168,21 +168,34 @@ bool BridgeClass::crcCheck(uint16_t _CRC) { return CRC == _CRC; } -uint8_t BridgeClass::transfer(const uint8_t *buff, uint8_t len, - uint8_t *rxbuff, uint8_t rxlen) +uint8_t BridgeClass::transfer(const uint8_t *buff1, uint16_t len1, + const uint8_t *buff2, uint16_t len2, + const uint8_t *buff3, uint16_t len3, + uint8_t *rxbuff, uint16_t rxlen) { + uint16_t len = len1 + len2 + len3; for ( ; ; delay(100), dropAll() /* Delay for retransmission */) { // Send packet crcReset(); - write((char)0xFF); // Start of packet (0xFF) + write((char)0xFF); // Start of packet (0xFF) crcUpdate(0xFF); - write((char)index); // Message index + write((char)index); // Message index crcUpdate(index); - write((char)len); // Message length - crcUpdate(len); - for (uint8_t i=0; i> 8) & 0xFF)); // Message length (hi) + crcUpdate((len >> 8) & 0xFF); + write((char)(len & 0xFF)); // Message length (lo) + crcUpdate(len & 0xFF); + for (uint8_t i=0; i