CAN message container. Defines "<<" and ">>" operators to simplify adding/getting data to/from a CAN message.
Dependents: grove_stream_jpa_sd2 grove_stream_jpa_sd2 grove_stream_jpa_sd2-2 grove_stream_jpa_sd2-3
Diff: CANMsg.h
- Revision:
- 5:26efbc3fd451
- Parent:
- 4:5017a65ff423
diff -r 5017a65ff423 -r 26efbc3fd451 CANMsg.h --- a/CANMsg.h Tue Feb 05 14:50:19 2019 +0000 +++ b/CANMsg.h Mon Aug 31 17:49:15 2020 +0000 @@ -15,23 +15,16 @@ class CANMsg : public mbed::CANMessage { public: - /** Creates empty CAN message. - */ + /** Creates empty CAN message. */ CANMsg() : CANMessage(){ } - - /** Creates CAN message with specific content. - */ + /** Creates CAN message with specific content. */ CANMsg(int _id, const char *_data, char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) : CANMessage(_id, _data, _len, _type, _format){ } - - /** Creates CAN remote message. - */ + /** Creates CAN remote message. */ CANMsg(int _id, CANFormat _format = CANStandard) : CANMessage(_id, _format){ } - - /** Clears CAN message content - */ + /** Clears CAN message content */ void clear(void) { len = 0; type = CANData; @@ -39,9 +32,7 @@ id = 0; memset(data, 0, 8); }; - - /** Append operator: Appends data (value) to CAN message - */ + /** Append operator: Appends data (value) to CAN message */ template<class T> CANMsg &operator<<(const T val) { MBED_ASSERT(len + sizeof(T) <= 8); @@ -49,9 +40,7 @@ len += sizeof(T); return *this; } - - /** Extract operator: Extracts data (value) from CAN message - */ + /** Extract operator: Extracts data (value) from CAN message */ template<class T> CANMsg &operator>>(T& val) { MBED_ASSERT(sizeof(T) <= len);