Hi Tim,
> I ran into a portability issue with drivers/bcmxcp.c in nut-2.4.1 on
> my UnixWare 7.1.4 machine. The error I get is
> .....
> UX:acomp: ERROR: "/opt/src/utils/nut-2.4.1/drivers/bcmxcp.c", line 835:
>  integral constant expression expected .....
> 
> Looking at the code we see
> .....
> int init_outlet(unsigned char len)
> {
>         unsigned char answer[len];
> .....
> 
> Although gcc can handle it, it's not portable C code.
> 
> What size should the answer array be?
> 

It depends on the ups.
In the upsdrv_initinfo parsing the ID Block you get the length of the 
outlet_block.
---------------------------------
        /* Size of outlet monitoring block */
        outlet_block_len = get_word(answer+iIndex);
        upsdebugx(2, "Length of outlet_block: %d\n", outlet_block_len);
        iIndex += 2;
---------------------------------
If this block is larger that 8 this indicate more than one outlet. So we go to
setup and read the outlet. Also add the commands.
---------------------------------
        /* Due to a bug in PW5115 firmware, we need to use blocklength > 8.
        The protocol state that outlet block is only implemented if there is
        at least 2 outlet block. 5115 has only one outlet, but has outlet 
block! */ 
        if (outlet_block_len > 8) {
                len = init_outlet(outlet_block_len);

                for(res = 1 ; res <= len ; res++) {
                        snprintf(outlet_name, sizeof(outlet_name)-1, 
"outlet.%d.shutdown.return", res);
                        dstate_addcmd(outlet_name);
                }
        }
---------------------------

So setting the length of the answer from the ID_block. So from 0 - 20 at the 
moment.
It would be possible to hardcode this len, and leave some space for 4 outlet.

Would be 2+6+6+6+6 = 26

Regards
Kjell



_______________________________________________
Nut-upsdev mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev

Reply via email to