ihmcrobotics / ihmc-ethercat-master

Java EtherCAT master based on the SOEM EtherCAT master
Apache License 2.0
21 stars 14 forks source link

Invalid slave configuration for slave 0:0. Invalid vendor and/or product code. #7

Closed edokkir closed 5 years ago

edokkir commented 5 years ago

OS, running in virtualbox: (experimental test) Linux vbox-ubuntu 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux Jdk: java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

Slave object: netHat 52 from Hilscher

Steps to reproduce issue

Can you please guide me to resolve coding a slave module and accessing its registers? Is there an error in mapping the slaveInfo output to the java slave file? Is it mandatory to run from a native computer, not a virtual machine? (for test purposes)

I have gone through the steps in ihmc-ethercat-master to create the environment. Managed to get slaveInfo to produce the information of the slave:

Found 1 slaves 1 - 0:0 netX Manufacturer: 0xe0000044 Product code: 0x0000002e Revision: 262149 Distributed Clocks: yes SM(0) Address: 0x1000, length: 128 Flags: 65590 Type: Mailbox messages receive SM(1) Address: 0x1080, length: 128 Flags: 65586 Type: Mailbox messages transmit SM(2) Address: 0x1100, length: 200 Flags: 65652 Type: Cyclic process data receive RxPDO 0x1600 RxPDO 0x2000:0x01 UNSIGNED8 1 Byte Out (0) 0x2000:0x02 UNSIGNED8 1 Byte Out (1) 0x2000:0x03 UNSIGNED8 1 Byte Out (2) 0x2000:0x04 UNSIGNED8 1 Byte Out (3) 0x2000:0x05 UNSIGNED8 1 Byte Out (4) 0x2000:0x06 UNSIGNED8 1 Byte Out (5) 0x2000:0x07 UNSIGNED8 1 Byte Out (6) 0x2000:0x08 UNSIGNED8 1 Byte Out (7) 0x2000:0x09 UNSIGNED8 1 Byte Out (8) 0x2000:0x0a UNSIGNED8 1 Byte Out (9) 0x2000:0x0b UNSIGNED8 1 Byte Out (10) 0x2000:0x0c UNSIGNED8 1 Byte Out (11) 0x2000:0x0d UNSIGNED8 1 Byte Out (12) 0x2000:0x0e UNSIGNED8 1 Byte Out (13) 0x2000:0x0f UNSIGNED8 1 Byte Out (14) 0x2000:0x10 UNSIGNED8 1 Byte Out (15) 0x2000:0x11 UNSIGNED8 1 Byte Out (16) 0x2000:0x12 UNSIGNED8 1 Byte Out (17) 0x2000:0x13 UNSIGNED8 1 Byte Out (18) 0x2000:0x14 UNSIGNED8 1 Byte Out (19) 0x2000:0x15 UNSIGNED8 1 Byte Out (20) 0x2000:0x16 UNSIGNED8 1 Byte Out (21) 0x2000:0x17 UNSIGNED8 1 Byte Out (22) 0x2000:0x18 UNSIGNED8 1 Byte Out (23) 0x2000:0x19 UNSIGNED8 1 Byte Out (24) 0x2000:0x1a UNSIGNED8 1 Byte Out (25) 0x2000:0x1b UNSIGNED8 1 Byte Out (26) 0x2000:0x1c UNSIGNED8 1 Byte Out (27) 0x2000:0x1d UNSIGNED8 1 Byte Out (28) 0x2000:0x1e UNSIGNED8 1 Byte Out (29) 0x2000:0x1f UNSIGNED8 1 Byte Out (30) 0x2000:0x20 UNSIGNED8 1 Byte Out (31) SM(3) Address: 0x1d00, length: 200 Flags: 65584 Type: Cyclic process data transmit TxPDO 0x1a00 TxPDO 0x3000:0x01 UNSIGNED8 1 Byte In (0) 0x3000:0x02 UNSIGNED8 1 Byte In (1) 0x3000:0x03 UNSIGNED8 1 Byte In (2) 0x3000:0x04 UNSIGNED8 1 Byte In (3) 0x3000:0x05 UNSIGNED8 1 Byte In (4) 0x3000:0x06 UNSIGNED8 1 Byte In (5) 0x3000:0x07 UNSIGNED8 1 Byte In (6) 0x3000:0x08 UNSIGNED8 1 Byte In (7) 0x3000:0x09 UNSIGNED8 1 Byte In (8) 0x3000:0x0a UNSIGNED8 1 Byte In (9) 0x3000:0x0b UNSIGNED8 1 Byte In (10) 0x3000:0x0c UNSIGNED8 1 Byte In (11) 0x3000:0x0d UNSIGNED8 1 Byte In (12) 0x3000:0x0e UNSIGNED8 1 Byte In (13) 0x3000:0x0f UNSIGNED8 1 Byte In (14) 0x3000:0x10 UNSIGNED8 1 Byte In (15) 0x3000:0x11 UNSIGNED8 1 Byte In (16) 0x3000:0x12 UNSIGNED8 1 Byte In (17) 0x3000:0x13 UNSIGNED8 1 Byte In (18) 0x3000:0x14 UNSIGNED8 1 Byte In (19) 0x3000:0x15 UNSIGNED8 1 Byte In (20) 0x3000:0x16 UNSIGNED8 1 Byte In (21) 0x3000:0x17 UNSIGNED8 1 Byte In (22) 0x3000:0x18 UNSIGNED8 1 Byte In (23) 0x3000:0x19 UNSIGNED8 1 Byte In (24) 0x3000:0x1a UNSIGNED8 1 Byte In (25) 0x3000:0x1b UNSIGNED8 1 Byte In (26) 0x3000:0x1c UNSIGNED8 1 Byte In (27) 0x3000:0x1d UNSIGNED8 1 Byte In (28) 0x3000:0x1e UNSIGNED8 1 Byte In (29) 0x3000:0x1f UNSIGNED8 1 Byte In (30) 0x3000:0x20 UNSIGNED8 1 Byte In (31)

Created a slave java file to run: ` import us.ihmc.etherCAT.master.RxPDO; import us.ihmc.etherCAT.master.Slave; import us.ihmc.etherCAT.master.SyncManager; import us.ihmc.etherCAT.master.TxPDO;

public class NetHat extends Slave {

static final int vendorID = 0xE0000044;
static final int productCode = 0x0000002E;

public class Input extends RxPDO {

    Unsigned8 value = new Unsigned8(8);

    protected Input(int address) {
        super(address);
    }
};

public class Output extends TxPDO {

    Unsigned8 value = new Unsigned8(8);

    protected Output(int address) {
        super(address);
    }
};

public NetHat(int aliasAddress, int configAddress) {
    super(vendorID, productCode, aliasAddress, configAddress);

    registerSyncManager(new SyncManager(2, true));
    registerSyncManager(new SyncManager(3, true));
    configurePDOWatchdog(1000000000);

    Input[] ins = new Input[32];
    Output[] outs = new Output[32];
    int insInitialAdrs = 0x1a00;
    int outsInitialAdrs = 0x1600;

    for (int i = 0; i < 32; i++) {
        ins[i] = new Input(insInitialAdrs + i);
        sm(2).registerPDO(ins[i]);

        outs[i] = new Output(outsInitialAdrs + i);
        sm(3).registerPDO(outs[i]);
    }

}`

Expected behavior

No exceptions so that the doControl loop runs.

Actual behavior

Attaching native thread 13975 with priority 50 to JVM [9230434750219] Master: Setting up fast IRQ [9230454179216] Master: Creating context [9230456023885] Master: Opening interface


*

Contributors with relevant knowledge or expertise (optional)

jespersmith commented 5 years ago

I think it is a signed/unsigned issue with the vendorID. We never tested with slaves where the vendor ID is that big.

If you have the ability to run from source, please test against the latest "master". I created a bugfix commit here https://github.com/ihmcrobotics/ihmc-ethercat-master/commit/61897557625238b2fcae6a21b71158985de64c60

In your code, change vendor ID and productCode to

static final long vendorID = 0xE0000044L; static final long productCode = 0x0000002EL;

note the (L) at the end of the variable, which forces it to be a long value. This avoids integer overflow and wrapping to a negative value.

If you can't use the code from source, please let me know and I'll try to push a new release later today

edokkir commented 5 years ago

Thank you for the prompt reply, I have done the relevant changes, now I get this right out on the first line: Exception in thread "main" java.lang.NoSuchMethodError: us.ihmc.etherCAT.master.Slave.<init>(JJII)V

jespersmith commented 5 years ago

You're still linking to the old version of the master. Make sure you updated to the master version from source.

If you can't get it to work from source I'll have to make a release, but that'll take some time.

edokkir commented 5 years ago

Yes, I had missed the last gradlew jar part, now it seems to be working. At least this case is over, thank you for the prompt and precise help.

jespersmith commented 5 years ago

Awesome. I'll make a release including this fix soon then.