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

pyxcp == 0.22.23 , shortUpload function often gets the Shortupload value as feedback from other messages, resulting in incorrect values returned #205

Open
XuHaobang opened this issue Jan 17, 2025 · 7 comments

Comments

@XuHaobang
Copy link

Image

Image

@christoph2 pyxcp == 0.22.23 , shortUpload function often gets the Shortupload value as feedback from other messages, resulting in incorrect values returned. Can I fix this? The version of pyxcp-0.21.11 I used before is OK, I hope you can help me, thank you very much ~

my pyxcp_conf.py is :
c = get_config() # noqa

c.Transport.Can.Vector.serial = 529423 #CAN serial

c.Transport.Can.poll_interval = 0.001
c.Transport.Can.Vector.serial = 32634 #CAN serial
c.Transport.layer = 'CAN'
c.Transport.Can.padding_value = 0xAA
c.Transport.Can.use_default_listener = True
c.Transport.create_daq_timestamps = False
c.Transport.Can.Vector.rx_queue_size = 16384
c.Transport.Can.can_id_broadcast = 256
c.Transport.Can.interface = 'vector'
c.Transport.Can.max_dlc_required = True
c.Transport.Can.use_default_listener = True
c.Transport.Can.can_id_master = 0x580 # Master CAN ID
c.Transport.Can.can_id_slave = 0x581 # Slave CAN ID
c.Transport.Can.channel = 0 # CAN channel (e.g., 0 for Kvaser channel 0)
c.Transport.Can.bitrate = 500000 # CAN bitrate
c.Transport.Can.fd = True # CAN bitrate
c.Transport.Can.receive_own_messages = True # CAN bitrate
c.Transport.Can.data_bitrate = 2000000 # CAN bitrate
c.Transport.Can.sjw_abr = 8 # CAN bitrate
c.Transport.Can.tseg1_abr = 31 # CAN bitrate
c.Transport.Can.tseg2_abr = 8 # CAN bitrate
c.Transport.Can.sjw_dbr = 8 # CAN bitrate
c.Transport.Can.tseg1_dbr = 31 # CAN bitrate
c.Transport.Can.tseg2_dbr = 8 # CAN bitrate

@christoph2
Copy link
Owner

The interesting thing here is the -1:
The variable in question Master.slaveProperties.maxCto is set after a CONNECT service and one can expect a reasonable value for MAX_CTO, like 8 on CAN classic, but it seems to be zero here. A correct value is vital for block transfer, DAQ allocation and other things.

Could you run xcp-info and look for maxCto?

{'addressGranularity': EnumIntegerString.new(0, 'BYTE'),
 'byteOrder': EnumIntegerString.new(0, 'INTEL'),
 'bytesPerElement': 1,
 'interleavedMode': False,
 'masterBlockMode': False,
 'maxBs': 255,
 'maxCto': 8,
 'maxDto': 8,
 'maxWriteDaqMultipleElements': 0,
 'minSt': 0,
 'optionalCommMode': True,
 'pgmProcessor': {},
 'protocolLayerVersion': 1,
 'queueSize': 0,
 'slaveBlockMode': True,
 'supportsCalpag': True,
 'supportsDaq': True,
 'supportsPgm': True,
 'supportsStim': False,
 'transportLayerVersion': 1,
 'transport_layer': 'CAN',
 'xcpDriverVersionNumber': 10}

And could you also put a print statement in your code?

print(x.slaveProperties)

@XuHaobang
Copy link
Author

The interesting thing here is the -1: The variable in question Master.slaveProperties.maxCto is set after a CONNECT service and one can expect a reasonable value for MAX_CTO, like 8 on CAN classic, but it seems to be zero here. A correct value is vital for block transfer, DAQ allocation and other things.

Could you run xcp-info and look for maxCto?

{'addressGranularity': EnumIntegerString.new(0, 'BYTE'),
'byteOrder': EnumIntegerString.new(0, 'INTEL'),
'bytesPerElement': 1,
'interleavedMode': False,
'masterBlockMode': False,
'maxBs': 255,
'maxCto': 8,
'maxDto': 8,
'maxWriteDaqMultipleElements': 0,
'minSt': 0,
'optionalCommMode': True,
'pgmProcessor': {},
'protocolLayerVersion': 1,
'queueSize': 0,
'slaveBlockMode': True,
'supportsCalpag': True,
'supportsDaq': True,
'supportsPgm': True,
'supportsStim': False,
'transportLayerVersion': 1,
'transport_layer': 'CAN',
'xcpDriverVersionNumber': 10}
And could you also put a print statement in your code?

print(x.slaveProperties)

@christoph2 when I try to print(x.slaveProperties) ,the result as below, can you tell me how to Work it out,thanks!
self.xm.slaveProperties = {'pgmProcessor': {}, 'transport_layer': 'CAN', 'byteOrder': EnumIntegerString.new(0, 'INTEL'), 'maxCto': 170, 'maxDto': 43690, 'supportsPgm': False, 'supportsStim': False, 'supportsDaq': False, 'supportsCalpag': False, 'slaveBlockMode': False, 'addressGranularity': EnumIntegerString.new(1, 'WORD'), 'protocolLayerVersion': 170, 'transportLayerVersion': 170, 'optionalCommMode': True, 'maxWriteDaqMultipleElements': 21, 'bytesPerElement': 2}

@XuHaobang
Copy link
Author

@christoph2 when I try to print(x.slaveProperties) ,the result as below, can you tell me how to Work it out,thanks!
self.xm.slaveProperties = {'pgmProcessor': {}, 'transport_layer': 'CAN', 'byteOrder': EnumIntegerString.new(0, 'INTEL'), 'maxCto': 170, 'maxDto': 43690, 'supportsPgm': False, 'supportsStim': False, 'supportsDaq': False, 'supportsCalpag': False, 'slaveBlockMode': False, 'addressGranularity': EnumIntegerString.new(1, 'WORD'), 'protocolLayerVersion': 170, 'transportLayerVersion': 170, 'optionalCommMode': True, 'maxWriteDaqMultipleElements': 21, 'bytesPerElement': 2}

@christoph2
Copy link
Owner

Well, looks really messed up!

maxCto should be 8 on CAN classic and max. 64 on CAN-FD -- interestingly the value 170 repeats (protocolLayerVersion, transportLayerVersion).
And xcp-info gives the same values?
If available, you may check the configuration file of your XCP slave.

@XuHaobang
Copy link
Author

XuHaobang commented Jan 21, 2025

Well, looks really messed up!

maxCto should be 8 on CAN classic and max. 64 on CAN-FD -- interestingly the value 170 repeats (protocolLayerVersion, transportLayerVersion). And xcp-info gives the same values? If available, you may check the configuration file of your XCP slave.

@christoph2 Hi thanks, when I run the XCP_info.py,Slave Properties as below, if my pyxcp_conf.py config is fault? my pyxcp_conf.py is below:

Image

Image

@christoph2
Copy link
Owner

OK, you may turn max_dlc_required to False, because padding is not expected to work under this conditions.
Also note: the paramter of shortUpload and similar functions is the number of elements, not bytes!
In your case the element-size (addressGranularity) is WORD, i.e. you need to divide your Characteristic_size_in_bytes by two.

@XuHaobang
Copy link
Author

@christoph2 when I turn max_dlc_required to False,Unfortunately, although no error was reported, the communication was abnormal. Xcp-info was incorrectly read from the beginning, which should be a bug, but I don't know where caused. I am currently using the old XCP version =pyxcp-0.21.11, and the parameters of xcp-info read out are all normal. max-cto = 8, and the value read by shortload is also correct. If you have conditions, you can test your latest version. It is really not possible. I think it is not the problem of the configuration file. They are all the same without any difference. I have checked them completely. If there is an environment on your side, you can Debug it.

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

No branches or pull requests

2 participants