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.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
CAN-xbee.h
00001 #ifndef CAN_XBEE_H 00002 #define CAN_XBEE_H 00003 00004 #include "mbed.h" 00005 #include "MODSERIAL.h" 00006 00007 // The string format of a CAN message shall be: 00008 // char0: Letter 'C' - start of a CAN message 00009 // char1: message type = (extended?1:0 << 0) | (RTR?1:0 << 1) | (DLC << 2) 00010 // char1: ID lower byte 00011 // char2: ID upper byte 00012 // char3-10: data bytes (lowest first) 00013 // lastChar: \n - newline = end of message 00014 // 00015 // Extended ID message is the same but with more ID bytes. 00016 // RTR messages show up as empty messages (no data, DLC=0) but are otherwise indistinguishable. 00017 00018 class CANxbee { 00019 public: 00020 CANxbee(PinName tx, PinName rx, int baud, int txSize, int rxSize); 00021 00022 bool send(CANMessage &msg, unsigned int* length); // Send a CANMessage object over the xbee (first converts to serial) 00023 bool receive(CANMessage &msg); // Receive a CANMessage object over the xbee (converts from serial message to CAN) 00024 void baud(int baudrate) { 00025 serial.baud(baudrate); 00026 } 00027 bool txSize(unsigned int size) { 00028 return (serial.txBufferSetSize(size) == 0); 00029 } 00030 bool rxSize(unsigned int size) { 00031 return (serial.rxBufferSetSize(size) == 0); 00032 } 00033 private: 00034 MODSERIAL serial; 00035 char rxBuff[15]; 00036 int rx_i; 00037 int getChars; 00038 }; 00039 00040 #endif
Generated on Fri Jul 15 2022 06:07:18 by
1.7.2
