mini-box / ups

Linux Status and Configuration application for Mini-Box.com Open UPS, Open UPS 2 and NUC UPS
https://www.mini-box.com/micro-UPS-load-sharing
46 stars 8 forks source link

read error when trying to pull RTE and capacity #10

Open lorenzoooooo opened 2 years ago

lorenzoooooo commented 2 years ago

I am using openups with firmware 1.9 and the configuration set is in the attached file.

While trying to run the following code inside GetStatus() method of object HIDOpenups: " ret = sendMessage(OPENUPS_CLOCK_OUT, 0); usleep(1000); recvMessage(recv); parseMessage(recv); " I get the following error: " hid_interrupt_read failed with return code -110 Read error [0xc0]: -110 " it reads the capacity and the RTE but puts to 0 all the other values. If I comment this part of code I get all the values with correct values except for the RTE and capacity and the error is not present. Furthermore I saw that the windows interface doesn't have this problem.

settings.txt

chunter1 commented 1 year ago

Will this EVER get fixed?

mcmara commented 10 months ago

It seems that I have got it working reliably by removing all delays and sending the OPENUPS_CLOCK_OUT message twice. In particular, I changed GetStatus into this:

void HIDOpenUPS::GetStatus() 
{
    unsigned char recv[32];
    int ret;

    sendMessage(OPENUPS_GET_ALL_VALUES, 0);
    recvMessage(recv);
    parseMessage(recv);

    ret = sendMessage(OPENUPS_GET_ALL_VALUES_2, 0);
    recvMessage(recv);
    parseMessage(recv);

    ret = sendMessage(OPENUPS_CLOCK_OUT, 0);
    recvMessage(recv);
    parseMessage(recv);

    ret = sendMessage(OPENUPS_CLOCK_OUT, 0);
    recvMessage(recv);
    parseMessage(recv);
}

This is on a little rpi zero w, running Raspbian GNU/Linux 11 (bullseye). I was having the same problem as you described it above.