[Nut-upsuser] Megatec serial UPS woes
Arjen de Korte
nut+users at de-korte.org
Thu Feb 7 12:55:19 UTC 2008
[...]
> I can now see what is in "buffer" and it looks like just a few leading
> characters might just be missing!
>
> So now I am at a loss of how to resolve this problem!
This could be due to some data remaining in the buffers. The megatec
driver doesn't flush the buffers, so if the UPS sends something it doesn't
expect, this may cause a problem in the synchronisation if a command is
not understood by the UPS.
> I'm not the greatest C programmer. I can read it and it makes sense but
> writing it is a real plod!
Add
ser_flush_io(upsfd);
on lines 258, 278, 309 and 333. Basically, this will flush whatever is in
the in- and output buffers before sending a command to the UPS. It is safe
(but not always needed) to do so before every ser_send_pace() function.
Best regards, Arjen
--
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-upsuser
mailing list