File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed
Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change 11from pyb import CAN
22
3- can = CAN (1 )
3+ can = CAN (1 , CAN . LOOPBACK )
44print (can )
5- can .init (CAN .LOOPBACK )
65print (can .any (0 ))
76can .send ('abcd' , 123 )
87print (can .any (0 ))
98print (can .recv (0 ))
9+
10+ can .send ('abcd' , - 1 )
11+ print (can .recv (0 ))
12+
13+ can .send ('abcd' , 0x7FF + 1 )
14+ print (can .recv (0 ))
15+
16+ #Test too long message
17+ try :
18+ can .send ('abcdefghi' , 0x7FF )
19+ except ValueError :
20+ print ('passed' )
21+ else :
22+ print ('failed' )
23+
24+ del can
25+
26+ #Testing extended IDs
27+ can = CAN (1 , CAN .LOOPBACK , extframe = True )
28+ print (can )
29+
30+ try :
31+ can .send ('abcde' , 0x7FF + 1 )
32+ except ValueError :
33+ print ('failed' )
34+ else :
35+ r = can .recv (0 )
36+ if r [0 ] == 0x7FF + 1 and r [3 ] == b'abcde' :
37+ print ('passed' )
38+ else :
39+ print ('failed, wrong data received' )
40+
41+
42+ print ('end' )
Original file line number Diff line number Diff line change 1- CAN(1)
1+ CAN(1, LOOPBACK, False )
22False
33True
44(123, 0, 0, b'abcd')
5+ (2047, 0, 0, b'abcd')
6+ (0, 0, 0, b'abcd')
7+ passed
8+ CAN(1, LOOPBACK, True)
9+ passed
10+ end
You can’t perform that action at this time.
0 commit comments