ihmcrobotics / ihmc-ethercat-master

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

Slave/SlaveInfo: ByteBuffer and SWIGTYPE_p_void are incompatible #2

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hey :) When compiling the Java part of the library,I get errors that the types ByteBuffer and SWIGTYPE_p_void are incompatible and that the buffer cannot be converted to the SWIGTYPE_p_void. I am using Ubuntu 14.04.3 LTS with gradle 4.1 , JDK 1.8.0_60 and all other steps in the README (along with the C libraries) can be completed successfully.

warning: [options] bootstrap class path not set in conjunction with -source 1.7 /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:154: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void int wc = soem.ecx_FPRD(context.getPort(), ec_slave.getConfigadr(), ECT_REG_WATCHDOG_DIV, 4, pdoWatchdogBuffer, soemConstants.EC_TIMEOUTRET); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:163: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void wc = soem.ecx_FPWR(context.getPort(), ec_slave.getConfigadr(), ECT_REG_WATCHDOG_PDO_TIMEOUT, 4, pdoWatchdogBuffer, soemConstants.EC_TIMEOUTRET); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:241: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void int wc = soem.ecx_SDOwrite(context, slaveIndex, index, (short) subindex, (short) 0, buffer.position(), buffer, timeout); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:487: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void int wc = soem.ecx_SDOread_java_helper(context, slaveIndex, index, (short) subIndex, (short) 0, size, sdoBuffer, soemConstants.EC_TIMEOUTRXM); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:713: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void BufferOffsetHolder inputOffset = new BufferOffsetHolder(soem.ecx_inputoffset(ec_slave, ioMap), ec_slave.getIstartbit(), ec_slave.getIbits()); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:729: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void BufferOffsetHolder outputOffset = new BufferOffsetHolder(soem.ecx_outputoffset(ec_slave, ioMap), ec_slave.getOstartbit(), ec_slave.getObits()); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:884: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void int wkc = soem.ecx_FPWR(context.getPort(), ec_slave.getConfigadr(), register, value.remaining(), value, soemConstants.EC_TIMEOUTRET); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Slave.java:901: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void int wkc = soem.ecx_FPRD(context.getPort(), ec_slave.getConfigadr(), soemConstants.ECT_REG_DCSYSDIFF, 4, dcDiff, soemConstants.EC_TIMEOUTRET); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/Master.java:379: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void int ioBufferSize = soem.ecx_config_map_group(context, ioMap, (short)0); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/SlaveInfo.java:56: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void int wkc = soem.ecx_SDOread_java_helper(context, slaveIndex, PDOassign, (short) 0x00, FALSE, 2, buffer, soemConstants.EC_TIMEOUTRXM); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/SlaveInfo.java:65: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void wkc = soem.ecx_SDOread_java_helper(context, slaveIndex, PDOassign, (short) i, FALSE, 2, buffer, soemConstants.EC_TIMEOUTRXM); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/SlaveInfo.java:81: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void wkc = soem.ecx_SDOread_java_helper(context, slaveIndex, idx, (short) 0x0, FALSE, 1, buffer, soemConstants.EC_TIMEOUTRXM); ^ /home/velitchko/Desktop/ihmc-ethercat-master-master/src/us/ihmc/etherCAT/master/SlaveInfo.java:87: error: incompatible types: ByteBuffer cannot be converted to SWIGTYPE_p_void wkc = soem.ecx_SDOread_java_helper(context, slaveIndex, idx, (short) subCount, FALSE, 4, buffer, soemConstants.EC_TIMEOUTRXM); ^

Any ideas on how to fix this?I want to try to run some sort of Ethercat device (simulated one would be best) and try to interface it with Java.

jespersmith commented 7 years ago

I would advice trying the gradle/maven dependency first, that should work fine under 14.04 (do you use 64 bit OS/JVM?).

Otherwise, I suspect your swig version is old, which version do you use? The swig code is regenerated when you build the C code, and I think the support for ByteBuffers is more recent than Ubuntu 14.04.

Sorry for the delayed answer, I was out of town.

jespersmith commented 7 years ago

So out of curiosity I tested compiling under 14.04 on a Virtual Machine and the default version of Swig does not work. You need at least 3.0.8.

Swig 3.0.8 can be installed using the 16.04 package. It can be downloaded from https://packages.ubuntu.com/xenial/amd64/swig3.0/download

I've updated the README with more info. You might also need to install OpenJDK 8 to avoid certificate errors with the gradle domain. The compiled application should still run using OpenJRE 7 afterwards.

ghost commented 7 years ago

Thank you for the response :) I did a fresh install of Ubuntu 16.10, installed SWIG 3.0.8 and OpenJDK 8 and it installed like a charm.

jespersmith commented 7 years ago

You're welcome. Let us know if you have any more issues, we're always looking to improve our library to work with more setups.