File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
libraries/CAN/examples/CAN1Read Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* *************************************************************************************
2
+ * INCLUDE
3
+ **************************************************************************************/
4
+
5
+ #include < CAN.h>
6
+
7
+ /* *************************************************************************************
8
+ * SETUP/LOOP
9
+ **************************************************************************************/
10
+
11
+ void setup ()
12
+ {
13
+ Serial.begin (115200 );
14
+ while (!Serial) { }
15
+
16
+ /* You need to enable the CAN transceiver
17
+ * by commenting in below code when using
18
+ * a Portenta H33 on a Portenta Max Carrier.
19
+ * Note: Only CAN1 is available on the Portenta
20
+ * Max Carrier's RJ10 CAN connector.
21
+ */
22
+ #if (PIN_CAN1_STBY >= 0)
23
+ pinMode (PIN_CAN1_STBY, OUTPUT);
24
+ digitalWrite (PIN_CAN1_STBY, LOW);
25
+ #endif
26
+
27
+ if (!CAN1.begin (CanBitRate::BR_250k))
28
+ {
29
+ Serial.println (" CAN.begin(...) failed." );
30
+ for (;;) {}
31
+ }
32
+ }
33
+
34
+ void loop ()
35
+ {
36
+ if (CAN1.available ())
37
+ {
38
+ CanMsg const msg = CAN1.read ();
39
+ Serial.println (msg);
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments