16
16
import os
17
17
18
18
log = logging .getLogger ('can.socketcan.native' )
19
+ log_tx = log .getChild ("tx" )
20
+ log_rx = log .getChild ("rx" )
21
+
19
22
log .info ("Loading socketcan native backend" )
20
23
21
24
try :
@@ -321,7 +324,6 @@ def captureMessage(sock):
321
324
return None
322
325
323
326
can_id , can_dlc , data = dissect_can_frame (cf )
324
- log .debug ('Received: can_id=%x, can_dlc=%x, data=%s' , can_id , can_dlc , data )
325
327
326
328
# Fetching the timestamp
327
329
binary_structure = "@LL"
@@ -347,13 +349,17 @@ def captureMessage(sock):
347
349
log .debug ("CAN: Standard" )
348
350
arbitration_id = can_id & 0x000007FF
349
351
350
- return Message (timestamp = timestamp ,
351
- arbitration_id = arbitration_id ,
352
- extended_id = is_extended_frame_format ,
353
- is_remote_frame = is_remote_transmission_request ,
354
- is_error_frame = is_error_frame ,
355
- dlc = can_dlc ,
356
- data = data )
352
+ msg = Message (timestamp = timestamp ,
353
+ arbitration_id = arbitration_id ,
354
+ extended_id = is_extended_frame_format ,
355
+ is_remote_frame = is_remote_transmission_request ,
356
+ is_error_frame = is_error_frame ,
357
+ dlc = can_dlc ,
358
+ data = data )
359
+
360
+ log_rx .debug ('Received: %s' , msg )
361
+
362
+ return msg
357
363
358
364
359
365
class SocketcanNative_Bus (BusABC ):
@@ -417,8 +423,7 @@ def send(self, msg, timeout=None):
417
423
if msg .is_error_frame :
418
424
log .warning ("Trying to send an error frame - this won't work" )
419
425
arbitration_id |= 0x20000000
420
- l = log .getChild ("tx" )
421
- l .debug ("sending: %s" , msg )
426
+ log_tx .debug ("Sending: %s" , msg )
422
427
if timeout :
423
428
# Wait for write availability. send will fail below on timeout
424
429
select .select ([], [self .socket ], [], timeout )
0 commit comments