5
5
6
6
import serial
7
7
8
- import can
8
+ import can . interfaces . slcan
9
9
10
10
from .config import IS_PYPY
11
11
@@ -58,9 +58,8 @@ def test_send_extended(self):
58
58
arbitration_id = 0x12ABCDEF , is_extended_id = True , data = [0xAA , 0x55 ]
59
59
)
60
60
self .bus .send (msg )
61
- expected = b"T12ABCDEF2AA55\r "
62
- data = self .serial .read (len (expected ))
63
- self .assertEqual (data , expected )
61
+ rx_msg = self .bus .recv (TIMEOUT )
62
+ self .assertTrue (msg .equals (rx_msg , timestamp_delta = None ))
64
63
65
64
def test_recv_standard (self ):
66
65
self .serial .write (b"t4563112233\r " )
@@ -77,9 +76,8 @@ def test_send_standard(self):
77
76
arbitration_id = 0x456 , is_extended_id = False , data = [0x11 , 0x22 , 0x33 ]
78
77
)
79
78
self .bus .send (msg )
80
- expected = b"t4563112233\r "
81
- data = self .serial .read (len (expected ))
82
- self .assertEqual (data , expected )
79
+ rx_msg = self .bus .recv (TIMEOUT )
80
+ self .assertTrue (msg .equals (rx_msg , timestamp_delta = None ))
83
81
84
82
def test_recv_standard_remote (self ):
85
83
self .serial .write (b"r1238\r " )
@@ -95,9 +93,8 @@ def test_send_standard_remote(self):
95
93
arbitration_id = 0x123 , is_extended_id = False , is_remote_frame = True , dlc = 8
96
94
)
97
95
self .bus .send (msg )
98
- expected = b"r1238\r "
99
- data = self .serial .read (len (expected ))
100
- self .assertEqual (data , expected )
96
+ rx_msg = self .bus .recv (TIMEOUT )
97
+ self .assertTrue (msg .equals (rx_msg , timestamp_delta = None ))
101
98
102
99
def test_recv_extended_remote (self ):
103
100
self .serial .write (b"R12ABCDEF6\r " )
@@ -113,9 +110,8 @@ def test_send_extended_remote(self):
113
110
arbitration_id = 0x12ABCDEF , is_extended_id = True , is_remote_frame = True , dlc = 6
114
111
)
115
112
self .bus .send (msg )
116
- expected = b"R12ABCDEF6\r "
117
- data = self .serial .read (len (expected ))
118
- self .assertEqual (data , expected )
113
+ rx_msg = self .bus .recv (TIMEOUT )
114
+ self .assertTrue (msg .equals (rx_msg , timestamp_delta = None ))
119
115
120
116
def test_partial_recv (self ):
121
117
self .serial .write (b"T12ABCDEF" )
0 commit comments