Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: CAN_Hello EinlesenSensorabstand_digital_2 CAN_STABLE_EINSTEIN CAN_ex_STM32F103C8T6 ... more
Revision 2:2b8425b12d05, committed 2018-03-29
- Comitter:
- hudakz
- Date:
- Thu Mar 29 18:56:19 2018 +0000
- Parent:
- 1:34738eb16cf7
- Child:
- 3:4e42fdc0459f
- Commit message:
- Updated.
Changed in this revision
| CANMsg.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/CANMsg.h Sat Mar 18 23:09:30 2017 +0000
+++ b/CANMsg.h Thu Mar 29 18:56:19 2018 +0000
@@ -44,32 +44,20 @@
*/
template<class T>
CANMsg &operator<<(const T val) {
- if(len + sizeof(T) <= 8) {
- *reinterpret_cast < T * > (&data[len]) = val;
- len += sizeof(T);
- }
-#if DEBUG
- else {
- printf("Error: Cannot append data - exceeding CAN data length!\r\n");
- }
-#endif
- return *this;
+ MBED_ASSERT(len + sizeof(T) <= 8);
+ *reinterpret_cast<T*>(&data[len]) = val;
+ len += sizeof(T);
+ return *this;
}
/** Extract operator: Extracts data (value) from CAN message
*/
template<class T>
CANMsg &operator>>(T& val) {
- if(sizeof(T) <= len) {
- val = *reinterpret_cast < T * > (&data[0]);
- len -= sizeof(T);
- memcpy(data, data + sizeof(T), len);
- }
-#if DEBUG
- else {
- printf("Error: Cannot extract data - exceeding CAN data length!\r\n");
- }
-#endif
+ MBED_ASSERT(sizeof(T) <= len);
+ val = *reinterpret_cast<T*>(&data[0]);
+ len -= sizeof(T);
+ memcpy(data, data + sizeof(T), len);
return *this;
}
};