From cb0b7c5f70af00fb40f0b1e062340420c1e253a1 Mon Sep 17 00:00:00 2001 From: TheRo0T Date: Wed, 13 Jan 2016 16:13:38 +0400 Subject: [PATCH] Add Example CAN Read --- examples/CAN_read/CAN_read.ino | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/CAN_read/CAN_read.ino diff --git a/examples/CAN_read/CAN_read.ino b/examples/CAN_read/CAN_read.ino new file mode 100644 index 0000000..8767340 --- /dev/null +++ b/examples/CAN_read/CAN_read.ino @@ -0,0 +1,35 @@ +#include +#include + +struct can_frame canMsg; +MCP_CAN mcp2551(10, MCP_CAN::MODE_NORMAL); + + +void setup() { + Serial.begin(115200); + mcp2551.begin(CAN_125KBPS); + Serial.println("------- CAN Read ----------"); + Serial.println("ID DLC DATA"); + +} + +void loop() { + + if (mcp2551.readMessage(&canMsg) == MCP_CAN::ERROR_OK) { + + Serial.print(canMsg.can_id); // print ID + + Serial.print(canMsg.can_dlc); // print DLC + + for(int i = 0; i