Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Added error check on WriteCan example #36

Merged
merged 2 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/CAN/WriteCan/WriteCan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void loop() {
mbed::CANMessage msg = mbed::CANMessage(13ul, &payload, payload_size);
if (comm_protocols.can.write(msg)) {
Serial.println("Message sent");
} else {
Serial.println("Transmission Error: ");
Serial.println(comm_protocols.can.tderror());
comm_protocols.can.reset();
}

delay(100);
Expand Down
14 changes: 8 additions & 6 deletions examples/Digital_output/Digital_output.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ using namespace automation;

void setup() {
Serial.begin(9600);
//The loop starts only when the serial monitor is opened.
// The loop starts only when the serial monitor is opened.
while (!Serial);

//Set over current behavior of all channels to latch mode:
digital_programmables.setLatch();
//Set over current behavior of all channels to auto retry mode:
digital_programmables.setRetry();

// Uncomment this line to set over current behavior of all
// channels to auto retry mode instead of latch mode:
// digital_programmables.setRetry();

//At startup set all channels to OPEN
digital_outputs.setAll(0);
Expand All @@ -55,17 +57,17 @@ void setup() {
void loop() {
Serial.println("DIGITAL OUT:");

//Set all channels to CLOSED
// Set all channels to CLOSED
digital_outputs.setAll(255);
Serial.print("All channels are CLOSED for 1s...");
delay(1000);

//Set all channels to OPEN
// Set all channels to OPEN
digital_outputs.setAll(0);
Serial.println("now they are OPEN.");
delay(1000);

//Toggle each channel for 1s, one by one
// Toggle each channel for 1s, one by one

digital_outputs.set(0, HIGH);
Serial.print("CH0 is CLOSED for 1s...");
Expand Down