@@ -6,7 +6,7 @@ def msg(x):
6
6
if DEBUG :
7
7
print ("S:" , binascii .hexlify (x ))
8
8
if len (x ) <= 7 :
9
- ret = chr ( len (x )). encode ( "utf8" ) + x
9
+ ret = bytes ([ len (x )] ) + x
10
10
else :
11
11
assert False
12
12
return ret .ljust (8 , b"\x00 " )
@@ -40,7 +40,7 @@ def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr):
40
40
dat = msg [3 :]
41
41
42
42
# 0 block size?
43
- CONTINUE = chr ( subaddr ). encode ( "utf8" ) + b"\x30 " + b"\x00 " * 6
43
+ CONTINUE = bytes ([ subaddr ] ) + b"\x30 " + b"\x00 " * 6
44
44
panda .can_send (sendaddr , CONTINUE , bus )
45
45
46
46
idx = 1
@@ -68,22 +68,22 @@ def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None):
68
68
if len (x ) <= 7 and subaddr is None :
69
69
panda .can_send (addr , msg (x ), bus )
70
70
elif len (x ) <= 6 and subaddr is not None :
71
- panda .can_send (addr , chr ( subaddr ). encode ( "utf8" ) + msg (x )[0 :7 ], bus )
71
+ panda .can_send (addr , bytes ([ subaddr ] ) + msg (x )[0 :7 ], bus )
72
72
else :
73
73
if subaddr :
74
- ss = ( chr ( subaddr ) + chr ( 0x10 + (len (x )>> 8 ) ) + chr ( len (x )& 0xFF )). encode ( "utf8" ) + x [0 :5 ]
74
+ ss = bytes ([ subaddr ] ) + bytes ([ 0x10 + (len (x ) >> 8 )] ) + bytes ([ len (x ) & 0xFF ] ) + x [0 :5 ]
75
75
x = x [5 :]
76
76
else :
77
- ss = ( chr ( 0x10 + (len (x )>> 8 ) ) + chr ( len (x )& 0xFF )). encode ( "utf8" ) + x [0 :6 ]
77
+ ss = bytes ([ 0x10 + (len (x ) >> 8 )] ) + bytes ([ len (x ) & 0xFF ] ) + x [0 :6 ]
78
78
x = x [6 :]
79
79
idx = 1
80
80
sends = []
81
81
while len (x ) > 0 :
82
82
if subaddr :
83
- sends .append (((( chr ( subaddr ) + chr ( 0x20 + (idx & 0xF ))). encode ( 'utf8' ) + x [0 :6 ]).ljust (8 , b"\x00 " )))
83
+ sends .append (((bytes ([ subaddr ] ) + bytes ([ 0x20 + (idx & 0xF )] ) + x [0 :6 ]).ljust (8 , b"\x00 " )))
84
84
x = x [6 :]
85
85
else :
86
- sends .append (((chr ( 0x20 + (idx & 0xF )). encode ( "utf8" ) + x [0 :7 ]).ljust (8 , b"\x00 " )))
86
+ sends .append (((bytes ([ 0x20 + (idx & 0xF )] ) + x [0 :7 ]).ljust (8 , b"\x00 " )))
87
87
x = x [7 :]
88
88
idx += 1
89
89
@@ -107,7 +107,7 @@ def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
107
107
else :
108
108
msg = recv (panda , 1 , addr , bus )[0 ]
109
109
110
- if msg [0 ]& 0xf0 == 0x10 :
110
+ if msg [0 ] & 0xf0 == 0x10 :
111
111
# first
112
112
tlen = ((msg [0 ] & 0xf ) << 8 ) | msg [1 ]
113
113
dat = msg [2 :]
0 commit comments