Glen Bakeman
2021-Sep-02 22:13 UTC
[Nut-upsdev] Looking for examples of var TYPE descriptions
Thank you for the info, Roger. I was going off of the developer guide <https://networkupstools.org/docs/developer-guide.chunked/ar01s09.html> at nut.org which seems pretty close to the one you linked to, at least for the section I'm in right now. I don't think I quite have the answer I'm looking for. To give a little more background, I'm working on a program that, among other things, will parse the variable type(s) that are passed to it from a NUT server. I'd like to understand just how exotic/complicated a variable type can get. If that means ENUMs are just enum and nothing else, great - although from my understanding in the master branch of the nut-ups code, it seems possible that variables can mix and match when the server responds to such a query. I'm hoping someone can maybe provide a few examples of what the most complex variables look like, since I don't seem to have those on my end. Glen On 9/2/2021 2:50 AM, Roger Price wrote:> On Wed, 1 Sep 2021, Glen Bakeman via Nut-upsdev wrote: > >> I'm currently trying to understand the implementation of get_type in >> netget.c, specifically how more complex variable types (such as ENUMs >> or RANGEs) are represented by text. On my own UPS, it doesn't seem to >> have anything more complicated than a number or string (or UNKNOWN). >> >> It looks like it would be theoretically possible for a var to show as >> enum OR range AND string OR number, is that true? > > Have a look at section 4.2.4 GET at > http://rogerprice.org/NUT/draft-rprice-ups-management-protocol-05.html#name-get-2 > > > Roger > > _______________________________________________ > Nut-upsdev mailing list > Nut-upsdev at alioth-lists.debian.net > https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://alioth-lists.debian.net/pipermail/nut-upsdev/attachments/20210902/59d6dfcd/attachment.htm>
Roger Price
2021-Sep-03 07:54 UTC
[Nut-upsdev] Looking for examples of var TYPE descriptions
On Thu, 2 Sep 2021, Glen Bakeman via Nut-upsdev wrote:> To give a little more background, I'm working on a program that, among other > things, will parse the variable type(s) that are passed to it from a NUT > server. I'd like to understand just how exotic/complicated a variable type can > get. If that means ENUMs are just enum and nothing else, great - although from > my understanding in the master branch of the nut-ups code, it seems possible > that variables can mix and match when the server responds to such a query. I'm > hoping someone can maybe provide a few examples of what the most complex > variables look like, since I don't seem to have those on my end.There is no overall grammar for the "language" of the responses sent by a NUT server to the client. Each command received by the server invites a response with a very limited grammar available for that response. The command GET TYPE <upsname> <varname> returns the type, i.e. the grammar of the response. There is only one type per variable, and there is only one grammar. Choosing the grammar of the response requires the server code to be able to handle all the possible types, but the client will receive only one at a time. This is why the examples given are always simple, as in 4.2.4.6. command GET VAR su700 ups.status and response VAR su700 ups.status "OB LB" However some testing showed: rprice at maria ~ nc localhost 3493 GET TYPE Eaton ups.status TYPE Eaton ups.status NUMBER GET VAR Eaton ups.status VAR Eaton ups.status "OL" "OL" is not a NUMBER. I cannot explain this. Perhaps others can. Roger