Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For Motorola format in DBC, after use canmatrix.formats.loadp function to load, the start_bit are not right #829

Open
CXZ1988 opened this issue Jan 2, 2025 · 4 comments
Labels

Comments

@CXZ1988
Copy link

CXZ1988 commented Jan 2, 2025

Based on the Vector_DBC_File_Format_Documentation PDF, there is one point:
start_bit = unsigned_integer ;
The start_bit value specifies the position of the signal within the data field of the frame.
For signals with byte order Intel (little endian) the position of the least-significant bit is given.
For signals with byte order Motorola (big endian) the position of the most significant bit is given.

For Motorola format DBC, the start_bit value from the Class CanMatrix(after use canmatrix.formats.loadp to load one DBC) seems not right.

See below two comments for an example:

  • see in DBC the "SG_ BotBotPedlTrvlOutpDrvr : 15|12@0-...." the start_bit = 15,
  • while when use canmatrix.formats.loadp output is "Signal(name='BotBotPedlTrvlOutpDrvr', start_bit=8, size=12....", and the start_bit = 8
    don't know where this start_bit=8 come from(calculated or from the original DBC), but it is wrong per my understand.

Sorry that I just add two comments below for your references. 1st one can save as *.dbc and be opened. 2nd one is partly from canmatrix.formats.loadp function.

@CXZ1988
Copy link
Author

CXZ1988 commented Jan 2, 2025

VERSION ""

NS_ :
NS_DESC_
CM_
BA_DEF_
BA_
VAL_
CAT_DEF_
CAT_
FILTER
BA_DEF_DEF_
EV_DATA_
ENVVAR_DATA_
SGTYPE_
SGTYPE_VAL_
BA_DEF_SGTYPE_
BA_SGTYPE_
SIG_TYPE_REF_
VAL_TABLE_
SIG_GROUP_
SIG_VALTYPE_
SIGTYPE_VALTYPE_
BO_TX_BU_
BA_DEF_REL_
BA_REL_
BA_DEF_DEF_REL_
BU_SG_REL_
BU_EV_REL_
BU_BO_REL_
SG_MUL_VAL_

BS_:

BU_: Bot VCU EPS VDC VIU

BO_ 134 Bot_ExtBrkReq: 16 Bot
SG_ BotBotBrkPedlPrsd : 5|1@0+ (1,0) [0|1] "" VCU,VDC
SG_ BotBotBrkPedlPrsdVldy : 7|2@0+ (1,0) [0|3] "" VCU,VDC
SG_ BotBotPedlTrvlOutpDrvr : 15|12@0- (0.015625,-5) [-5|47] "mm" VCU,VDC
SG_ BotBotBrkPedlTrvlOutp : 19|12@0+ (0.015625,-5) [-5|47] "mm" VCU,VDC
SG_ BotBotBrkPedlTrvlOutpVldy : 33|2@0+ (1,0) [0|3] "" VCU,VDC
SG_ BotBotPedlTrvlOutpDrvrVldy : 35|2@0+ (1,0) [0|3] "" VCU,VDC
SG_ BotBotExtReqSts : 41|2@0+ (1,0) [0|3] "" VCU,VDC
SG_ BotBotExtReqPrioActv : 42|1@0+ (1,0) [0|1] "" VCU,VDC
SG_ Bot_ExtBrkReq_Cntr : 115|4@0+ (1,0) [0|15] "" VCU,VDC
SG_ Bot_ExtBrkReq_CRC : 127|8@0+ (1,0) [0|255] "" VCU,VDC

@CXZ1988
Copy link
Author

CXZ1988 commented Jan 2, 2025

{'': CanMatrix(type=<matrix_class.CAN: 1>, attributes={'DBName': 'VCU_Matrix'}, ecus=[Ecu(name='Bot', comment=None), Ecu(name='VCU', comment=None), Ecu(name='EPS', comment=None), Ecu(name='VDC', comment=None), Ecu(name='VIU', comment=None)], frames=[Frame(name='Bot_ExtBrkReq', arbitration_id=ArbitrationId(id=134, extended=False), size=16, transmitters=['Bot'], is_complex_multiplexed=False, is_fd=False, comment='å\x88¶å\x8a¨ç\x94¨ç\x94µå\xad\x90å\x8a©å\x8a\x9bæ³µå¤\x96é\x83¨å\x88¶å\x8a¨è¯·æ±\x82\nBot external brake request', signals=[Signal(name='BotBotBrkPedlPrsd', start_bit=2, size=1, is_little_endian=False, is_signed=False, offset=Decimal('0'), factor=Decimal('1'), unit='', receivers=['VCU', 'VDC'], comment='表å¾\x81驾驶å\x91\x98踩å\x88¶å\x8a¨è¸\x8fæ\x9d¿ç\x9a\x84ä¿¡å\x8f·\nSignal that corrVCUonds to the information if the driver is applying the brake pedal', multiplex=None, mux_value=None, is_float=False, is_ascii=False, type_label='', enumeration=None, comments={}, attributes={'GenSigStartValue': '0', 'GenSigSendType': 'Cyclic'}, values={0: 'False', 1: 'True'}, mux_val_grp=[], muxer_for_signal=None, calc_min_for_none=True, calc_max_for_none=True, cycle_time=0, initial_value=Decimal('0'), min=Decimal('0'), max=Decimal('1')), Signal(name='BotBotBrkPedlPrsdVldy', start_bit=0, size=2, is_little_endian=False, is_signed=False, offset=Decimal('0'), factor=Decimal('1'), unit='', receivers=['VCU', 'VDC'], comment='驾驶å\x91\x98å\x88¶å\x8a¨è¸\x8fæ\x9d¿ä¿¡å\x8f·æ\x9c\x89æ\x95\x88æ\x80§\nQualifier for sigEbbBrkPedlPrsd', multiplex=None, mux_value=None, is_float=False, is_ascii=False, type_label='', enumeration=None, comments={}, attributes={'GenSigStartValue': '0', 'GenSigSendType': 'Cyclic'}, values={0: 'Not initialized', 1: 'Normal', 2: 'Faulty', 3: 'Reserved'}, mux_val_grp=[], muxer_for_signal=None, calc_min_for_none=True, calc_max_for_none=True, cycle_time=0, initial_value=Decimal('0'), min=Decimal('0'), max=Decimal('3')), Signal(name='BotBotPedlTrvlOutpDrvr', start_bit=8, size=12, is_little_endian=False, is_signed=True, offset=Decimal('-5'), factor=Decimal('0.015625'), unit='mm', receivers=['VCU', 'VDC'], comment='表å¾\x81驾驶å\x91\x98å\x88¶å\x8a¨è¯·æ±\x82ç\x9a\x84æ\x8e¨æ\x9d\x86è¡\x8cç¨\x8b\nSignal that corrVCUonds to the driver brake request', multiplex=None, mux_value=None, is_float=False, is_ascii=False, type_label='', enumeration=None, comments={}, attributes={'GenSigStartValue': '0', 'GenSigSendType': 'Cyclic'}, values={4095: 'Init/Error'}, mux_val_grp=[], muxer_for_signal=None, calc_min_for_none=True, calc_max_for_none=True, cycle_time=0, initial_value=Decimal('-5.000000'), min=Decimal('-5'), max=Decimal('47')), Signal(name='BotBotBrkPedlTrvlOutp', start_bit=20, size=12, is_little_endian=False, is_signed=False, offset=Decimal('-5'), factor=Decimal('0.015625'), unit='mm', receivers=['VCU', 'VDC'], comment='表å¾\x81å®\x9eé\x99\x85æ\x8e¨å\x8a¨æ¶²å\x8e\x8bæµ\x81é\x87\x8fç\x9a\x84æ\x8e¨æ\x9d\x86è¡\x8cç¨\x8b\nSignal that represents the actual shifted hydraulic volume', multiplex=None, mux_value=None, is_float=False, is_ascii=False, type_label='', enumeration=None, comments={}, attributes={'GenSigStartValue': '0', 'GenSigSendType': 'Cyclic'}, values={4095: 'Init/Error'}, mux_val_grp=[], muxer_for_signal=None, calc_min_for_none=True, calc_max_for_none=True, cycle_time=0, initial_value=Decimal('-5.000000'), min=Decimal('-5'), max=Decimal('47')), Signal(name='BotBotBrkPedlTrvlOutpVldy', start_bit=38, size=2, is_little_endian=False, is_signed=False, offset=Decimal('0'), factor=Decimal('1'), unit='', receivers=['VCU', 'VDC'], comment='EbbBrkPedlTrvlOutpä¿¡å\x8f·æ\x9c\x89æ\x95\x88æ\x80§\nQualifier for sigEbbBrkPedlTrvlOutp', multiplex=None, mux_value=None, is_float=False, is_ascii=False, type_label='', enumeration=None, comments={}, attributes={'GenSigStartValue': '0', 'GenSigSendType': 'Cyclic'}, values={0: 'Not initialized', 1: 'Normal', 2: 'Faulty', 3: 'Reserved'}, mux_val_grp=[], muxer_for_signal=None, calc_min_for_none=True, calc_max_for_none=True, cycle_time=0, initial_value=Decimal('0'), min=Decimal('0'), max=Decimal('3')), Signal(name='BotBotPedlTrvlOutpDrvrVldy', start_bit=36, size=2, is_little_endian=False, is_signed=False, offset=Decimal('0'), factor=Decimal('1'), unit='', receivers=['VCU', 'VDC'], comment='EbbBrkPedlTrvlOutpDrvrä¿¡å\x8f·æ\x9c\x89æ\x95\x88æ\x80§\nQualifier for sigEbbBrkPedlTrvlOutpDrvr', multiplex=None, mux_value=None, is_float=False, is_ascii=False, type_label='', enumeration=None, comments={}, attributes={'GenSigStartValue': '0', 'GenSigSendType': 'Cyclic'}, values={0: 'Not initialized', 1: 'Normal', 2: 'Faulty', 3: 'Reserved'}, mux_val_grp=[], muxer_for_signal=None, calc_min_for_none=True, calc_max_for_none=True, cycle_time=0, initial_value=Decimal('0'), min=Decimal('0'), max=Decimal('3')), Signal(name='BotBotExtReqSts', start_bit=46, size=2, is_little_endian=False, is_signed=False, offset=Decimal('0'), factor=Decimal('1'), unit='', receivers=['VCU', 'VDC'], comment='eBoosterå¤\x96é\x83¨å\x88¶å\x8a¨è¯·æ±\x82å\x8a\x9fè\x83½ç\x8a¶æ\x80\x81\nSignal to indicate that an external brake request can be executed by the eBooster', multiplex=None, mux_value=None, is_float=False, is_ascii=False, type_label='', enumeration=None, comments={}, attributes={'GenSigStartValue': '0', 'GenSigSendType': 'Cyclic'}, values={0: 'Not initialized', 1: 'Not available', 2: 'Available', 3: 'Reserved'}, mux_val_grp=[], muxer_for_signal=None, calc_min_for_none=True, calc_max_for_none=True, cycle_time=0, initial_value=Decimal('0'),

@CXZ1988 CXZ1988 changed the title For Motorola format in DBC, after use ccanmatrix.formats.loadp function to load, the start_bit are not right For Motorola format in DBC, after use canmatrix.formats.loadp function to load, the start_bit are not right Jan 2, 2025
@ebroecker
Copy link
Owner

Hi @CXZ1988 ,

the motorola startbit is arbitrariness of candb++.
canmatrix writes the correct startbit to dbc but uses an other (for our point of view more logical) internal representation.
Exporting to dbc will write the startbit as dbc expects it.

I just discussed it here: #821

to get the same startbit as candb++ shows you (with default settings) just use get_startbit(True,True) method of the signal object.

there is also information about byte-order and starbits here:
https://github.com/ebroecker/canmatrix/wiki/signal-Byteorder

@CXZ1988
Copy link
Author

CXZ1988 commented Jan 3, 2025

Hello @ebroecker ,
Thanks very much for your feedback. It is clear from my side now. Have a nice day.🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants