mirror of
https://github.com/Seeed-Studio/Seeed_Arduino_CAN.git
synced 2026-07-27 19:55:59 +00:00
@@ -2,19 +2,19 @@
|
||||
#include <mcp_can.h>
|
||||
|
||||
struct can_frame canMsg;
|
||||
MCP_CAN mcp2551(10, MCP_CAN::MODE_NORMAL);
|
||||
MCP_CAN mcp2515(10, MCP_CAN::MODE_NORMAL);
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
mcp2551.begin(CAN_125KBPS);
|
||||
mcp2515.begin(CAN_125KBPS);
|
||||
Serial.println("------- CAN Read ----------");
|
||||
Serial.println("ID DLC DATA");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (mcp2551.readMessage(&canMsg) == MCP_CAN::ERROR_OK) {
|
||||
if (mcp2515.readMessage(&canMsg) == MCP_CAN::ERROR_OK) {
|
||||
|
||||
Serial.print(canMsg.can_id); // print ID
|
||||
|
||||
|
||||
Reference in New Issue
Block a user