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

Commit 9c51c7e

Browse files
authored
Added error check on WriteCan example (#36)
- Added error check on WriteCan example - Modified Digital_output example in order to call or setLatch or setRetry
1 parent ce428b1 commit 9c51c7e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

examples/CAN/WriteCan/WriteCan.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ void loop() {
4545
mbed::CANMessage msg = mbed::CANMessage(13ul, &payload, payload_size);
4646
if (comm_protocols.can.write(msg)) {
4747
Serial.println("Message sent");
48+
} else {
49+
Serial.println("Transmission Error: ");
50+
Serial.println(comm_protocols.can.tderror());
51+
comm_protocols.can.reset();
4852
}
4953

5054
delay(100);

examples/Digital_output/Digital_output.ino

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ using namespace automation;
3939

4040
void setup() {
4141
Serial.begin(9600);
42-
//The loop starts only when the serial monitor is opened.
42+
// The loop starts only when the serial monitor is opened.
4343
while (!Serial);
4444

4545
//Set over current behavior of all channels to latch mode:
4646
digital_programmables.setLatch();
47-
//Set over current behavior of all channels to auto retry mode:
48-
digital_programmables.setRetry();
47+
48+
// Uncomment this line to set over current behavior of all
49+
// channels to auto retry mode instead of latch mode:
50+
// digital_programmables.setRetry();
4951

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

58-
//Set all channels to CLOSED
60+
// Set all channels to CLOSED
5961
digital_outputs.setAll(255);
6062
Serial.print("All channels are CLOSED for 1s...");
6163
delay(1000);
6264

63-
//Set all channels to OPEN
65+
// Set all channels to OPEN
6466
digital_outputs.setAll(0);
6567
Serial.println("now they are OPEN.");
6668
delay(1000);
6769

68-
//Toggle each channel for 1s, one by one
70+
// Toggle each channel for 1s, one by one
6971

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

0 commit comments

Comments
 (0)