beckhoff — 6.10 Reading SMB values from the TwinCAT I/O driver

Samples: TcJavaToAds err = AdsCallDllFunction.adsSyncReadReq(addr, 0x5000, 0x2, deviceCountBuff.getUsedBytesCount(), deviceCountBuff); if(err!=0) { visu.setInfoMsg("Error: Read device count:

0x" + Long.toHexString(err)); } devCount = Convert.ByteArrToInt( deviceCountBuff.getByteArray()) + 1; //Gets the device count of devices appended to active //configuration as zero-based index and gets the devices ID's of //all active devices for the remaining indices (inverted sort) JNIByteBuffer deviceBuff = new JNIByteBuffer( (Short.SIZE * devCount) / Byte.SIZE); ByteBuffer devices; err = AdsCallDllFunction.adsSyncReadReq(addr, 0x5000, 0x1, deviceBuff.getUsedBytesCount(), deviceBuff); if(err!=0) { visu.setInfoMsg("Error: Read devices:

0x" + Long.toHexString(err)); } devices = ByteBuffer.wrap(deviceBuff.getByteArray()); for (int i = 1; i JNIByteBuffer identNrBuff = new JNIByteBuffer(Short.SIZE / Byte.SIZE); short identNr = 0; //gets the device identification number //(Motherboard System Management Bus(SMB) => 32) err = AdsCallDllFunction.adsSyncReadReq(addr, 0x5000 + devices.getShort(i), 0x7, identNrBuff.getUsedBytesCount(), identNrBuff); if(err!=0) { visu.setInfoMsg("Error: Read ident numbers:

0x" + Long.toHexString(err)); } else { identNr = Convert.ByteArrToShort( identNrBuff.getByteArray()); //checks whether the device is of type SMB if (identNr == SMB_ID) { int indexGroup = 0x9000 + devices.getShort(i); // If a SMB-Device was found a TimerTask is started // to read the specified input from the device once // every second Timer tmr = new Timer(); tmr.schedule(new SMBTask(indexGroup, addr, visu), 0, 1); break; } } } } } catch (Exception ex) { visu.setInfoMsg(ex.getMessage()); } } } TX1000 45 Version: 1.1