Can somebody please explain why values are 0-prepended in almost every driver? Since it's done almost everywhere I suspect it's due to some old policy. In theory this might have been a good idea given the assumption that applications are forced to parse the values before presenting them. However, since this isn't done even within NUT I don't see any real reason for doing this. Essentially, 0-prepended values: * Normally means that they are octal, but they aren't in our case. * Produces ugly cluttered output when displayed without processing (as done but upsc/upsstats etc). * Does not facilitate parsing in any way (it might have if the values were octal, but they aren't). I'd really like to remove all 0-prepending of values because of these reasons. The way to go for this would probably be to agree on some kind of "best practices" and document it in new-names.txt and then people can change their drivers in their own pace when they get nagged by users that their UPS shows ugly 0-prepended stuff in upsstats et al. ;) /Nikke -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se | nikke@acc.umu.se --------------------------------------------------------------------------- I am Groucho of Borg. Say the secret woid and you will be assimilated. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
On 2/23/06, Niklas Edmundsson <nikke@acc.umu.se> wrote:> Can somebody please explain why values are 0-prepended in almost every > driver? Since it's done almost everywhere I suspect it's due to some > old policy.I don't have time at the moment to look into this, but this probably started because some of the older UPSes actually returned values padded with zeroes. Other people probably looked at the driver output and made their code output similar values. You should probably check with Arnaud to see whether clients are counting on certain widths for their numbers. I agree in principle that a '0' prefix should only be used for octal numbers, but then again, the only bases that you generally see with UPS protocols are 2, 10, and 16. -- - Charles Lepple
> Given this experience, I think it would be a good thing to documentsuggested format strings in docs/new-names.txt. Something like %.1f for measurements. The question is how to handle stuff with only> integer output, do we want those to stick to integers or do we want themto produce similarly formatted output? I tend to prefer the latter, consistent output is a good thing. However, since my taste isn't the Universal Truth<tm> I expect a lengthy thread debating this :) You asked for it, so here we go. Where analog values (voltage, current, temperature) are measured, you may have a point, although I would rather leave this up to the driver to decide. If the UPS can't measure a value with decimal precision, I'd prefer not to add a decimal. On the other hand, if it can measure a value more precisely I don't see what value there is in truncating it. Regarding integer values, I would hate to see something like "number of batteries installed 4.0" or "outputs active 2.0". So where exact counts/numbers are involved, I think it is not a good idea at all to add a decimal. Of course, for display purposes you can truncate or add whatever decimal positions you like, but the drivers should not be limited in that respect. Arjen -- Eindhoven - The Netherlands Key fingerprint - 66 4E 03 2C 9D B5 CB 9B 7A FE 7E C1 EE 88 BC 57