[Nut-upsdev] Patching CyberPower UPS drivers

Ben Kamen ben at benkamen.net
Tue Jan 19 14:37:29 UTC 2016

Hey there,

   I got a new UPS (CyberPower PR1500LCDRTXL2Ua) and found the serial drivers don't quite work...

So I decided to jump in and make changes to the driver that would hopefully make it happier.

I have it working (I really only changed powerp-txt.c) but still have a couple questions... Charles said I should mention them here to talk to anyone interest but specifically Arjen (one of the original authors of the driver)


Here I am. ;)

Where should we start?

Essentially, I rewrote powpan_status so it better tolerates strings of different lengths (although I only have the 1 UPS right now, so I can't test against another and different string lengths)

I had to make the serial read much longer so it grabs 55bytes instead of the original short list.

>   9.843588     read: (55 bytes) => 23 49 31 31 38 2e 30 4f 31 31 38 2e 30 4c 30 31 37 42
>    9.843663      31 30 30 54 30 32 35 48 30 36 30 2e 30 46 30 36 30 2e 30 52 30 35 31 51 30
>    9.843695      30 32 53 90 84 c0 88 80 57 00 81 0d

compared to the original string support in the file, there's now 2 fields of binary data (in ASCII Protocol? seriously? smh)

and the S field on this UPS has 4 bytes instead of just 2.

(not that it matters I guess... but now it makes me wonder what all the extra information is)

(I also guess someone has tried reaching out to CyberPower for docs and been turned down?)

Anyway -- in rewriting this, the only part I have left to do to where I'm happy is setting the timeout.

Instead of asking for N number of chars and then timing out after a long time, I'd like to ask it for a string (up to the 0x0D).

I haven't written that in yet, but will if someone says there's another way -- or I have to do it that way....

so that an incomplete string after time causes a timeout but a string that comes in reasonably soon will be collected -- but not using a fixed number (since it seems these UPSs now have variability in string length between models) and then just parse the string.

The parsing part works. I just need to alter the collection part so the timeouts work differently.

Any advice from anyone?



More information about the Nut-upsdev mailing list