Hello, i am using v2 with uno r3.
Here is my code:
#include "Config.h"
#include "Components/Can.h"
#include "mcp2515_can.h"
mcp2515_can CAN(9);
namespace ii::blackbox::components {
unsigned char len = 0;
unsigned char buf[8];
char str[20];
void Can::SetUp() {
while (CAN.begin(CAN_500KBPS) != 0) {
#ifdef SERIAL_DEBUG
SERIAL_PORT_MONITOR.println("CAN init fail, retry...");
#endif
delay(100);
}
CAN.setMode(MODE_NORMAL);
#ifdef SERIAL_DEBUG
SERIAL_PORT_MONITOR.println("CAN init OK.");
#endif
unsigned char stmp[8] = {0x02, 0x90, 0x02, 0, 0, 0, 0, 0};
for (size_t i = 0; i < 10; i++) {
auto send = CAN.sendMsgBuf(0x7DF, 0, 8, stmp);
if (send == CAN_OK) {
SERIAL_PORT_MONITOR.println("CAN send OK.");
}
else {
SERIAL_PORT_MONITOR.println("CAN send fail.");
}
}
}
void Can::Loop() {
while (CAN_MSGAVAIL == CAN.checkReceive()) {
// read data, len: data length, buf: data buf
CAN.readMsgBuf(&len, buf);
for (int i = 0; i < len; i++) {
SERIAL_PORT_MONITOR.print(buf[i]);
SERIAL_PORT_MONITOR.print(",");
m_logger.Log(g_logFileName, buf[i]);
}
SERIAL_PORT_MONITOR.println();
SERIAL_PORT_MONITOR.println("----");
m_logger.Log(g_logFileName, "\n");
}
}
} // namespace ii::blackbox::components
Loop back mode works as expected, but normal mode outputs:
CAN send fail.
CAN send fail.
CAN send fail.
CAN send fail.
CAN send fail.
CAN send fail.
CAN send fail.
CAN send fail.
CAN send fail.
Also i cutted P1 at all and desoldered the R3. I am testing with car ( w204 ) and PCAN-USB FD. Both of them not works. Am connecting PCAN FD cable or car by DB9.