Kārlis Repsons
2008-Dec-05 10:20 UTC
[Nut-upsuser] NUT 2.0.5 and 2.2.2 hacking -- there is something to improve!
Hello, I wanted to set my own time intervals for shutdown. {poweroff,return,paused.return}, so I had to change sources, where it has been set in a hard way. poweroff: Sxx\r return: Zxx\r paused.return: SxxRyyyy\r Solution A: Why not adding an info about these commands in a generic way and issuing shutdown.{poweroff.xx,return.xx,paused.return.xxyyyy} Solution B: Why not creating a special command, which takes UPS command as an argument? Really, for A (with 2.0.5 at least): unsigned int i; const char spo[] = "shutdown.poweroff"; const char sre[] = " shutdown.return"; const char spre[] = "shutdown.paused.return"; /* CMDDESC shutdown.poweroff.xx "Turn off the load after xx minute(s) and remain off" CMDDESC shutdown.return.xx "Turn off the load after xx minute(s) and return when power is back" CMDDESC shutdown.paused.return.xxyyyy "Turn off the load after xx minute(s) and return when power is back no sooner than after yyyy minutes" */ if (!strcasecmp(cmdname, "test.battery.start")) ret = powpan_command("T\r"); if (!strcasecmp(cmdname, "test.battery.stop")) ret = powpan_command("CT\r"); if (!strcasecmp(cmdname, "beeper.on")) ret = powpan_command("C7:1\r"); if (!strcasecmp(cmdname, "beeper.off")) ret = powpan_command("C7:0\r"); if (!strcasecmp(cmdname, "shutdown.stop")) ret = powpan_command("C\r"); // check for shutdown.poweroff: if ( (strlen(spo) + 3) == strlen(cmdname) ) { for ( i=0; i<strlen(spo); i++ ) if ( cmdname[ i ] != spo[ i ] ) break; if ( i == strlen(spo) ) { char comm[] = "Sxx\r"; comm[1] = cmdname[ strlen( spo ) + 1 ]; comm[2] = cmdname[ strlen( spo ) + 2 ]; ret = powpan_command(comm); } } // check for shutdown.return: if ( (strlen(sre) + 3) == strlen(cmdname) ) { for ( i=0; i<strlen(sre); i++ ) if ( cmdname[ i ] != sre[ i ] ) break; if ( i == strlen(sre) ) { char comm[] = "Zxx\r"; comm[1] = cmdname[ strlen( sre ) + 1 ]; comm[2] = cmdname[ strlen( sre ) + 2 ]; ret = powpan_command(comm); } } // check for shutdown.paused.return: if ( (strlen(spre) + 7) == strlen(cmdname) ) { for ( i=0; i<strlen(spre); i++ ) if ( cmdname[ i ] != spre[ i ] ) break; if ( i == strlen(spre) ) { char comm[] = "SxxRyyyy\r"; comm[1] = cmdname[ strlen( sre ) + 1 ]; comm[2] = cmdname[ strlen( sre ) + 2 ]; comm[4] = cmdname[ strlen( sre ) + 3 ]; comm[5] = cmdname[ strlen( sre ) + 4 ]; comm[6] = cmdname[ strlen( sre ) + 5 ]; comm[7] = cmdname[ strlen( sre ) + 6 ]; ret = powpan_command(comm); } } For B: you should know better, as I found NUT src tree complex enough not to do it. I would've stopped at expanding commandtab in 2.2.2, but I didn't like, I have to make such a great redundancy and also I had an error while doing hibernation or being in battery mode: my main terminal vt1 received many error messages: "Error: Data stale". Ugly. I would like to have these problems addressed, at least, removing error message and adding a function, which should be there is really not much asked for the author! So, solution B looks better, as there will always be a possibility, that new UPS command is possible. Ah, also, when experimenting with UPS commands (upscmd) in 2.2.2, they all return 0, even if there is no such command! Well, what people think? Regards, K?rlis
Arjen de Korte
2008-Dec-05 11:05 UTC
[Nut-upsuser] NUT 2.0.5 and 2.2.2 hacking -- there is something to improve!
Citeren K?rlis Repsons <karlis.repsons at gmail.com>: [ long rant removed ]> Well, what people think?This is the author of the powerpanel driver. What you're suggesting is what quite a couple of drivers already support. I would be happy to implement the suggestions you made in this driver. I neither work for the vendor of your UPS, nor own such a device, so my consultation fee is ? 75 per hour. Please let me know if you're interested in sponsoring the development of these additions. Best regards, Arjen PS Looking at the example code, you really should brush up on your coding skills and use 'snprintf' more often. PPS Asking nicely goes a much longer way. -- Please keep list traffic on the list
Kārlis Repsons
2008-Dec-06 11:28 UTC
[Nut-upsuser] NUT 2.0.5 and 2.2.2 hacking -- there is something to improve!
On Saturday 06 December 2008 11:05:17 you wrote:> Citeren K?rlis Repsons <karlis.repsons at gmail.com>: > > Sorry man, was all facts, you perceived them as an offence. > > Indeed I did (see below).I shouldn't have written after trying to get it work in an "accelerated" regime. Sorry, I know, is no excuse.> > > Ok, this is useless, if others support (if for same hardware, though). > > > > PS: so how should I've asked?...> Finally, I will add the requested functionality in due time. Maybe > something nice for the Christmas holidays, who knows. I'll let you > know if I need someone to test this with (I don't have access to a > CyberPower UPS, remember?)Ok, to be forgiven and make less trouble for others, I will monitor this list (traffic is not big) and when there is something to test, I will contribute that way, just it would be much nicer, if there is no more to do about it than stop what is working good (not modify) and try out some fresh code more directly. Well, we will see then. As I wrote, I am willing to help.> Not having access to such a device was the > #1 reason to hardcode these intervals in the first place. Making this > configurable, complicates this since we can't fallback to a couple of > settings that were used before. > > Your UPS will probably support setting a shutdown delay value between > 0 and 99That could be too much my-ups-specific! The manufacturer did post me info about 1..10, I know, 0 is working too, but more I didn't test! Anyway, my idea is, that driver should support full range (if there is no autodetection with UPS), and should take any command as input. Then it would be up to UPS to handle or reject it.> Best regards, ArjenRegards, K?rlis
Kārlis Repsons
2008-Dec-08 07:56 UTC
[Nut-upsuser] NUT 2.0.5 and 2.2.2 hacking -- there is something to improve!
On Saturday 06 December 2008 12:50:41 you wrote:> Citeren K?rlis Repsons <karlis.repsons at gmail.com>: > >> Not having access to such a device was the > >> #1 reason to hardcode these intervals in the first place. Making this > >> configurable, complicates this since we can't fallback to a couple of > >> settings that were used before. > >> Your UPS will probably support setting a shutdown delay value between > >> 0 and 99 > > > > That could be too much my-ups-specific! The manufacturer did post me info > > about 1..10, I know, 0 is working too, but more I didn't test! > > Please forward whatever information you have about this. Like I said, > I don't even know if this value is in seconds or minutes, so any > information you have is more than I have now.Here it goes what I have: The BP100 ups uses the Cyberpower protocol (a standard protocol in low power UPSs) and according to the official documentation of the protocol: 6. Shutdown Control 6.1 Shutdown only Client: ? ? ? ? Sxx<cr> UPS: ? ? ? ? ? ?#err_code<cr> Asking UPS to shutdown after xx minute later. The value xx should be .1 to .9 or 01 to 10. The z is error code to indicate does this operate is success. 0 is means success, otherwise, wrong in this operation. If UPS does have no any response then have wrong in this operation. When UPS received this command it should be turn-off at time expired and never restore. Exception : Prior model of UPS had not follow above rule, there have a exception: When UPS received this command at battery-mode, it should turn-off the outlet at time expired then restore the outlet at time of utility power recovered. the later designed UPS should correct this issue. 6.2 Shutdown with Restore Client: ? ?SxxRyyyy<cr> UPS: ? ? ? #err_code<cr> Asking UPS to shutdown after xx minutes later then restore after yyyy minutes since command was received. The value xx should be .1 to .9 or 01 to 10, value yyyy should be 0000 to 9999. The z is error code to indicate does this operate is success. 0 is means success, otherwise, wrong in this operation. If UPS does have no any response then have wrong in this operation. 6.3 Sleep Client: ? ? ? ? Zxx<cr> UPS: ? ?#y<cr> Asking UPS to shutdown after xx minute later. The value xx should be .1 to .9 or 01 to 10. When UPS received this command at line-mode, it should turn-off the outlet at time expired then restore it immediately. When UPS received this command at battery-mode, it should turn-off the outlet at time expired then restore the outlet at time of utility power recovered. In both mode, the restoration is according to feature of Auto-Restart is enabled or disabled. The UPS should promise to do response for any condition. The y is error code to indicate does this operate is success. 0 is means success, otherwise, wrong in this operation. Note : While UPS have no any response for Zxx<cr> command, that means UPS do not support this command. In order to make UPS to do shutdown, using Sxx<cr> to instead of Zxx<cr> command. If UPS accept Sxx<cr> command rather than Zxx<cr> command, that means UPS will restore while utility power will recover.(see 6.Scheduled Shutdown/Shutdown only/Exception) 6.4. Cancel Shutdown Operation. Client: ? ? ? ? C<cr> UPS: ? ? ? ? ? ?#err_code<cr> Asking UPS to stop Shutdown. The z is error code to indicate does this operate is success. 0 is means success, otherwise, wrong in this operation. If UPS does have no any response then have wrong in this operation. As I wrote, I don't know about xx values greater than 10.> > > Anyway, my idea is, that driver should support full range (if there is no > > autodetection with UPS), and should take any command as input. Then it > > would be up to UPS to handle or reject it. > > Like the other drivers that support start- and shutdown delays, this > will be configurable through 'ups.conf' with the 'ondelay' and > 'offdelay' parameters. The only validation there will be in the > driver, is if the value fits within the 2 or 4 character space that is > available in the command.So I could just compile powerpanel driver and replace for tests? I guess no, because of I have 2.0.5 NUT. (maybe use driver more directly?)> > Best regards, Arjenk.
Kārlis Repsons
2008-Dec-08 19:03 UTC
[Nut-upsuser] NUT 2.0.5 and 2.2.2 hacking -- there is something to improve!
On Monday 08 December 2008 13:13:12 you wrote:> Citeren K?rlis Repsons <karlis.repsons at gmail.com>: > >> Now *this* is useful! Do you have the full specification available? If > >> possible, can you send it? > > > > Maybe other person will send. > > Given the total lack of support NUT gets from Cyberpower, I doubt it. > > Many users have already asked for this, but so far the response has > invariably been that this is confidential information and that they > can't release it. I'm actually quite surprised you have access to this > information, unless you happen to be working for Cyberpower (or an > affiliate).Confidential? Sounds quite ridiculous, who can have business on that protocol? I understand, if on UPSes, also then it would be the manufacturers interest to make their systems available. Some kind of nightmare in there. Perhaps someone has a great fear, his systems could have some hole :)> It seems to me that I've hit another dead end here, so I'm putting > this on the back burner until I get some more information. In the mean > time I'll spend my time on equipment from vendors that take supporting > NUT seriously (by sending both documentation and hardware to test with).As you wish, of course. If you decide to add time delay configuration options and want to test, let me know... As for my needs, I could make it work with that little piece of info.> Best regards, ArjenK.