tao_z
2022-08-23 989919a73c5ebd46368991b6c3ff6959e32490b6
test.py
@@ -14,6 +14,8 @@
from ShifterDefine import *
import cantools
from pprint import pprint
import binascii
from hexread import *
# def rece_msg(bus):
#     msg = bus.Receive(0.1)
#     if msg[0] is not None:
@@ -52,7 +54,7 @@
    "IndicationLEDControl": 0x8101
}
print(DID_dic["IndicationLEDControl"])
# print(DID_dic["IndicationLEDControl"])
# def f(conn):
#     conn.send([1, 'test', None])
@@ -217,31 +219,44 @@
#     sys.exit(app.exec_())
dbc = cantools.database.load_file("DBC/SX7H.dbc")
# print(dbc.messages)
sa_message = dbc.get_message_by_name('SA1')
# print(sa_message)
# pprint(sa_message.signals)
frame = [0x00, 0x0A, 0x00, 0xF0, 0, 0, 0, 0]
input_signal = dbc.decode_message(0x420, frame)
part_str = str(input_signal['SA1_Status_ParkButtonReq'])
pprint(part_str)
if input_signal['SA1_Status_ParkButtonReq'] == 'No request':
    print('yes')
# dbc = cantools.database.load_file("DBC/SX7H.dbc")
# # print(dbc.messages)
# sa_message = dbc.get_message_by_name('SA1')
# # print(sa_message)
# # pprint(sa_message.signals)
# frame = [0x00, 0x0A, 0x00, 0xF0, 0, 0, 0, 0]
# input_signal = dbc.decode_message(0x420, frame)
# part_str = str(input_signal['SA1_Status_ParkButtonReq'])
# pprint(part_str)
# if input_signal['SA1_Status_ParkButtonReq'] == 'No request':
#     print('yes')
data = sa_message.encode({
    'SA1_Status_PRNDL': 0,
    'SA1_Status_GearShftPosReq': 0,  #'Shifter position Zero',
    'SA1_Status_ParkButtonReq': 2,
    "SA1_ShifterManualSignal": 0,
    "SA1_ShifterModeSignal": 1,
    "SA1_Status_ShftSensSng_Fault": 0,
    "SA1_IND_ShifterMisUsd": 0,
    "SA1_Live_counter": 1,
    "SA1_Status_UnlockButtonReq": 1,
    "SA1_Status_EcoShifterModeReq": 0,
    "SA1_Status_RqGearPosInV": 0xf,
    "SA1_Status_ShiftPosValidFlag": 0,
})
# data = sa_message.encode({
#     'SA1_Status_PRNDL': 0,
#     'SA1_Status_GearShftPosReq': 0,  #'Shifter position Zero',
#     'SA1_Status_ParkButtonReq': 2,
#     "SA1_ShifterManualSignal": 0,
#     "SA1_ShifterModeSignal": 1,
#     "SA1_Status_ShftSensSng_Fault": 0,
#     "SA1_IND_ShifterMisUsd": 0,
#     "SA1_Live_counter": 1,
#     "SA1_Status_UnlockButtonReq": 1,
#     "SA1_Status_EcoShifterModeReq": 0,
#     "SA1_Status_RqGearPosInV": 0xf,
#     "SA1_Status_ShiftPosValidFlag": 0,
# })
# print(data)
# print(SA1_Status_ParkButtonReq_dic['No request'])
with open(r"./source bin/SX7H_Shifter.bin", 'rb') as fd:
    bin_file = fd.read()
    print(bin_file[0:20])
print('=====================================================')
hex_rd = Hex_read()
hex_rd.Open_file(r"./source bin/SX7H_Shifter.hex")
hex_file = hex_rd.data
print(hex_file[0:20])
aa = binascii.a2b_hex(hex_file)
print(aa[0:20])