Namespaces | Macros | Functions
Message_data.cpp File Reference
#include "husky_base/horizon_legacy/Message_data.h"
#include "husky_base/horizon_legacy/Number.h"
#include "husky_base/horizon_legacy/Transport.h"
#include <iostream>
#include <string>
#include <string.h>
#include <sstream>
Include dependency graph for Message_data.cpp:

Go to the source code of this file.

Namespaces

 clearpath
 

Macros

#define MESSAGE_CONSTRUCTORS(MessageClass, ExpectedLength)
 
#define MESSAGE_CONVENIENCE_FNS(MessageClass, DataMsgID)
 

Functions

 clearpath::MESSAGE_CONSTRUCTORS (DataDifferentialSpeed, PAYLOAD_LEN)
 
 clearpath::MESSAGE_CONSTRUCTORS (DataEncodersRaw,(1+getCount()*4)) uint8_t DataEncodersRaw
 
 clearpath::MESSAGE_CONSTRUCTORS (DataPlatformInfo,(int) strlenModel()+6) uint8_t DataPlatformInfo
 
 clearpath::MESSAGE_CONSTRUCTORS (DataPlatformName,(int)(*getPayloadPointer())+1) string DataPlatformName
 
 clearpath::MESSAGE_CONSTRUCTORS (DataProcessorStatus,(1+getProcessCount()*2)) uint8_t DataProcessorStatus
 
 clearpath::MESSAGE_CONSTRUCTORS (DataRangefinders,(1+getRangefinderCount()*2)) uint8_t DataRangefinders
 
 clearpath::MESSAGE_CONSTRUCTORS (DataRangefinderTimings,(1+getRangefinderCount()*6)) uint8_t DataRangefinderTimings
 
 clearpath::MESSAGE_CONSTRUCTORS (DataRawCurrent,(1+getCurrentCount()*2)) uint8_t DataRawCurrent
 
 clearpath::MESSAGE_CONSTRUCTORS (DataRawTemperature,(1+2 *getTemperatureCount())) uint8_t DataRawTemperature
 
 clearpath::MESSAGE_CONSTRUCTORS (DataRawVoltage,(1+2 *getVoltageCount())) uint8_t DataRawVoltage
 
 clearpath::MESSAGE_CONVENIENCE_FNS (DataDifferentialSpeed, DATA_DIFF_WHEEL_SPEEDS)
 
 clearpath::MESSAGE_CONVENIENCE_FNS (DataEncoders, DATA_ENCODER)
 

Macro Definition Documentation

#define MESSAGE_CONSTRUCTORS (   MessageClass,
  ExpectedLength 
)
Value:
MessageClass::MessageClass(void* input, size_t msg_len) : Message(input, msg_len) \
{ \
if( ((ExpectedLength) >= 0) && ((ssize_t)getPayloadLength() != (ExpectedLength)) ) { \
stringstream ss; \
ss << "Bad payload length: actual="<<getPayloadLength(); \
ss <<" vs. expected="<<(ExpectedLength); \
throw new MessageException(ss.str().c_str(), MessageException::INVALID_LENGTH); \
} \
} \
MessageClass::MessageClass(const MessageClass& other) : Message(other) {}

Macro which generates definitions of the Message constructors ExpectedLength is an expression valid within the constructor which gives the expected payload length of the message. If the length reported in the message header does not match, and exception will be thrown. If ExpectedLength is -1, the length check will be skipped. NB: Some Messages need to do some extra work in the constructor and don't use this macro!

Definition at line 24 of file Message_data.cpp.

#define MESSAGE_CONVENIENCE_FNS (   MessageClass,
  DataMsgID 
)
Value:
MessageClass* MessageClass::popNext() { \
return dynamic_cast<MessageClass*>(Transport::instance().popNext(DataMsgID)); \
} \
\
MessageClass* MessageClass::waitNext(double timeout) { \
return dynamic_cast<MessageClass*>(Transport::instance().waitNext(DataMsgID, timeout)); \
} \
\
MessageClass* MessageClass::getUpdate(double timeout) { \
Transport::instance().flush(DataMsgID); \
subscribe(0); \
return dynamic_cast<MessageClass*>( \
Transport::instance().waitNext(DataMsgID, timeout) ); \
}\
\
void MessageClass::subscribe(uint16_t freq) { \
Request(DataMsgID-0x4000, freq).send(); \
} \
\
enum MessageTypes MessageClass::getTypeID() { \
return DataMsgID; \
}
MessageTypes
Definition: Message.h:211

Macro which generates definitios of the Message convenience functions All message classes should use this macro to define these functions.

Definition at line 41 of file Message_data.cpp.



husky_base
Author(s): Mike Purvis , Paul Bovbel
autogenerated on Fri Oct 2 2020 03:40:07