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
Revision 5:26efbc3fd451, committed 2020-08-31
- Comitter:
- 38domo
- Date:
- Mon Aug 31 17:49:15 2020 +0000
- Parent:
- 4:5017a65ff423
- Commit message:
- discof746 avec can, ethernet, lcd, ts
Changed in this revision
CANMsg.h | Show annotated file Show diff for this revision Revisions of this file |
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);