Patch four-argument sendmsgbuf (#146)

maintains backward compatibility with previous versions of
the function call
This commit is contained in:
Micah Mundy
2023-08-09 08:23:01 +08:00
committed by GitHub
parent 02d18fb3b3
commit 6dcfabc65e
10 changed files with 15 additions and 14 deletions
+1 -1
View File
@@ -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() {
+3 -3
View File
@@ -4,8 +4,8 @@
#include <SPI.h>
#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!");
}
+1 -1
View File
@@ -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!");
}
+3 -3
View File
@@ -1,8 +1,8 @@
// demo: CAN-BUS Shield, send data
#include <SPI.h>
#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
}
+1 -1
View File
@@ -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
}
+2 -2
View File
@@ -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
@@ -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);
}
}
+1 -1
View File
@@ -211,7 +211,7 @@ private:
INT8U openCanBus();
INT8U sendMsgBuf(INT32U id, INT8U ext, INT8U rtr, INT8U len, INT8U *buf);
void parseCanStdId();
void parseCanExtId();
};
+1 -1
View File
@@ -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
+1
View File
@@ -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);