Browse Source

Added buffersize member to BinComm.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@824 f9c3cf11-9bcb-44bc-f272-b75c42450872
master
james.goppert 15 years ago
parent
commit
afb134b915
  1. 9
      libraries/APM_BinComm/APM_BinComm.cpp
  2. 9
      libraries/APM_BinComm/APM_BinComm.h

9
libraries/APM_BinComm/APM_BinComm.cpp

@ -45,10 +45,11 @@
#define DEC_MESSAGE_TIMEOUT 1000 #define DEC_MESSAGE_TIMEOUT 1000
BinComm::BinComm(const BinComm::MessageHandler *handlerTable, BinComm::BinComm(const BinComm::MessageHandler *handlerTable,
Stream *interface) : uint16_t rxBufferSize, Stream *interface) :
_handlerTable(handlerTable), _handlerTable(handlerTable),
_decodePhase(DEC_WAIT_P1), _decodePhase(DEC_WAIT_P1),
_lastReceived(millis()) _lastReceived(millis()),
_rxBufferSize(rxBufferSize)
{ {
init(interface); init(interface);
}; };
@ -98,10 +99,10 @@ BinComm::update(void)
// XXX we might want to further constrain this count // XXX we might want to further constrain this count
count = _interface->available(); count = _interface->available();
if (count >= 128) if (count >= _rxBufferSize)
{ {
char text[50]; char text[50];
strncpy(text,"buffer overflow",50); strncpy(text,"<bincomm> buffer overflow",50);
send_msg_status_text(SEVERITY_LOW,text); send_msg_status_text(SEVERITY_LOW,text);
} }

9
libraries/APM_BinComm/APM_BinComm.h

@ -69,9 +69,14 @@ public:
/// ///
/// @param interface The stream that will be used /// @param interface The stream that will be used
/// for telemetry communications. /// for telemetry communications.
///
/// @param rxBuffSize Size of receive buffer allocated by interface.
/// This is used to warn for buffer overflow.
///
/// ///
BinComm(const MessageHandler *handlerTable, BinComm(const MessageHandler *handlerTable,
Stream *interface = NULL); uint16_t rxBufferSize, Stream *interface = NULL);
/// ///
/// Optional initialiser. /// Optional initialiser.
@ -100,6 +105,8 @@ private:
uint8_t payload[256]; uint8_t payload[256];
} _decodeBuf; } _decodeBuf;
uint16_t _rxBufferSize;
/// Outgoing header/packet buffer /// Outgoing header/packet buffer
/// XXX we could make this smaller /// XXX we could make this smaller
struct { struct {

Loading…
Cancel
Save