I have a UPS HID device and I'm trying to use LibUSB to get data from it. The response expected is in the format below:
(Input_Volt ^ Fault_Volt ^ Output_Volt ^ Input_Curr ^ Freq ^ Batt_Volt (MMM.M ^ NNN.N ^ PPP.P ^ QQQ ^ RR.R ^ SS.S or S.SS ^ Temp ^ Status<cr> ^ TT.T ^8bit <cr>)
Example:
(229.0 000.0 220.0 000 49.9 2.25 33.0 00000000 <cr>)
At the current moment, I'm not able to get a populated response from the device since it's returning a response like this:
(000.0 000.0 000.0 000 00.0 0.00 00.0 00000000)
Curiosity: If I use the software UPSmart I can see that the UPS is working well. If I stop the UPSmart and try to get the response from the device again using my code, the response returned is the last one that was shown in the UPSmart and it does not change anymore.
Here is the code I'm using:
Context mContext = new Context();
int result = LibUsb.init(mContext);
if (result != LibUsb.SUCCESS)
throw new RuntimeException(String.format("USB error: Unable to initialize LibUSB. Error %d: %s", result, LibUsb.strError(result)));
DeviceHandle mDeviceHandle = LibUsb.openDeviceWithVidPid(mContext, vendorId, productId);
if (mDeviceHandle == null) {
throw new Exception("USB error: Device not found or is being used by another process");
}
System.out.println(LibUsb.getStringDescriptor(mDeviceHandle, 0x3));
LibUsb.exit(mContext);
Should I send any other command to tell the UPS it should populate the data?