[Nut-upsdev] [nut-commits] svn commit r1136 - in trunk: . drivers

Arjen de Korte nut+devel at de-korte.org
Wed Oct 3 11:09:25 UTC 2007


> Does it really complicate subdrivers? I think not.

Yes. Until this change, the subdrivers had a really clean, simple
interface - reading and writing. You added another function to the agiler
subdriver, which largely duplicates an existing one and isn't required at
this (low) level.

After Carlos has added the ser_flush_io() function to the megatec.c
subdriver, we will probably need the following:

int ser_flush_io(int upsfd)
{
	int	i = 0;

	while (subdriver->get_data(buf, buflen) > 0) {
		if (++i > 10) {
			break;
		}
	}
	return 0;
}

Although this will be basically a no-op for the Krauler subdriver, this is
certainly not worth an additional subdriver function.

> I don't know whether flushing input buffers is terribly necessary in
> agiler subdriver, but it's definitely not needed by krauler. And this
> has nothing to do with megatec driver, it is an agiler device-specific
> thing.

I know.

> The benefit? I don't get messages like "get_data_krauler: no command set"
> while not breaking agiler subdriver which I cannot test. What else can I
> do to keep it working? I just dont't like hacking it completely without
> testing.

Don't mistake upsdebugx() messages for error messages. It is telling you
just that no command is set. This is *not* an error and therefor doesn't
need fixing. It is perfectly OK to call the get_data_krauler() function
without setting a command (robustness). Users will never see the output
from the debugging command.

> Btw, did you received any response from the owners of agiler devices?

Yes. The updated agiler subdriver works as expected and is now also
included in nut-2.2.1-pre.

> I think you've missed Eric Raymond in the list. I'll contact him.

Fine.

[...]

> Yes, I know about this. Ok, let's do it.
> I plan to call reconnection function (which will try to reconnect once)
> in ser_send_pace() and ser_get_line() if set/get_data_* reports that
> connection is lost. Is this ok?

It depends on how you do this, but essentially this is what needs to be
done. Note that there are quite a number of error codes that need to be
dealt with:

	-EBUSY (other driver tried to claim this interface)
	-EPERM
	-EPIPE
	-ENODEV
	-EACCES
	-EIO
	-ENOENT

Best regards, Arjen




More information about the Nut-upsdev mailing list