Skip to content

Commit

Permalink
improve init
Browse files Browse the repository at this point in the history
  • Loading branch information
yconst committed Apr 23, 2024
1 parent c13bf6a commit 9d4ab2b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/arduino_uno_mcp2515/arduino_uno_mcp2515.ino
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Tinymovr tinymovr(1, &send_cb, &recv_cb, &delay_us_cb, 100);
void setup()
{
Serial.begin(115200);
CAN.setPins(12, 13);
while (!Serial);

// Most MCP2515 breakouts have a 8MHz crystal, this needs
// to be specified here
Expand All @@ -118,10 +118,15 @@ void setup()
// As a final step check that the hash returned by the node
// is the same as the hash stored by the Tinymovr library.
// This is crucial to prevent potential mismatches in commands.
if (tinymovr.get_protocol_hash() != avlos_proto_hash)
uint32_t got_hash = tinymovr.get_protocol_hash();
if (got_hash != avlos_proto_hash)
{
Serial.println("Wrong device spec!");
while (1);
Serial.print("Got: ");
Serial.println(got_hash);
Serial.print("Need: ");
Serial.println(avlos_proto_hash);
while(1);
}
}

Expand Down

0 comments on commit 9d4ab2b

Please sign in to comment.