#NEWLINE# def do_write( self , can_msg ) : #NEWLINE# #INDENT# if can_msg . CANData : #NEWLINE# #INDENT# cmd_byte = None #NEWLINE# id_f = None #NEWLINE# if ( ( not can_msg . CANFrame . frame_ext ) and ( write_buf . CANFrame . frame_type == CANMessage . DataFrame ) ) : #NEWLINE# #INDENT# cmd_byte = b't' #NEWLINE# id_f = self . get_hex ( can_msg . CANFrame . frame_raw_id ) . zfill ( 4 ) [ 1 : 4 ] . encode ( 'ISO-8859-1' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( can_msg . CANFrame . frame_ext and ( can_msg . CANFrame . frame_type == CANMessage . DataFrame ) ) : #NEWLINE# #INDENT# cmd_byte = b'T' #NEWLINE# id_f = self . get_hex ( can_msg . CANFrame . frame_raw_id ) . zfill ( 8 ) [ 0 : 8 ] . encode ( 'ISO-8859-1' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not can_msg . CANFrame . frame_ext ) and ( can_msg . CANFrame . frame_type == CANMessage . RemoteFrame ) ) : #NEWLINE# #INDENT# cmd_byte = b'r' #NEWLINE# id_f = self . get_hex ( can_msg . CANFrame . frame_raw_id ) . zfill ( 4 ) [ 1 : 4 ] . encode ( 'ISO-8859-1' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( can_msg . CANFrame . frame_ext and ( can_msg . CANFrame . frame_type == CANMessage . RemoteFrame ) ) : #NEWLINE# #INDENT# cmd_byte = b'R' #NEWLINE# id_f = self . get_hex ( can_msg . CANFrame . frame_raw_id ) . zfill ( 8 ) [ 0 : 8 ] . encode ( 'ISO-8859-1' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if cmd_byte : #NEWLINE# #INDENT# write_buf = ( ( ( ( cmd_byte + id_f ) + str ( can_msg . CANFrame . frame_length ) . encode ( 'ISO-8859-1' ) ) + self . get_hex ( can_msg . CANFrame . frame_raw_data ) . encode ( 'ISO-8859-1' ) ) + b'\r' ) #NEWLINE# self . _serialPort . write ( write_buf ) #NEWLINE# self . dprint ( 2 , ( 'WRITE: ' + write_buf . decode ( 'ISO-8859-1' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return can_msg