num_communicating[0] = 0;
short startAddress = 0;
byte toWrap[] = TKCMDSET_PM3_PRODUCT_NAME2.getBytes();
ByteBuffer byteBuffer = ByteBuffer.wrap(toWrap);
ShortBuffer numCommunicatingBuffer = ShortBuffer
.wrap(num_communicating);
// ecode = pm3ddicp.tkcmdsetDDI_discover_pm3s(toWrap, 0, startAddress,
// num_communicating, 0);
ecode = pm3ddicp.tkcmdsetDDI_discover_pm3s(byteBuffer, startAddress,
numCommunicatingBuffer);
if (ecode == 0 && numCommunicatingBuffer.get(0) > 0) {
// We discovered one or more PM3's
numNewPM3Devices = numCommunicatingBuffer.get(0);
}
slf4jLogger.info(String.format("Number of %s is: %d",
TKCMDSET_PM3_PRODUCT_NAME2, numNewPM3Devices));
// Look for old style PM3 devices, starting numbering after the previous
byteBuffer = ByteBuffer.wrap(TKCMDSET_PM3_PRODUCT_NAME.getBytes());
ecode = pm3ddicp.tkcmdsetDDI_discover_pm3s(byteBuffer,
numCommunicatingBuffer.get(0), numCommunicatingBuffer);
if (ecode == 0 && numCommunicatingBuffer.get(0) > 0) {
// We discovered one or more old PM3's
numOldPM3Devices = numCommunicatingBuffer.get(0) - numNewPM3Devices;
}
slf4jLogger.info(String.format("Number of %s is: %d",
TKCMDSET_PM3_PRODUCT_NAME, numOldPM3Devices));
// Look for PM4 devices
byteBuffer = ByteBuffer.wrap(TKCMDSET_PM4_PRODUCT_NAME.getBytes());
ecode = pm3ddicp.tkcmdsetDDI_discover_pm3s(byteBuffer,
numCommunicatingBuffer.get(0), numCommunicatingBuffer);
if (ecode == 0 && numCommunicatingBuffer.get(0) > 0) {
// We discovered one or more PM4's
numPM4Devices = numCommunicatingBuffer.get(0) - numNewPM3Devices
- numOldPM3Devices;
}
slf4jLogger.info(String.format("Number of %s is: %d",
TKCMDSET_PM4_PRODUCT_NAME, numPM4Devices));
numberPmsOnline = numCommunicatingBuffer.get(0);
if(numberPmsOnline > 0){
slf4jLogger.info(String.format("PM's discovered: %s\n", numberPmsOnline));
}else{
slf4jLogger.error(String.format("No PMs found"));