[Nut-upsuser] MGE Nova 1100 using newhidups on netBSD 3.0

Nevil Thatcher NevilTh at nat.com.au
Mon Mar 6 07:43:23 UTC 2006


Hi Arnaud,

I have been playing around with the blocking at 'waiting for Notifications'

What I have found is that the process will block at the read() statement in
usb_interrupt_read() function in libusb (bsd.c).

It seems to sit here indefinitely (have left it overnight).
By unplugging/replugging the USB cable causes an error return from the
read() statement, thus the function returns and status's are then received
via the usb_control_msgs's. Subsequent calls's to usb_interrupt_read then
also fail with the message "Failedto read form interrupt endpoint"

In the call to usb_interrupt_read there is a timeout argument (5 sec). I am
not sure if this means that the read is supposed to timeout after 5 sec if
no data but this is not happenening.

To work around this (and I am not sure if this is correct) I have added the
O_NONBLOCK flag to the call to open(). This means that netBSD will not block
on the read() but return directly if there is no data (the OS provides some
buffering).

The log segment below shows this behaviour


usb_control_msg: 4 161 1 770 0 0x5160ac 8 4000
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
dstate_init: sock /var/db/nut/newhidups-auto open on fd 5
upsdrv_updateinfo...
Waiting for notifications...
usb_interrupt_read 4 129 0x7f7fffffeb10 20 5000
usb_interrupt_read Calling read
usb_interrupt_read result=-1, size=20, retrieved=0
USB error: error reading from interrupt endpoint /dev/ugen1.01: Resource
temporarily unavailable
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up ACPresent
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 1

hu_find_infoval: found online (value: 1)

process_status_info: online
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up Discharging
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 0

hu_find_infoval: found !dischrg (value: 0)

process_status_info: !dischrg
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up Charging
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 1

hu_find_infoval: found chrg (value: 1)

process_status_info: chrg
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up ShutdownImminent
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 0

hu_find_infoval: found !shutdownimm (value: 0)

process_status_info: !shutdownimm
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up BelowRemainingCapacityLimit
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 0

hu_find_infoval: found !lowbatt (value: 0)

process_status_info: !lowbatt
new connection on fd 7
upsdrv_updateinfo...
Waiting for notifications...
usb_interrupt_read 4 129 0x7f7fffffeb10 20 5000
usb_interrupt_read Calling read
usb_interrupt_read result=-1, size=20, retrieved=0
USB error: error reading from interrupt endpoint /dev/ugen1.01: Resource
temporarily unavailable
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up ACPresent
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 1

hu_find_infoval: found online (value: 1)

process_status_info: online
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up Discharging
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
hu_find_infoval: searching for value = 0

hu_find_infoval: found !dischrg (value: 0)


If I remove the O_NONBLOCK flag from open()

process_status_info: !off
entering string_to_path()
Looking up UPS
Looking up PowerConverter
Looking up Output
Looking up Voltage
usb_control_msg: 4 161 1 782 0 0x5160ac 8 4000
Report : (8 bytes) => 0E E6 25 01 00 80 FF FF
entering string_to_path()
Looking up UPS
Looking up PowerSummary
Looking up PresentStatus
Looking up ACPresent
usb_control_msg: 4 161 1 770 0 0x5160ac 8 4000
Report : (8 bytes) => 02 23 00 01 00 80 FF FF
dstate_init: sock /var/db/nut/newhidups-auto open on fd 5
upsdrv_updateinfo...
Waiting for notifications...
usb_interrupt_read 4 129 0x7f7fffffeb10 20 5000
usb_interrupt_read Calling read

And it just sits here indefinitely.

I am not convinced that this is necessarily the correct thing to do , but at
least it gives me a working configuration.
 
Regards

Nevil 
-----Original Message-----
From: Arnaud Quette [mailto:aquette.dev at gmail.com] 
Sent: Friday, 3 March 2006 11:30 PM
To: Nevil Thatcher
Cc: Thierry Thomas; nut-upsuser at lists.alioth.debian.org
Subject: Re: [Nut-upsuser] MGE Nova 1100 using newhidups on netBSD 3.0

2006/3/3, Nevil Thatcher <NevilTh at nat.com.au>:
> Hi Arnaud,
>
> Have attached the debug log to this message.
> ...

the interrupt pipe problem is confirmed:
>>...
>>Waiting for notifications...
>>USB error: error reading from interrupt endpoint /dev/ugen1.01:
Interrupted system call
>>...

But I don't know why.
FYI, newhidups polls the UPS each pollfreq (default to 30 sec), and
wait for interrupt meanwhile... The problem is that upsd declares an
UPS stale after 15 sec.

So, as a workaround while waiting to sort out the interrupt problem,
try to lower pollfreq to 5 or 10 sec. Thanks to then report back the
results...

> Thanks for your assistance.

no problem, that's part of MGE support of the alternative OSs...
http://opensource.mgeups.com/contrib.htm

Moreover, I'm pleased to have somebody to work with on BSD ;-)

> Will forward to libusb maintainer as suggested.

thanks.
Arnaud




More information about the Nut-upsuser mailing list