The pid(ProductCode) is forcibly modified to 7FFFFFFF

More
27 Jul 2022 09:10 #248397 by shaying526
I have two servo drivers, JMC and i7, which can operate normally on TwinCAT, but in the linuxcnc+ethernet system I built, only JMC can operate normally.

I checked the debugging information(/var/log/syslog) of their runtime and found some problems

1. They use the same XML, ini, Hal files, just vid and pid are different
2. By checking the debugging information, the pid(ProductCode) of JMC is the same as what I set, but i7 is different from what I set

JMC XML files(part):
<slave idx="0" type="generic" vid="66668888" pid="20199307" configPdos="true">

JMC, Use the command line to confirm that the ID is correct
#ethercat slave -v
=== Master 0, Slave 0 ===
Device: Main
State: PREOP
Flag: +
Identity:
  Vendor Id:       0x66668888
  Product code:    0x20199307
  Revision number: 0x20190430
  Serial number:   0x00000000
......


JMC debug information(/var/log/syslog):
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941178] EtherCAT: Requesting master 0...
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941193] EtherCAT DEBUG 0: IDLE -> OPERATION.
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941202] EtherCAT: Successfully requested master 0.
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941212] EtherCAT DEBUG 0: ecrt_master_create_domain(master = 0x72977351)
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941220] EtherCAT DEBUG 0: Created domain 0.
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941230] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0x72977351, alias = 0, position = 0, vendor_id = 0x66668888, product_code = 0x20199307)
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941238] EtherCAT DEBUG 0: Creating slave configuration for 0:0, 0x66668888/0x20199307.

Jul 27 14:41:40 linuxcnc kernel: [ 1478.941246] EtherCAT DEBUG 0 0:0: Attached slave 0.
Jul 27 14:41:40 linuxcnc kernel: [ 1478.941383] EtherCAT DEBUG 0 0:0: ecrt_slave_config_dc(sc = 0x3fa55593, assign_activate = 0x0300, sync0_cycle = 1000000, sync0_shift = 0, sync1_cycle = 0, sync1_shift = 0

i7 XML files(part):
<slave idx="0" type="generic" vid="00000088" pid="88710000" configPdos="true">

i7, Use the command line to confirm that the ID is correct
#ethercat slave -v
=== Master 0, Slave 0 ===
Device: Main
State: PREOP
Flag: +
Identity:
  Vendor Id:       0x00000088
  Product code:    0x88710000
  Revision number: 0x00000001
  Serial number:   0x00000000
......

i7 debug information(/var/log/syslog):
Jul 27 14:27:49 linuxcnc kernel: [  648.027759] EtherCAT: Requesting master 0...
Jul 27 14:27:49 linuxcnc kernel: [  648.027771] EtherCAT DEBUG 0: IDLE -> OPERATION.
Jul 27 14:27:49 linuxcnc kernel: [  648.027780] EtherCAT: Successfully requested master 0.
Jul 27 14:27:49 linuxcnc kernel: [  648.027789] EtherCAT DEBUG 0: ecrt_master_create_domain(master = 0x72977351)
Jul 27 14:27:49 linuxcnc kernel: [  648.027796] EtherCAT DEBUG 0: Created domain 0.
Jul 27 14:27:49 linuxcnc kernel: [  648.027806] EtherCAT DEBUG 0: ecrt_master_slave_config(master = 0x72977351, alias = 0, position = 0, vendor_id = 0x00000088, product_code = 0x7fffffff)
Jul 27 14:27:49 linuxcnc kernel: [  648.027813] EtherCAT DEBUG 0: Creating slave configuration for 0:0, 0x00000088/0x7FFFFFFF.
Jul 27 14:27:49 linuxcnc kernel: [  648.027823] EtherCAT DEBUG 0 0:0: Slave 0 has no matching product code (0x88710000) for configuration (0x7FFFFFFF).

Jul 27 14:27:49 linuxcnc kernel: [  648.027842] EtherCAT DEBUG 0 0:0: ecrt_slave_config_sdo(sc = 0x4862868e, index = 0x6060, subindex = 0x00, data = 0xb498ab28, size = 1)
Jul 27 14:27:49 linuxcnc kernel: [  648.027854] EtherCAT DEBUG 0 0:0: ecrt_slave_config_sdo(sc = 0x4862868e, index = 0x6098, subindex = 0x00, data = 0xb498ab28, size = 1)


The pid(ProductCode) of JMC is the same as what I set, but i7 is different from what I set.
The pid(ProductCode) of i7 is 0x88710000, which is greater than 0x7FFFFFFF.
I suspect that the maximum value is limited in the code somewhere. The pid(ProductCode) greater than 0x7FFFFFFF will be changed back to 0x7FFFFFFF.

I want my i7 servo driver to run. What should I do next? 

Please Log in or Create an account to join the conversation.

More
27 Jul 2022 11:48 #248409 by db1981
this is strange.
I have checked the whole lcec code about that, all pids are uint32_t , so this should be no problem.
Maybe the bug is on the etherlab side, i will inform sascha about that.

Please Log in or Create an account to join the conversation.

More
01 Aug 2022 03:12 #248767 by shaying526
Thank you for your reply, Problem solved!
In the “linux-ethercat” open source code, the function of parsing XML file vid and pid uses the wrong string conversion function strtol().

lcec_conf.c line632 and line638

p->vid = strtol(val, NULL, 16);

p->pid = strtol(val, NULL, 16);

Change strtol() to strtoul()
I have modified the parsing of vid and pid, and other places remain unchanged for the time being.

The function strtol() is used in the following places through source insight search.
---- strtol Matches (11 in 3 files) ----
linuxcnc-ethercat.SearchResults (D:\Project\59_cnc\01_code\linuxcnc-ethercat-master\00_si\linuxcnc-ethercat.si4project) line 1 : ---- strtol Matches (#count#) ----
parseSlaveAttrs in lcec_conf.c (src) : p->vid = strtol(val, NULL, 16);
parseSlaveAttrs in lcec_conf.c (src) : p->pid = strtol(val, NULL, 16);
parseDcConfAttrs in lcec_conf.c (src) : p->assignActivate = strtol(val, NULL, 16);
parseSdoConfigAttrs in lcec_conf.c (src) : tmp = strtol(val, NULL, 16);
parseSdoConfigAttrs in lcec_conf.c (src) : tmp = strtol(val, NULL, 16);
parsePdoAttrs in lcec_conf.c (src) : tmp = strtol(val, NULL, 16);
parsePdoEntryAttrs in lcec_conf.c (src) : tmp = strtol(val, NULL, 16);
parsePdoEntryAttrs in lcec_conf.c (src) : tmp = strtol(val, NULL, 16);
parseModParamAttrs in lcec_conf.c (src) : p->value.s32 = strtol(pval, &s, 0);
parse_int in lcec_conf_icmds.c (src) : ret = strtol(buf, &end, 0);

After modification, recompile and install the “linux-ethercat”
#sudo make clean
#make configure
#make
#sudo make install
The following user(s) said Thank You: arvidb

Please Log in or Create an account to join the conversation.

More
01 Aug 2022 09:12 #248779 by db1981
good work !!

I overlooked the parser.

Please Log in or Create an account to join the conversation.

Time to create page: 0.067 seconds
Powered by Kunena Forum