[Nut-upsdev] Problem with bestfcom and old Ferrups

Arjen de Korte nut+devel at de-korte.org
Thu Feb 7 07:49:36 UTC 2008


>> >         if (strlen(rstring) < 80 ) {
>> > +               ser_get_line(upsfd, rstring, sizeof(rstring), '>',
>> "\012", 3, 0);
>> >                 upsdrv_init_nofc();
>>
>> I assume this is safe for owners of the newer Ferrups units? (I am not
>> familiar with this protocol in particular.)
>
> Well, someone with a newer model should definately try it.  I need this
> because my UPS doesn't support the "fc" command and has an error that
> isn't read from the serial port before continuing.  The newest models I
> think have the "fc" command and won't hit this; the models without "fc"
> should at worst hit this as a one-time timeout.

I think this is better handled by a strategically placed 'ser_flush_io()'
command. Since you're not actually reading data, this is probably all it
takes to get rid of the garbarge that is left in the buffer. From looking
at the execute() function, a favorable position would be

193- 	        ser_get_line_alert(upsfd, buf, sizeof(buf), '\012', "",
194- 	                POLL_ALERT, alert_handler, 0, 20000);
193+
194+ 	        ser_flush_io(upsfd);
195
196 	        ser_send(upsfd, cmd);

All the alert_handler does, is reading a single line from the UPS in an
attempt to clear the buffers. This can be handled much better with the
above change, since that will make sure that in fact everything is gone.

Best regards, Arjen

PS  Other than this, your patch makes a lot of sense, so I have no
objection to include it.
-- 
Eindhoven - The Netherlands
Key fingerprint - 66 4E 03 2C 9D B5 CB 9B  7A FE 7E C1 EE 88 BC 57




More information about the Nut-upsdev mailing list