STECHOQ / etherlab-nodejs

Bind etherlab process into nodejs
GNU Lesser General Public License v2.1
1 stars 1 forks source link

~~libethercat.so.1 not found~~ `Segmentation fault` caused by `slaves.json` #1

Closed alex-controlx closed 2 years ago

alex-controlx commented 2 years ago

Trying to run the example and getting an error:

/home/pi/ethercat_node/node_modules/bindings/bindings.js:121
        throw e;
        ^

Error: libethercat.so.1: cannot open shared object file: No such file or directory

checked the file exists in /usr/local/lib/

any ideas how to solve?

alex-controlx commented 2 years ago

Hmm, magically fixed. Done nothing, just was looking through bindings.js.

However, now I have the Segmentation fault:

PID 1842 received SIGSEGV for address: 0xb632fce9
/home/pi/ethercat_node/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x2574)[0xb6342574]
/lib/arm-linux-gnueabihf/libc.so.6(__default_rt_sa_restorer+0x0)[0xb6b90db0]
Segmentation fault

any ideas on this one?

iqrok commented 2 years ago

Trying to run the example and getting an error:

/home/pi/ethercat_node/node_modules/bindings/bindings.js:121
        throw e;
        ^

Error: libethercat.so.1: cannot open shared object file: No such file or directory

checked the file exists in /usr/local/lib/

any ideas how to solve?

my wild guess is the symlink was broken, but I have no idea how it magically got fixed. How did you install the etherlab?

as for the segmentation fault, I've never tried on raspi. Mostly, I use x86 platforms. But I ran this lib successfully on Beckhoff CX9020, which uses armhf processor. I'll chek it once I got raspi in my hand.

iqrok commented 2 years ago

So, I tried it in raspi 4b,

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.10.63-v8+ #1459 SMP PREEMPT Wed Oct 6 16:42:49 BST 2021 aarch64 GNU/Linux
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
pi@raspberrypi:~ $ node -v
v14.18.2

and I couldn't reproduce the error.

I think the problem is on how etherlab is installed. In arm platforms, you need to disable cycles when executing ./configure.

also, I use dkms to install etherlab from icshwi/etherlabmaster

alex-controlx commented 2 years ago

Not sure either how it got fixed. I think you are right and something was wrong with the symlink.

To install EtherCAT I used Etherlab at GitLab with one modification ./configure --disable-8139too and used the kernels from RPi-Distro/rpi-source

I'll try to rebuild it and use echo "ENABLE_CYCLES = NO" > configure/CONFIG_OPTIONS.local this weekend.

alex-controlx commented 2 years ago

I guess it's not relevant to this package, but I'm having issues installing suggested etherlab from icshwi/etherlabmaster

Have you had this issue before: https://github.com/icshwi/etherlabmaster/issues/13

iqrok commented 2 years ago

I think I know why make dkms_build throws error. icshwi/etherlabmaster uses etherlab source from sourceforge, AFAIK, it only supports kernel version up to 4.19 only. So, either downgrade your kernel to 4.19 or use etherlab from current official source at gitlab.

May I know what raspi you're using?

Also, I made some script at https://gitlab.com/iqrok/etherlab-dkms/-/tree/arm to make installation easier for me, perhaps you can try it. To use it, just execute sudo ./prepare.sh

alex-controlx commented 2 years ago

Thanks for the suggestion. I'll try using Etherlab from the official source at gitlab. But first I'll try your script when I'll get to office tomorrow morning.

I'm using: Raspberry Pi 4 Model B 4GB

Linux raspberrypi 5.10.63-v7l+ #1459 SMP Wed Oct 6 16:41:57 BST 2021 armv7l GNU/Linux

Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye
alex-controlx commented 2 years ago

Your script helped 🙌 to understand, I didn't run it, I manually removed the etherlabmaster-code and ran git clone https://gitlab.com/etherlab.org/ethercat.git etherlabmaster-code. It went without error on make dkms_build.

However I'm still getting the Segmentation fault when run node main.js. My NodeJs is

pi@raspberrypi:~/nodejs_ethercat $ node -v
v14.18.2

I used npm install etherlab-nodejs to get and build your package.

My main.js is exact code as per the example in README.MD with modified slaves.json to read my one slave connected.

iqrok commented 2 years ago

I tried to test with raspi. The connected slaves and the result look like this

pi@raspberrypi:~/Documents/ethercat-nodejs $ ethercat slaves 
0  0:0  PREOP  +  EK1100 EtherCAT-Koppler (2A E-Bus)
1  0:1  PREOP  +  EL6224 (IO Link Master)
2  0:2  PREOP  +  EL2004 4K. Dig. Ausgang 24V, 0.5A

pi@raspberrypi:~/Documents/ethercat-nodejs $ node main.js 

Using priority 99
sched_setscheduler failed: Operation not permitted
master's current state  2
master's current state  8
ready
[
    { position: 1, index: 24576, subindex: 1, value: 0 },
    { position: 1, index: 61696, subindex: 1, value: 160 },
    { position: 1, index: 61697, subindex: 13, value: 0 },
    { position: 1, index: 61697, subindex: 16, value: 1 },
    { position: 2, index: 28672, subindex: 1, value: 0 },
    { position: 2, index: 28688, subindex: 1, value: 0 },
    { position: 2, index: 28704, subindex: 1, value: 0 },
    { position: 2, index: 28720, subindex: 1, value: 0 }
]

...

tbh, I only have access to beckhoff and festo slave devices to test.

May I know what is the output of ethercat slaves -v? Also, can you post the content of your slaves.json?

alex-controlx commented 2 years ago

Below my outputs:

pi@raspberrypi:~/nodejs_ethercat $ ethercat slaves
0  0:0  PREOP  +  MotionLinx-Ai PLCmode

pi@raspberrypi:~/nodejs_ethercat $ ethercat slaves -v
=== Master 0, Slave 0 ===
Device: Main
State: PREOP
Flag: +
Identity:
  Vendor Id:       0x00000049
  Product code:    0x00000491
  Revision number: 0x00000001
  Serial number:   0x00000000
DL information:
  FMMU bit operation: no
  Distributed clocks: yes, 64 bit
  DC system time transmission delay: 0 ns
Port  Type  Link  Loop    Signal  NextSlave  RxTime [ns]  Diff [ns]   NextDc [ns]
   0  MII   up    open    yes             -    833946602           0           0
   1  MII   down  closed  no              -            -           -           -
   2  N/C   down  closed  no              -            -           -           -
   3  N/A   down  closed  no              -            -           -           -
Mailboxes:
  Bootstrap RX: 0x1000/128, TX: 0x1100/128
  Standard  RX: 0x1000/128, TX: 0x1080/128
  Supported protocols: CoE, FoE
General:
  Group: IndSoft Slaves
  Image name: 
  Order number: MotionLinx-Ai PLCmode
  Device name: MotionLinx-Ai PLCmode
  CoE details:
    Enable SDO: yes
    Enable SDO Info: yes
    Enable PDO Assign: no
    Enable PDO Configuration: no
    Enable Upload at startup: no
    Enable SDO complete access: yes
  Flags:
    Enable SafeOp: no
    Enable notLRW: no
  Current consumption: 0 mA

I'm not too sure if I have to list all syncs in slaves.json and I just added a few for testing, perhaps it causes the problem:

[
  {
    "alias":0,
    "position":0,
    "vendor_id":"0x49",
    "product_code":"0x00000491",
    "syncs":[
      {
        "index":5001,
        "watchdog_enabled":false,
        "pdos":[
          {
            "index":"0x1a00",
            "name": "Module Inputs",
            "entries":[
              {
                "index":"0x3001",
                "name": "ServoStateL",
                "subindex":"0x02",
                "size":8,
                "add_to_domain":true,
                "swap_endian":false,
                "signed":false
              }
            ]
          }
        ]
      }
    ]
  }
]
iqrok commented 2 years ago

I'm not too sure if I have to list all syncs in slaves.json and I just added a few for testing, perhaps it causes the problem:

you have to add all syncs into slaves.json, but it shouldn't be the cause of segmentation fault. If syncs manager configuration is wrong, usually the slave simply refuses to go OP.

I'm curious about this part

    "syncs":[
      {
        "index":5001,
        "watchdog_enabled":false,
        "pdos":[
          {
            "index":"0x1a00",
            "name": "Module Inputs",
            "entries":[
              {
                "index":"0x3001",
                "name": "ServoStateL",
                "subindex":"0x02",
                "size":8,
                "add_to_domain":true,
                "swap_endian":false,
                "signed":false
              }
            ]
          }
        ]
      }
    ]

the index inside syncs array should be 0 - 3. The index simply refers to which sync manager will be configured, whether it's SM0, SM1, SM2, or SM3. Usually, I run ethercat pdos or ethercat cstruct to know whether the slave already has PDOs mapped into sync manager or not, then I just translate the output into slaves.json.

as for segmentation fault, I believe the cause is because I hardcoded the sync index (0,1,2,3) into an array. But because the value is 5001, then it tries to array index outside the range, hence segmentation fault happens.

alex-controlx commented 2 years ago

Thank you for helping me. It is probably out of topic, but how do I construct the slaves.json from the below:

pi@raspberrypi:~ $ ethercat cstruct
/* Master 0, Slave 0, "MotionLinx-Ai PLCmode"
 * Vendor ID:       0x00000049
 * Product code:    0x00000491
 * Revision number: 0x00000001
 */

ec_pdo_entry_info_t slave_0_pdo_entries[] = {
    {0x2000, 0x00, 8}, /* MDRCtrlLeft */
    {0x200c, 0x00, 8}, /* MDRCtrlRight */
    {0x2001, 0x00, 16}, /* SpeedLeft */
    {0x2002, 0x00, 16}, /* SpeedRight */
    {0x200f, 0x00, 8}, /* BrakeModeLeft */
    {0x2010, 0x00, 8}, /* BrakeModeRight */
    {0x2003, 0x00, 16}, /* AccelLeft */
    {0x2004, 0x00, 16}, /* DecelLeft */
    {0x2005, 0x00, 16}, /* AccelRight */
    {0x2006, 0x00, 16}, /* DecelRight */
    {0x2007, 0x00, 16}, /* ServoControl */
    {0x2008, 0x00, 16}, /* Set_ServoLeft */
    {0x2009, 0x00, 16}, /* Set_ServoRight */
    {0x2011, 0x00, 8}, /* WritePin2Output */
    {0x2012, 0x00, 8}, /* ClearMotorError */
    {0x3000, 0x00, 16}, /* AllSensors */
    {0x3001, 0x00, 8}, /* ServoStateLeft */
    {0x3006, 0x00, 8}, /* ServoStateRight */
    {0x3002, 0x00, 16}, /* ServoPositionLeft */
    {0x3003, 0x00, 16}, /* ServoPositionRight */
    {0x3004, 0x00, 16}, /* DiagnosticLeft */
    {0x3005, 0x00, 16}, /* DiagnosticRight */
    {0x3013, 0x00, 8}, /* SystemDiagnostic */
    {0x3014, 0x00, 8}, /* Reserved1 */
    {0x3015, 0x00, 16}, /* Reserved2 */
};

ec_pdo_info_t slave_0_pdos[] = {
    {0x1600, 6, slave_0_pdo_entries + 0}, /* RxPDO-Map0 */
    {0x1601, 4, slave_0_pdo_entries + 6}, /* RxPDO-Map1 */
    {0x1602, 5, slave_0_pdo_entries + 10}, /* RxPDO-Map2 */
    {0x1a00, 5, slave_0_pdo_entries + 15}, /* TxPDO-Map0 */
    {0x1a01, 5, slave_0_pdo_entries + 20}, /* TxPDO-Map1 */
};

ec_sync_info_t slave_0_syncs[] = {
    {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
    {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
    {2, EC_DIR_OUTPUT, 3, slave_0_pdos + 0, EC_WD_ENABLE},
    {3, EC_DIR_INPUT, 2, slave_0_pdos + 3, EC_WD_DISABLE},
    {0xff}
};

pi@raspberrypi:~ $ ethercat pdos
SM0: PhysAddr 0x1000, DefaultSize  128, ControlRegister 0x26, Enable 1
SM1: PhysAddr 0x1080, DefaultSize  128, ControlRegister 0x22, Enable 1
SM2: PhysAddr 0x1100, DefaultSize   24, ControlRegister 0x64, Enable 1
  RxPDO 0x1600 "RxPDO-Map0"
    PDO entry 0x2000:00,  8 bit, "MDRCtrlLeft"
    PDO entry 0x200c:00,  8 bit, "MDRCtrlRight"
    PDO entry 0x2001:00, 16 bit, "SpeedLeft"
    PDO entry 0x2002:00, 16 bit, "SpeedRight"
    PDO entry 0x200f:00,  8 bit, "BrakeModeLeft"
    PDO entry 0x2010:00,  8 bit, "BrakeModeRight"
  RxPDO 0x1601 "RxPDO-Map1"
    PDO entry 0x2003:00, 16 bit, "AccelLeft"
    PDO entry 0x2004:00, 16 bit, "DecelLeft"
    PDO entry 0x2005:00, 16 bit, "AccelRight"
    PDO entry 0x2006:00, 16 bit, "DecelRight"
  RxPDO 0x1602 "RxPDO-Map2"
    PDO entry 0x2007:00, 16 bit, "ServoControl"
    PDO entry 0x2008:00, 16 bit, "Set_ServoLeft"
    PDO entry 0x2009:00, 16 bit, "Set_ServoRight"
    PDO entry 0x2011:00,  8 bit, "WritePin2Output"
    PDO entry 0x2012:00,  8 bit, "ClearMotorError"
SM3: PhysAddr 0x1400, DefaultSize   16, ControlRegister 0x20, Enable 1
  TxPDO 0x1a00 "TxPDO-Map0"
    PDO entry 0x3000:00, 16 bit, "AllSensors"
    PDO entry 0x3001:00,  8 bit, "ServoStateLeft"
    PDO entry 0x3006:00,  8 bit, "ServoStateRight"
    PDO entry 0x3002:00, 16 bit, "ServoPositionLeft"
    PDO entry 0x3003:00, 16 bit, "ServoPositionRight"
  TxPDO 0x1a01 "TxPDO-Map1"
    PDO entry 0x3004:00, 16 bit, "DiagnosticLeft"
    PDO entry 0x3005:00, 16 bit, "DiagnosticRight"
    PDO entry 0x3013:00,  8 bit, "SystemDiagnostic"
    PDO entry 0x3014:00,  8 bit, "Reserved1"
    PDO entry 0x3015:00, 16 bit, "Reserved2"
iqrok commented 2 years ago

sorry, may I see the output of ethercat sdos too?

iqrok commented 2 years ago

from the output from ethercat cstruct above, slaves.json probably looks like this

[
  {
    "alias": 0,
    "position": 0,
    "vendor_id": "0x00000049",
    "product_code": "0x00000491",

    "syncs": [
      {
        "index": 2,
        "watchdog_enabled": true,
        "pdos": [
          {
            "index": "0x1600",
            "entries": [
              {
                "index": "0x2000",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x200c",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2001",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2002",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x200f",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2010",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              }
            ]
          },
          {
            "index": "0x1601",
            "entries": [
              {
                "index": "0x2003",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2004",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2005",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2006",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              }
            ]
          },
          {
            "index": "0x1602",
            "entries": [
              {
                "index": "0x2007",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2008",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2009",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2011",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x2012",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              }
            ]
          }
        ]
      },

      {
        "index": 3,
        "watchdog_enabled": false,
        "pdos": [
          {
            "index": "0x1a00",
            "entries": [
              {
                "index": "0x3000",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3001",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3006",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3002",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3003",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              }
            ]
          },

          {
            "index": "0x1a01",
            "entries": [
              {
                "index": "0x3004",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3005",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3013",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3014",
                "subindex": "0x00",
                "size": 8,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              },
              {
                "index": "0x3015",
                "subindex": "0x00",
                "size": 16,

                "add_to_domain": true,
                "swap_endian": false,
                "signed": false
              }
            ]
          }
        ]
      }
    ]
  }
]
alex-controlx commented 2 years ago

Output of ethercat sdos

pi@raspberrypi:~ $ ethercat sdos
SDO 0x1000, "Device type"
  0x1000:00, r-r-r-, uint32, 32 bit, "Device type"
SDO 0x1001, "Error register"
  0x1001:00, r-r-r-, uint8, 8 bit, "Error register"
SDO 0x1008, "Device name"
  0x1008:00, r-r-r-, string, 168 bit, "Device name"
SDO 0x1009, "Hardware version"
  0x1009:00, r-r-r-, string, 24 bit, "Hardware version"
SDO 0x100a, "Software version"
  0x100a:00, r-r-r-, string, 24 bit, "Software version"
SDO 0x1018, "Identity"
  0x1018:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1018:01, r-r-r-, uint32, 32 bit, "Vendor ID"
  0x1018:02, r-r-r-, uint32, 32 bit, "Product code"
  0x1018:03, r-r-r-, uint32, 32 bit, "Revision"
  0x1018:04, r-r-r-, uint32, 32 bit, "Serial number"
SDO 0x10f1, "Error Settings"
  0x10f1:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x10f1:01, rwrwrw, uint32, 32 bit, "Local Error Reaction"
  0x10f1:02, rwrwrw, uint16, 16 bit, "Sync Error Counter Limit"
SDO 0x1600, "RxPDO-Map0"
  0x1600:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1600:01, r-r-r-, uint32, 32 bit, "MDRCtrl Left"
  0x1600:02, r-r-r-, uint32, 32 bit, "MDRCtrl Right"
  0x1600:03, r-r-r-, uint32, 32 bit, "Speed Left MDR"
  0x1600:04, r-r-r-, uint32, 32 bit, "Speed Right MDR"
  0x1600:05, r-r-r-, uint32, 32 bit, "BrakeMode Left"
  0x1600:06, r-r-r-, uint32, 32 bit, "BrakeMode Right"
SDO 0x1601, "RxPDO-Map1"
  0x1601:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1601:01, r-r-r-, uint32, 32 bit, "Accel Left MDR"
  0x1601:02, r-r-r-, uint32, 32 bit, "Decel Left MDR"
  0x1601:03, r-r-r-, uint32, 32 bit, "Accel Right MDR"
  0x1601:04, r-r-r-, uint32, 32 bit, "Decel Right MDR"
SDO 0x1602, "RxPDO-Map2"
  0x1602:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1602:01, r-r-r-, uint32, 32 bit, "Servo Control"
  0x1602:02, r-r-r-, uint32, 32 bit, "Left MDR Set Servo"
  0x1602:03, r-r-r-, uint32, 32 bit, "Right MDR Set Servo"
  0x1602:04, r-r-r-, uint32, 32 bit, "Write Pin2 Output"
  0x1602:05, r-r-r-, uint32, 32 bit, "Clear Motor Error"
SDO 0x1a00, "TxPDO-Map0"
  0x1a00:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1a00:01, r-r-r-, uint32, 32 bit, "All Sensors"
  0x1a00:02, r-r-r-, uint32, 32 bit, "ServoState Left"
  0x1a00:03, r-r-r-, uint32, 32 bit, "ServoState Right"
  0x1a00:04, r-r-r-, uint32, 32 bit, "Servo Position Left"
  0x1a00:05, r-r-r-, uint32, 32 bit, "Servo Position Right"
SDO 0x1a01, "TxPDO-Map1"
  0x1a01:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1a01:01, r-r-r-, uint32, 32 bit, "Diagnostic Left"
  0x1a01:02, r-r-r-, uint32, 32 bit, "Diagnostic Right"
  0x1a01:03, r-r-r-, uint32, 32 bit, "System Diagnostic"
  0x1a01:04, r-r-r-, uint32, 32 bit, "Reserved1"
  0x1a01:05, r-r-r-, uint32, 32 bit, "Reserved2"
SDO 0x1c00, "Sync manager type"
  0x1c00:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1c00:01, r-r-r-, uint8, 8 bit, "SubIndex 001"
  0x1c00:02, r-r-r-, uint8, 8 bit, "SubIndex 002"
  0x1c00:03, r-r-r-, uint8, 8 bit, "SubIndex 003"
  0x1c00:04, r-r-r-, uint8, 8 bit, "SubIndex 004"
SDO 0x1c12, "RxPDO assign"
  0x1c12:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1c12:01, r-r-r-, uint16, 16 bit, "SubIndex 001"
  0x1c12:02, r-r-r-, uint16, 16 bit, "SubIndex 002"
  0x1c12:03, r-r-r-, uint16, 16 bit, "SubIndex 003"
SDO 0x1c13, "TxPDO assign"
  0x1c13:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1c13:01, r-r-r-, uint16, 16 bit, "SubIndex 001"
  0x1c13:02, r-r-r-, uint16, 16 bit, "SubIndex 002"
SDO 0x1c32, "SM output parameter"
  0x1c32:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1c32:01, rwr-r-, uint16, 16 bit, "Synchronization Type"
  0x1c32:02, r-r-r-, uint32, 32 bit, "Cycle Time"
  0x1c32:03, ------, type 0000, 32 bit, "SubIndex 003"
  0x1c32:04, r-r-r-, uint16, 16 bit, "Synchronization Types supported"
  0x1c32:05, r-r-r-, uint32, 32 bit, "Minimum Cycle Time"
  0x1c32:06, r-r-r-, uint32, 32 bit, "Calc and Copy Time"
  0x1c32:07, ------, type 0000, 32 bit, "SubIndex 007"
  0x1c32:08, rwrwrw, uint16, 16 bit, "Get Cycle Time"
  0x1c32:09, r-r-r-, uint32, 32 bit, "Delay Time"
  0x1c32:0a, rwrwrw, uint32, 32 bit, "Sync0 Cycle Time"
  0x1c32:0b, r-r-r-, uint16, 16 bit, "SM-Event Missed"
  0x1c32:0c, r-r-r-, uint16, 16 bit, "Cycle Time Too Small"
  0x1c32:0d, ------, type 0000, 16 bit, "Shift Time Too Short"
  0x1c32:0e, ------, type 0000, 16 bit, "SubIndex 014"
  0x1c32:0f, ------, type 0000, 32 bit, "SubIndex 015"
  0x1c32:10, ------, type 0000, 32 bit, "SubIndex 016"
  0x1c32:11, ------, type 0000, 32 bit, "SubIndex 017"
  0x1c32:12, ------, type 0000, 32 bit, "SubIndex 018"
  0x1c32:13, ------, type 0000, 0 bit, "SubIndex 019"
  0x1c32:14, ------, type 0000, 0 bit, "SubIndex 020"
  0x1c32:15, ------, type 0000, 0 bit, "SubIndex 021"
  0x1c32:16, ------, type 0000, 0 bit, "SubIndex 022"
  0x1c32:17, ------, type 0000, 0 bit, "SubIndex 023"
  0x1c32:18, ------, type 0000, 0 bit, "SubIndex 024"
  0x1c32:19, ------, type 0000, 0 bit, "SubIndex 025"
  0x1c32:1a, ------, type 0000, 0 bit, "SubIndex 026"
  0x1c32:1b, ------, type 0000, 0 bit, "SubIndex 027"
  0x1c32:1c, ------, type 0000, 0 bit, "SubIndex 028"
  0x1c32:1d, ------, type 0000, 0 bit, "SubIndex 029"
  0x1c32:1e, ------, type 0000, 0 bit, "SubIndex 030"
  0x1c32:1f, ------, type 0000, 0 bit, "SubIndex 031"
  0x1c32:20, r-r-r-, bool, 1 bit, "Sync Error"
SDO 0x1c33, "SM input parameter"
  0x1c33:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x1c33:01, rwr-r-, uint16, 16 bit, "Synchronization Type"
  0x1c33:02, r-r-r-, uint32, 32 bit, "Cycle Time"
  0x1c33:03, ------, type 0000, 32 bit, "SubIndex 003"
  0x1c33:04, r-r-r-, uint16, 16 bit, "Synchronization Types supported"
  0x1c33:05, r-r-r-, uint32, 32 bit, "Minimum Cycle Time"
  0x1c33:06, r-r-r-, uint32, 32 bit, "Calc and Copy Time"
  0x1c33:07, ------, type 0000, 32 bit, "SubIndex 007"
  0x1c33:08, rwrwrw, uint16, 16 bit, "Get Cycle Time"
  0x1c33:09, r-r-r-, uint32, 32 bit, "Delay Time"
  0x1c33:0a, rwrwrw, uint32, 32 bit, "Sync0 Cycle Time"
  0x1c33:0b, r-r-r-, uint16, 16 bit, "SM-Event Missed"
  0x1c33:0c, r-r-r-, uint16, 16 bit, "Cycle Time Too Small"
  0x1c33:0d, ------, type 0000, 16 bit, "Shift Time Too Short"
  0x1c33:0e, ------, type 0000, 16 bit, "SubIndex 014"
  0x1c33:0f, ------, type 0000, 32 bit, "SubIndex 015"
  0x1c33:10, ------, type 0000, 32 bit, "SubIndex 016"
  0x1c33:11, ------, type 0000, 32 bit, "SubIndex 017"
  0x1c33:12, ------, type 0000, 32 bit, "SubIndex 018"
  0x1c33:13, ------, type 0000, 0 bit, "SubIndex 019"
  0x1c33:14, ------, type 0000, 0 bit, "SubIndex 020"
  0x1c33:15, ------, type 0000, 0 bit, "SubIndex 021"
  0x1c33:16, ------, type 0000, 0 bit, "SubIndex 022"
  0x1c33:17, ------, type 0000, 0 bit, "SubIndex 023"
  0x1c33:18, ------, type 0000, 0 bit, "SubIndex 024"
  0x1c33:19, ------, type 0000, 0 bit, "SubIndex 025"
  0x1c33:1a, ------, type 0000, 0 bit, "SubIndex 026"
  0x1c33:1b, ------, type 0000, 0 bit, "SubIndex 027"
  0x1c33:1c, ------, type 0000, 0 bit, "SubIndex 028"
  0x1c33:1d, ------, type 0000, 0 bit, "SubIndex 029"
  0x1c33:1e, ------, type 0000, 0 bit, "SubIndex 030"
  0x1c33:1f, ------, type 0000, 0 bit, "SubIndex 031"
  0x1c33:20, r-r-r-, bool, 1 bit, "Sync Error"
SDO 0x2000, "MDRCtrlLeft"
  0x2000:00, rwrwrw, uint8, 8 bit, "MDRCtrlLeft"
SDO 0x2001, "SpeedLeft"
  0x2001:00, rwrwrw, uint16, 16 bit, "SpeedLeft"
SDO 0x2002, "SpeedRight"
  0x2002:00, rwrwrw, uint16, 16 bit, "SpeedRight"
SDO 0x2003, "AccelLeft"
  0x2003:00, rwrwrw, uint16, 16 bit, "AccelLeft"
SDO 0x2004, "DecelLeft"
  0x2004:00, rwrwrw, uint16, 16 bit, "DecelLeft"
SDO 0x2005, "AccelRight"
  0x2005:00, rwrwrw, uint16, 16 bit, "AccelRight"
SDO 0x2006, "DecelRight"
  0x2006:00, rwrwrw, uint16, 16 bit, "DecelRight"
SDO 0x2007, "ServoControl"
  0x2007:00, rwrwrw, uint16, 16 bit, "ServoControl"
SDO 0x2008, "Set_ServoLeft"
  0x2008:00, rwrwrw, uint16, 16 bit, "Set_ServoLeft"
SDO 0x2009, "Set_ServoRight"
  0x2009:00, rwrwrw, uint16, 16 bit, "Set_ServoRight"
SDO 0x200c, "MDRCtrlRight"
  0x200c:00, rwrwrw, uint8, 8 bit, "MDRCtrlRight"
SDO 0x200f, "BrakeModeLeft"
  0x200f:00, rwrwrw, uint8, 8 bit, "BrakeModeLeft"
SDO 0x2010, "BrakeModeRight"
  0x2010:00, rwrwrw, uint8, 8 bit, "BrakeModeRight"
SDO 0x2011, "WritePin2Output"
  0x2011:00, rwrwrw, uint8, 8 bit, "WritePin2Output"
SDO 0x2012, "ClearMotorError"
  0x2012:00, rwrwrw, uint8, 8 bit, "ClearMotorError"
SDO 0x3000, "AllSensors"
  0x3000:00, r-r-r-, uint16, 16 bit, "AllSensors"
SDO 0x3001, "ServoStateLeft"
  0x3001:00, r-r-r-, uint8, 8 bit, "ServoStateLeft"
SDO 0x3002, "ServoPositionLeft"
  0x3002:00, r-r-r-, uint16, 16 bit, "ServoPositionLeft"
SDO 0x3003, "ServoPositionRight"
  0x3003:00, r-r-r-, uint16, 16 bit, "ServoPositionRight"
SDO 0x3004, "DiagnosticLeft"
  0x3004:00, r-r-r-, uint16, 16 bit, "DiagnosticLeft"
SDO 0x3005, "DiagnosticRight"
  0x3005:00, r-r-r-, uint16, 16 bit, "DiagnosticRight"
SDO 0x3006, "ServoStateRight"
  0x3006:00, r-r-r-, uint8, 8 bit, "ServoStateRight"
SDO 0x3013, "SystemDiagnostic"
  0x3013:00, r-r-r-, uint8, 8 bit, "SystemDiagnostic"
SDO 0x3014, "Reserved1"
  0x3014:00, r-r-r-, uint8, 8 bit, "Reserved1"
SDO 0x3015, "Reserved2"
  0x3015:00, r-r-r-, uint16, 16 bit, "Reserved2"
SDO 0x4000, "StartUpConfiguration"
  0x4000:00, rwrwrw, uint8, 8 bit, "SubIndex 000"
  0x4000:01, rwrwrw, uint16, 16 bit, "SensorPolarity"
  0x4000:02, rwrwrw, uint16, 16 bit, "SensorDebounce"
  0x4000:03, rwrwrw, uint16, 16 bit, "PushPull"
  0x4000:04, rwrwrw, uint16, 16 bit, "MotorTypeLeft"
  0x4000:05, rwrwrw, uint16, 16 bit, "MotorTypeRight"
  0x4000:06, rwrwrw, uint16, 16 bit, "BrakeModeLeft"
  0x4000:07, rwrwrw, uint16, 16 bit, "BrakeModeRight"
  0x4000:08, rwrwrw, uint16, 16 bit, "SpeedLeft"
  0x4000:09, rwrwrw, uint16, 16 bit, "SpeedRight"
  0x4000:0a, rwrwrw, uint16, 16 bit, "InOrOutPin2"
  0x4000:0b, rwrwrw, uint16, 16 bit, "LeftMotorSlave"
  0x4000:0c, rwrwrw, uint16, 16 bit, "RightMotorSlave"
  0x4000:0d, rwrwrw, uint16, 16 bit, "Reserved1"
  0x4000:0e, rwrwrw, uint16, 16 bit, "Reserved2"
  0x4000:0f, rwrwrw, uint16, 16 bit, "Reserved3"
SDO 0x4001, "ServiceReadObjects"
  0x4001:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x4001:01, r-r-r-, uint16, 16 bit, "MDRVoltage"
  0x4001:02, r-r-r-, uint16, 16 bit, "LogicVoltage"
  0x4001:03, r-r-r-, uint16, 16 bit, "SensorDetect"
  0x4001:04, r-r-r-, uint16, 16 bit, "MotorTempLeft"
  0x4001:05, r-r-r-, uint16, 16 bit, "MotorTempRight"
  0x4001:06, r-r-r-, uint16, 16 bit, "MotorCurrentLeft"
  0x4001:07, r-r-r-, uint16, 16 bit, "MotorCurrentRight"
  0x4001:08, r-r-r-, uint16, 16 bit, "MaxSpeedLeft"
  0x4001:09, r-r-r-, uint16, 16 bit, "MaxSpeedRight"
  0x4001:0a, r-r-r-, uint16, 16 bit, "RealSpeedLeft"
  0x4001:0b, r-r-r-, uint16, 16 bit, "RealSpeedRight"
  0x4001:0c, r-r-r-, uint16, 16 bit, "MDRFrequencyLeft"
  0x4001:0d, r-r-r-, uint16, 16 bit, "MDRFrequencyRight"
  0x4001:0e, r-r-r-, uint16, 16 bit, "MotorPWMLeft"
  0x4001:0f, r-r-r-, uint16, 16 bit, "MotorPWMRight"
  0x4001:10, r-r-r-, uint16, 16 bit, "SystemReserved1"
  0x4001:11, r-r-r-, uint16, 16 bit, "SystemReserved2"
  0x4001:12, r-r-r-, uint16, 16 bit, "Reserved1"
  0x4001:13, r-r-r-, uint16, 16 bit, "Reserved2"
  0x4001:14, r-r-r-, uint16, 16 bit, "Reserved3"
SDO 0x4100, "LeftMotorInfo"
  0x4100:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x4100:01, r-r-r-, uint16, 16 bit, "ProductID"
  0x4100:02, r-r-r-, uint8, 8 bit, "CustomerID"
  0x4100:03, r-r-r-, uint8, 8 bit, "RollerType"
  0x4100:04, r-r-r-, uint8, 8 bit, "MotorType"
  0x4100:05, r-r-r-, uint8, 8 bit, "DiamCode"
  0x4100:06, r-r-r-, uint8, 8 bit, "GearBox"
  0x4100:07, r-r-r-, uint8, 8 bit, "Interlock"
  0x4100:08, r-r-r-, uint8, 8 bit, "Month"
  0x4100:09, r-r-r-, uint8, 8 bit, "Year"
  0x4100:0a, r-r-r-, uint8, 8 bit, "Shaft"
  0x4100:0b, r-r-r-, uint8, 8 bit, "Tube"
  0x4100:0c, r-r-r-, uint16, 16 bit, "MtrLen"
  0x4100:0d, r-r-r-, uint8, 8 bit, "Day"
  0x4100:0e, r-r-r-, uint8, 8 bit, "Assemled"
  0x4100:0f, r-r-r-, uint32, 32 bit, "Time"
  0x4100:10, r-r-r-, uint32, 32 bit, "TimeCurrLimit"
  0x4100:11, r-r-r-, uint32, 32 bit, "TimeOverHeat"
  0x4100:12, r-r-r-, uint32, 32 bit, "OnOffCycles"
  0x4100:13, r-r-r-, uint32, 32 bit, "OverVoltageCounter"
  0x4100:14, r-r-r-, uint32, 32 bit, "UnderVoltageCounter"
SDO 0x4101, "RightMotorInfo"
  0x4101:00, r-r-r-, uint8, 8 bit, "SubIndex 000"
  0x4101:01, r-r-r-, uint16, 16 bit, "ProductID"
  0x4101:02, r-r-r-, uint8, 8 bit, "CustomerID"
  0x4101:03, r-r-r-, uint8, 8 bit, "RollerType"
  0x4101:04, r-r-r-, uint8, 8 bit, "MotorType"
  0x4101:05, r-r-r-, uint8, 8 bit, "DiamCode"
  0x4101:06, r-r-r-, uint8, 8 bit, "GearBox"
  0x4101:07, r-r-r-, uint8, 8 bit, "Interlock"
  0x4101:08, r-r-r-, uint8, 8 bit, "Month"
  0x4101:09, r-r-r-, uint8, 8 bit, "Year"
  0x4101:0a, r-r-r-, uint8, 8 bit, "Shaft"
  0x4101:0b, r-r-r-, uint8, 8 bit, "Tube"
  0x4101:0c, r-r-r-, uint16, 16 bit, "MtrLen"
  0x4101:0d, r-r-r-, uint8, 8 bit, "Day"
  0x4101:0e, r-r-r-, uint8, 8 bit, "Assemled"
  0x4101:0f, r-r-r-, uint32, 32 bit, "Time"
  0x4101:10, r-r-r-, uint32, 32 bit, "TimeCurrLimit"
  0x4101:11, r-r-r-, uint32, 32 bit, "TimeOverHeat"
  0x4101:12, r-r-r-, uint32, 32 bit, "OnOffCycles"
  0x4101:13, r-r-r-, uint32, 32 bit, "OverVoltageCounter"
  0x4101:14, r-r-r-, uint32, 32 bit, "UnderVoltageCounter"
alex-controlx commented 2 years ago

Thank you for the example on slaves.json. When I'm using this slaves.json it throws a fatal error:

FATAL ERROR: thread_entry Domain data initialization failed!

Aborted

It doesn't like subindex: "0x00" properties. When I change it to, say "0x01" it's accepted and added to the domain.

A few things in the changed to fix a number of issues:

  1. Could it be a bug in line 304 https://github.com/STECHOQ/etherlab-nodejs/blob/03e7f390cd563a224996f59937e81b02d22f1cab/src/ecat.cc#L304

and 318 https://github.com/STECHOQ/etherlab-nodejs/blob/03e7f390cd563a224996f59937e81b02d22f1cab/src/ecat.cc#L318

so it doesn't add to the domain?

  1. Also suggest change line 246 https://github.com/STECHOQ/etherlab-nodejs/blob/03e7f390cd563a224996f59937e81b02d22f1cab/lib/ecat.lib.js#L246

to typeof self._dmnAddr2Idx[position][identifier] === "number", otherwise it doesn't write in the first datablock.

  1. To fit the wrapper for my hardware I had to comment out one line in .cpp file: https://github.com/STECHOQ/etherlab-nodejs/blob/03e7f390cd563a224996f59937e81b02d22f1cab/src/include/config_parser.cpp#L279 This line of code could be optional and set via the config.

otherwise tail -f /var/log/syslog | grep EtherCAT shows WARNING and the values not written properly.

Dec 15 13:48:41 raspberrypi kernel: [53487.022253] EtherCAT WARNING 0-0: Slave does not support changing the PDO mapping!
Dec 15 13:48:41 raspberrypi kernel: [53487.022265] EtherCAT WARNING 0-0: Currently mapped PDO entries: 0x2000:00/8 0x200C:00/8 0x2001:00/16 0x2002:00/16 0x200F:00/8 0x2010:00/8. Entries to map: 0x2000:00/8 0x2001:00/16 0x2002:00/16 0x200C:00/8 0x200F:00/8 0x2010:00/8
Dec 15 13:48:41 raspberrypi kernel: [53487.022573] EtherCAT WARNING 0-0: Slave does not support changing the PDO mapping!
Dec 15 13:48:41 raspberrypi kernel: [53487.022582] EtherCAT WARNING 0-0: Currently mapped PDO entries: 0x3000:00/16 0x3001:00/8 0x3006:00/8 0x3002:00/16 0x3003:00/16. Entries to map: 0x3000:00/16 0x3001:00/8 0x3002:00/16 0x3003:00/16 0x3006:00/8
iqrok commented 2 years ago

you're right, I might overlook that part, about subindex value being 0. I'll create some fixes so subindex can accept 0x00.

about the WARNING, I think it doesn't matter whether qsort is omitted or not, the warnings would still be thrown. I'll chek that later, I know how to reproduce that WARNING.

Thanks for your inputs, really appreciate that.