From 6dcfabc65e87c33a36eb4790392b7da6eafa075e Mon Sep 17 00:00:00 2001 From: Micah Mundy Date: Tue, 8 Aug 2023 19:23:01 -0500 Subject: [PATCH] Patch four-argument sendmsgbuf (#146) maintains backward compatibility with previous versions of the function call --- examples/OBDII_PIDs/OBDII_PIDs.ino | 2 +- examples/send/send.ino | 6 +++--- examples/sendFD/sendFD.ino | 2 +- examples/send_Blink/send_Blink.ino | 6 +++--- examples/send_Blink_ROS/send_Blink_ROS.ino | 2 +- examples/send_sleep/send_sleep.ino | 4 ++-- examples/set_mask_filter_send/set_mask_filter_send.ino | 2 +- src/can-serial.h | 2 +- src/mcp2515_can.h | 2 +- src/mcp2518fd_can.h | 1 + 10 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/OBDII_PIDs/OBDII_PIDs.ino b/examples/OBDII_PIDs/OBDII_PIDs.ino index 010fbd1..f3fa1e4 100644 --- a/examples/OBDII_PIDs/OBDII_PIDs.ino +++ b/examples/OBDII_PIDs/OBDII_PIDs.ino @@ -80,7 +80,7 @@ void sendPid(unsigned char __pid) { unsigned char tmp[8] = {0x02, 0x01, __pid, 0, 0, 0, 0, 0}; SERIAL_PORT_MONITOR.print("SEND PID: 0x"); SERIAL_PORT_MONITOR.println(__pid, HEX); - CAN.MCP_CAN::sendMsgBuf(CAN_ID_PID, 0, 8, tmp); + CAN.sendMsgBuf(CAN_ID_PID, 0, 8, tmp); } void setup() { diff --git a/examples/send/send.ino b/examples/send/send.ino index b115416..e54f066 100644 --- a/examples/send/send.ino +++ b/examples/send/send.ino @@ -4,8 +4,8 @@ #include -#define CAN_2515 -// #define CAN_2518FD +//#define CAN_2515 +#define CAN_2518FD // Set SPI CS Pin according to your hardware @@ -61,7 +61,7 @@ void loop() { } } - CAN.MCP_CAN::sendMsgBuf(0x00, 0, 8, stmp); + CAN.sendMsgBuf(0x00, 0, 8, stmp); delay(100); // send data per 100ms SERIAL_PORT_MONITOR.println("CAN BUS sendMsgBuf ok!"); } diff --git a/examples/sendFD/sendFD.ino b/examples/sendFD/sendFD.ino index 1a98d11..69093a0 100644 --- a/examples/sendFD/sendFD.ino +++ b/examples/sendFD/sendFD.ino @@ -54,7 +54,7 @@ void loop() { } } - CAN.MCP_CAN::sendMsgBuf(0x00, 0, CANFD::len2dlc(MAX_DATA_SIZE), stmp); + CAN.sendMsgBuf(0x00, 0, CANFD::len2dlc(MAX_DATA_SIZE), stmp); delay(100); // send data per 100ms SERIAL_PORT_MONITOR.println("CAN BUS sendMsgBuf ok!"); } diff --git a/examples/send_Blink/send_Blink.ino b/examples/send_Blink/send_Blink.ino index 97a6272..ac83f65 100644 --- a/examples/send_Blink/send_Blink.ino +++ b/examples/send_Blink/send_Blink.ino @@ -1,8 +1,8 @@ // demo: CAN-BUS Shield, send data #include -#define CAN_2515 -// #define CAN_2518FD +//#define CAN_2515 +#define CAN_2518FD // Set SPI CS Pin according to your hardware @@ -52,7 +52,7 @@ unsigned char stmp[8] = {ledHIGH, 1, 2, 3, ledLOW, 5, 6, 7}; void loop() { SERIAL_PORT_MONITOR.println("In loop"); // send data: id = 0x70, standard frame, data len = 8, stmp: data buf - CAN.MCP_CAN::sendMsgBuf(0x70, 0, 8, stmp); + CAN.sendMsgBuf(0x70, 0, 8, stmp); delay(1000); // send data once per second } diff --git a/examples/send_Blink_ROS/send_Blink_ROS.ino b/examples/send_Blink_ROS/send_Blink_ROS.ino index 6dd98cc..1a1641c 100644 --- a/examples/send_Blink_ROS/send_Blink_ROS.ino +++ b/examples/send_Blink_ROS/send_Blink_ROS.ino @@ -26,7 +26,7 @@ mcp2515_can CAN(SPI_CS_PIN); // Set CS pin void messageCb(const std_msgs::Empty& toggle_msg) { //digitalWrite(13, HIGH-digitalRead(13)); // blink the led // send data: id = 0x00, standrad frame, data len = 8, stmp: data buf - CAN.MCP_CAN::sendMsgBuf(0x70, 0, 8, stmp); + CAN.sendMsgBuf(0x70, 0, 8, stmp); delay(1000); // send data per 100ms } diff --git a/examples/send_sleep/send_sleep.ino b/examples/send_sleep/send_sleep.ino index f5a7c29..ae1f0ef 100644 --- a/examples/send_sleep/send_sleep.ino +++ b/examples/send_sleep/send_sleep.ino @@ -83,7 +83,7 @@ unsigned char stmp[8] = {0, 0, 0, 0, 0, 0, 0, 0}; void loop() { SERIAL_PORT_MONITOR.println("Sending message"); - CAN.MCP_CAN::sendMsgBuf(0x00, 0, 0, NULL); // Send empty wakeup message + CAN.sendMsgBuf(0x00, 0, 0, NULL); // Send empty wakeup message delay(100); // give the receiving node some time to wake up @@ -100,7 +100,7 @@ void loop() { } } - CAN.MCP_CAN::sendMsgBuf(0x00, 0, 8, stmp); + CAN.sendMsgBuf(0x00, 0, 8, stmp); // sleep diff --git a/examples/set_mask_filter_send/set_mask_filter_send.ino b/examples/set_mask_filter_send/set_mask_filter_send.ino index 679cdef..bb1b294 100644 --- a/examples/set_mask_filter_send/set_mask_filter_send.ino +++ b/examples/set_mask_filter_send/set_mask_filter_send.ino @@ -51,7 +51,7 @@ unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7}; void loop() { for (int id = 0; id < 10; id++) { memset(stmp, id, sizeof(stmp)); // set id to send data buff - CAN.MCP_CAN::sendMsgBuf(id, 0, sizeof(stmp), stmp); + CAN.sendMsgBuf(id, 0, sizeof(stmp), stmp); delay(100); } } diff --git a/src/can-serial.h b/src/can-serial.h index 0133ca9..cf96988 100644 --- a/src/can-serial.h +++ b/src/can-serial.h @@ -211,7 +211,7 @@ private: INT8U openCanBus(); INT8U sendMsgBuf(INT32U id, INT8U ext, INT8U rtr, INT8U len, INT8U *buf); - + void parseCanStdId(); void parseCanExtId(); }; diff --git a/src/mcp2515_can.h b/src/mcp2515_can.h index b5eae50..a95dde0 100644 --- a/src/mcp2515_can.h +++ b/src/mcp2515_can.h @@ -92,7 +92,7 @@ public: virtual byte trySendMsgBuf(unsigned long id, byte ext, byte rtrBit, byte len, const byte *buf, byte iTxBuf = 0xff); // as sendMsgBuf, but does not have any wait for free buffer virtual byte sendMsgBuf(byte status, unsigned long id, byte ext, byte rtrBit, byte len, volatile const byte *buf); // send message buf by using parsed buffer status virtual byte sendMsgBuf(unsigned long id, byte ext, byte rtrBit, byte len, const byte *buf, bool wait_sent = true); // send buf - + using MCP_CAN::sendMsgBuf; // make other overloads visible virtual void clearBufferTransmitIfFlags(byte flags = 0); // Clear transmit flags according to status virtual byte readRxTxStatus(void); // read has something send or received diff --git a/src/mcp2518fd_can.h b/src/mcp2518fd_can.h index 8fc555d..181da31 100644 --- a/src/mcp2518fd_can.h +++ b/src/mcp2518fd_can.h @@ -154,6 +154,7 @@ public: byte dlc, volatile const byte *buf); virtual byte sendMsgBuf(unsigned long id, byte ext, byte rtr, byte dlc, const byte *buf, bool wait_sent = true); + using MCP_CAN::sendMsgBuf; // make other overloads visible virtual void clearBufferTransmitIfFlags(byte flags = 0);