summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorHenrik <henrik.solver@gmail.com>2015-04-17 21:15:26 +0200
committerDamien George <damien.p.george@gmail.com>2015-04-18 14:53:00 +0100
commite3cd1543170a9b00b75fb0d1d097f0d68dc8d45b (patch)
tree651c11d9ad82968006e3be55f00d55655caaf6ee /tests
parent259eaab9a9de1b01ac45803fe4f0e58b90f99d84 (diff)
downloadmicropython-e3cd1543170a9b00b75fb0d1d097f0d68dc8d45b.tar.gz
micropython-e3cd1543170a9b00b75fb0d1d097f0d68dc8d45b.zip
stmhal: Add support for sending and receiving CAN RTR messages.
Diffstat (limited to 'tests')
-rw-r--r--tests/pyb/can.py37
-rw-r--r--tests/pyb/can.py.exp40
2 files changed, 62 insertions, 15 deletions
diff --git a/tests/pyb/can.py b/tests/pyb/can.py
index 5fd4d39d05..63a3be4e92 100644
--- a/tests/pyb/can.py
+++ b/tests/pyb/can.py
@@ -151,3 +151,40 @@ except OSError as e:
pyb.delay(500)
while can.any(0):
print(can.recv(0))
+
+# Testing rtr messages
+bus1 = CAN(1, CAN.LOOPBACK)
+bus2 = CAN(2, CAN.LOOPBACK, extframe = True)
+while bus1.any(0):
+ bus1.recv(0)
+while bus2.any(0):
+ bus2.recv(0)
+bus1.setfilter(0, CAN.LIST16, 0, (1, 2, 3, 4))
+bus1.setfilter(1, CAN.LIST16, 0, (5, 6, 7, 8), rtr=(True, True, True, True))
+bus1.setfilter(2, CAN.MASK16, 0, (64, 64, 32, 32), rtr=(False, True))
+bus2.setfilter(0, CAN.LIST32, 0, (1, 2), rtr=(True, True))
+bus2.setfilter(1, CAN.LIST32, 0, (3, 4), rtr=(True, False))
+bus2.setfilter(2, CAN.MASK32, 0, (16, 16), rtr=(False,))
+bus2.setfilter(2, CAN.MASK32, 0, (32, 32), rtr=(True,))
+
+bus1.send('',1,rtr=True)
+print(bus1.any(0))
+bus1.send('',5,rtr=True)
+print(bus1.recv(0))
+bus1.send('',6,rtr=True)
+print(bus1.recv(0))
+bus1.send('',7,rtr=True)
+print(bus1.recv(0))
+bus1.send('',16,rtr=True)
+print(bus1.any(0))
+bus1.send('',32,rtr=True)
+print(bus1.recv(0))
+
+bus2.send('',1,rtr=True)
+print(bus2.recv(0))
+bus2.send('',2,rtr=True)
+print(bus2.recv(0))
+bus2.send('',3,rtr=True)
+print(bus2.recv(0))
+bus2.send('',4,rtr=True)
+print(bus2.any(0))
diff --git a/tests/pyb/can.py.exp b/tests/pyb/can.py.exp
index 845f6d5ba1..ec6f97ea02 100644
--- a/tests/pyb/can.py.exp
+++ b/tests/pyb/can.py.exp
@@ -2,9 +2,9 @@ CAN(1)
CAN(1, CAN.LOOPBACK, extframe=False)
False
True
-(123, 0, 0, b'abcd')
-(2047, 0, 0, b'abcd')
-(0, 0, 0, b'abcd')
+(123, False, 0, b'abcd')
+(2047, False, 0, b'abcd')
+(0, False, 0, b'abcd')
passed
CAN(1, CAN.LOOPBACK, extframe=True)
passed
@@ -20,21 +20,31 @@ cb1
full
cb1a
overflow
-(1, 0, 0, b'11111111')
-(2, 0, 1, b'22222222')
-(4, 0, 3, b'44444444')
-(5, 0, 0, b'55555555')
-(6, 0, 1, b'66666666')
-(8, 0, 3, b'88888888')
+(1, False, 0, b'11111111')
+(2, False, 1, b'22222222')
+(4, False, 3, b'44444444')
+(5, False, 0, b'55555555')
+(6, False, 1, b'66666666')
+(8, False, 3, b'88888888')
cb0a
pending
cb1a
pending
-(1, 0, 0, b'11111111')
-(5, 0, 0, b'55555555')
+(1, False, 0, b'11111111')
+(5, False, 0, b'55555555')
False
-(1, 0, 0, b'abcde')
+(1, False, 0, b'abcde')
passed
-(2, 0, 0, b'abcde')
-(3, 0, 0, b'abcde')
-(4, 0, 0, b'abcde')
+(2, False, 0, b'abcde')
+(3, False, 0, b'abcde')
+(4, False, 0, b'abcde')
+False
+(5, True, 4, b'')
+(6, True, 5, b'')
+(7, True, 6, b'')
+False
+(32, True, 9, b'')
+(1, True, 0, b'')
+(2, True, 1, b'')
+(3, True, 2, b'')
+False