web-dev-qa-db-ja.com

UPSの切断と再接続を繰り返し行う方法を教えてください。

USBでTripp Lite SMART1500LCDに接続された nut server を実行しています。デバイスが予期しない動作をしており、次のカーネルメッセージが表示されます。

user@Host:~ $ dmesg -T
[Wed Dec  4 13:24:24 2019] usb 1-1.5: USB disconnect, device number 91
[Wed Dec  4 13:24:25 2019] usb 1-1.5: new low-speed USB device number 92 using dwc_otg
[Wed Dec  4 13:24:25 2019] usb 1-1.5: New USB device found, idVendor=09ae, idProduct=2012, bcdDevice= 0.09
[Wed Dec  4 13:24:25 2019] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed Dec  4 13:24:25 2019] usb 1-1.5: Product: Tripp Lite UPS
[Wed Dec  4 13:24:25 2019] usb 1-1.5: Manufacturer: Tripp Lite
[Wed Dec  4 13:24:25 2019] hid-generic 0003:09AE:2012.15157: hiddev96,hidraw0: USB HID v1.10 Device [Tripp Lite  Tripp Lite UPS ] on usb-3f980000.usb-1.5/input0
[Wed Dec  4 13:24:39 2019] usb 1-1.5: USB disconnect, device number 92
[Wed Dec  4 13:24:40 2019] usb 1-1.5: new low-speed USB device number 93 using dwc_otg
[Wed Dec  4 13:24:40 2019] usb 1-1.5: New USB device found, idVendor=09ae, idProduct=2012, bcdDevice= 0.09
[Wed Dec  4 13:24:40 2019] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed Dec  4 13:24:40 2019] usb 1-1.5: Product: Tripp Lite UPS
[Wed Dec  4 13:24:40 2019] usb 1-1.5: Manufacturer: Tripp Lite
[Wed Dec  4 13:24:40 2019] hid-generic 0003:09AE:2012.15158: hiddev96,hidraw0: USB HID v1.10 Device [Tripp Lite  Tripp Lite UPS ] on usb-3f980000.usb-1.5/input0
[Wed Dec  4 13:24:54 2019] usb 1-1.5: USB disconnect, device number 93
[Wed Dec  4 13:24:55 2019] usb 1-1.5: new low-speed USB device number 94 using dwc_otg
[Wed Dec  4 13:24:55 2019] usb 1-1.5: New USB device found, idVendor=09ae, idProduct=2012, bcdDevice= 0.09
[Wed Dec  4 13:24:55 2019] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Wed Dec  4 13:24:55 2019] usb 1-1.5: Product: Tripp Lite UPS
[Wed Dec  4 13:24:55 2019] usb 1-1.5: Manufacturer: Tripp Lite
[Wed Dec  4 13:24:55 2019] hid-generic 0003:09AE:2012.15159: hiddev96,hidraw0: USB HID v1.10 Device [Tripp Lite  Tripp Lite UPS ] on usb-3f980000.usb-1.5/input0

UPSが再接続するたびにデバイス番号が増加するのを確認できます。

USBケーブルを交換して別のUSBポートを試しましたが、何も影響はありませんでした。

また、このエラーは22秒ごとに確認できます。

user@Host:~ $ Sudo systemctl status nut-driver
libusb_get_interrupt: error submitting URB: No such device

ドライバー設定:

# /etc/nut/ups.conf

[ups]
    driver = usbhid-ups
    port = auto
    desc = "Tripp Lite SMART1500LCD"
    vendorid = 09ae
    productid = 2012

ドライバーを手動で実行すると、UPS電力の概要が削除された出力になります。

user@Host:~ $ Sudo /lib/nut/usbhid-ups -DD -a ups
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
   0.000000     debug level is '2'
   0.001893     upsdrv_initups...
   0.003138     Checking device (09AE/2012) (001/106)
   0.016572     - VendorID: 09ae
   0.016729     - ProductID: 2012
   0.016847     - Manufacturer: Tripp Lite
   0.016963     - Product: Tripp Lite UPS
   0.017080     - Serial Number: unknown
   0.017196     - Bus: 001
   0.017314     - Device release number: 0009
   0.017430     Trying to match device
   0.017736     Device matches
   0.021374     HID descriptor length 662
   0.111731     Report Descriptor size = 662
   0.113247     Using subdriver: TrippLite HID 0.82
   0.113406     74 HID objects found
   0.174949     refresh_report_buffer: expected 5 bytes, but got 2 instead
   0.176949     refresh_report_buffer: expected 5 bytes, but got 2 instead
   0.188951     libusb_get_report: No error
   0.189102     Can't retrieve Report c1: Operation not permitted
   0.192948     libusb_get_report: No error
   0.193087     Can't retrieve Report 9a: Operation not permitted
   0.212168     Report descriptor retrieved (Reportlen = 662)
   0.212289     Found HID device
   0.212410     Detected a UPS: Tripp Lite /Tripp Lite UPS
   0.224046     find_nut_info: unknown info type: load.on.delay
   0.224178     find_nut_info: unknown info type: load.on.delay
   0.224333     upsdrv_initinfo...
   0.224474     upsdrv_updateinfo...
   0.253472     Got 1 HID objects...
   0.253783     Quick update...
   0.255248     dstate_init: sock /var/run/nut/usbhid-ups-ups open on fd 5
   0.255424     upsdrv_updateinfo...
   0.317491     Got 1 HID objects...
   0.317854     Quick update...
   2.257413     upsdrv_updateinfo...
   2.397465     Got 8 HID objects...
   2.398955     Quick update...
   4.258846     upsdrv_updateinfo...
   4.477447     Got 1 HID objects...
   4.477793     Quick update...
   6.260665     upsdrv_updateinfo...
   6.511167     libusb_get_interrupt: Connection timed out
   6.511357     Got 0 HID objects...
   6.511485     Quick update...
   8.262452     upsdrv_updateinfo...
   8.512913     libusb_get_interrupt: Connection timed out
   8.513114     Got 0 HID objects...
   8.513243     Quick update...
  10.264242     upsdrv_updateinfo...
  10.514689     libusb_get_interrupt: Connection timed out
  10.514874     Got 0 HID objects...
  10.515005     Quick update...
  12.266027     upsdrv_updateinfo...
  12.516595     libusb_get_interrupt: Connection timed out
  12.516789     Got 0 HID objects...
  12.516919     Quick update...
  14.267817     upsdrv_updateinfo...
  14.518422     libusb_get_interrupt: Connection timed out
  14.518605     Got 0 HID objects...
  14.518795     Quick update...
  16.269609     upsdrv_updateinfo...
  16.520214     libusb_get_interrupt: Connection timed out
  16.520317     Got 0 HID objects...
  16.520357     Quick update...
  18.271398     upsdrv_updateinfo...
  18.522023     libusb_get_interrupt: Connection timed out
  18.523212     Got 0 HID objects...
  18.524242     Quick update...
  20.273176     upsdrv_updateinfo...
  20.273330     libusb_get_interrupt: error submitting URB: No such device
  22.275225     upsdrv_updateinfo...
  22.275328     Got to reconnect!
  22.276163     Checking device (09AE/2012) (001/107)
  22.289479     - VendorID: 09ae
  22.289538     - ProductID: 2012
  22.289571     - Manufacturer: Tripp Lite
  22.289600     - Product: Tripp Lite UPS
  22.289629     - Serial Number: unknown
  22.289658     - Bus: 001
  22.289689     - Device release number: 0009
  22.289717     Trying to match device
  22.289791     Device matches
  22.289845     failed to claim USB device: could not claim interface 0: Device or resource busy
  22.291291     detached kernel driver from USB device...
  22.343257     Got 8 HID objects...
  22.345208     Quick update...
  24.277201     upsdrv_updateinfo...
  24.423254     Got 1 HID objects...
  24.423658     Quick update...
  26.279093     upsdrv_updateinfo...
  26.503245     Got 1 HID objects...
  26.503660     Quick update...
  28.281009     upsdrv_updateinfo...
  28.531523     libusb_get_interrupt: Connection timed out
  28.531717     Got 0 HID objects...
  28.531851     Quick update...
  30.282799     upsdrv_updateinfo...
  30.533325     libusb_get_interrupt: Connection timed out
  30.533523     Got 0 HID objects...
  30.533656     Quick update...
  32.284587     upsdrv_updateinfo...
  32.535043     libusb_get_interrupt: Connection timed out
  32.535232     Got 0 HID objects...
  32.535365     Full update...
  34.286352     upsdrv_updateinfo...
  34.536823     libusb_get_interrupt: Connection timed out
  34.537012     Got 0 HID objects...
  34.537147     Quick update...
  36.288143     upsdrv_updateinfo...
  36.538698     libusb_get_interrupt: Connection timed out
  36.538785     Got 0 HID objects...
  36.538828     Quick update...
  38.289947     upsdrv_updateinfo...
  38.540189     libusb_get_interrupt: Connection timed out
  38.540268     Got 0 HID objects...
  38.540290     Quick update...
  40.291736     upsdrv_updateinfo...
  40.542062     libusb_get_interrupt: Connection timed out
  40.542250     Got 0 HID objects...
  40.542385     Quick update...
  42.293530     upsdrv_updateinfo...
  42.293653     libusb_get_interrupt: error submitting URB: No such device
  44.295581     upsdrv_updateinfo...
  44.295686     Got to reconnect!
  44.296444     Checking device (09AE/2012) (001/108)
  44.308695     - VendorID: 09ae
  44.308755     - ProductID: 2012
  44.308786     - Manufacturer: Tripp Lite
  44.308815     - Product: Tripp Lite UPS
  44.308844     - Serial Number: unknown
  44.308872     - Bus: 001
  44.308901     - Device release number: 0009
  44.308929     Trying to match device
  44.309004     Device matches
  44.309057     failed to claim USB device: could not claim interface 0: Device or resource busy
  44.310209     detached kernel driver from USB device...
  44.354048     Got 1 HID objects...
  44.354356     Quick update...
  46.295743     upsdrv_updateinfo...
  46.434020     Got 1 HID objects...
  46.434127     Quick update...
  48.297648     upsdrv_updateinfo...
  48.514023     Got 8 HID objects...
  48.521768     Quick update...
  50.299455     upsdrv_updateinfo...
  50.550294     libusb_get_interrupt: Connection timed out
  50.551469     Got 0 HID objects...
  50.552351     Quick update...
  52.301216     upsdrv_updateinfo...
  52.551366     libusb_get_interrupt: Connection timed out
  52.551926     Got 0 HID objects...
  52.552348     Quick update...
  54.303005     upsdrv_updateinfo...
  54.554668     libusb_get_interrupt: Connection timed out
  54.555685     Got 0 HID objects...
  54.556498     Quick update...
  56.304783     upsdrv_updateinfo...
  56.556273     libusb_get_interrupt: Connection timed out
  56.557219     Got 0 HID objects...
  56.558026     Quick update...
  58.306562     upsdrv_updateinfo...
  58.557815     libusb_get_interrupt: Connection timed out
  58.558925     Got 0 HID objects...
  58.559737     Quick update...
  60.308337     upsdrv_updateinfo...
  60.559706     libusb_get_interrupt: Connection timed out
  60.560734     Got 0 HID objects...
  60.561550     Quick update...
  62.310103     upsdrv_updateinfo...
  62.561592     libusb_get_interrupt: Connection timed out
  62.562574     Got 0 HID objects...
  62.563361     Quick update...
  64.315103     upsdrv_updateinfo...
  64.316416     libusb_get_interrupt: error submitting URB: No such device
  66.317149     upsdrv_updateinfo...
  66.318179     Got to reconnect!
  66.319960     Checking device (09AE/2012) (001/109)
  66.331430     - VendorID: 09ae
  66.332261     - ProductID: 2012
  66.333030     - Manufacturer: Tripp Lite
  66.333799     - Product: Tripp Lite UPS
  66.334102     - Serial Number: unknown
  66.334415     - Bus: 001
  66.334543     - Device release number: 0009
  66.334665     Trying to match device
  66.335015     Device matches
  66.335322     failed to claim USB device: could not claim interface 0: Device or resource busy
  66.336510     detached kernel driver from USB device...
  66.378838     Got 1 HID objects...
  66.378973     Full update...

UPSが切断され続ける原因は何ですか?

2
Layne

この投稿 に触発されて、これまでの私の解決策は新しいudevルールを作成することでした:

# /etc/udev/rules.d/62-nut-usbups.rules

SUBSYSTEM!="usb", GOTO="nut-usbups_rules_end"

# TrippLite
#  e.g. TrippLite SMART1500LCD - usbhid-ups
ACTION=="add|change", SUBSYSTEM=="usb|usb_device", SUBSYSTEMS=="usb|usb_device", ATTR{idVendor}=="09ae", ATTR{idProduct}=="2012", MODE="664", GROUP="nut", RUN+="/sbin/upsdrvctl stop; /sbin/upsdrvctl start"

LABEL="nut-usbups_rules_end"

そしてpollintervalups.conf

# /etc/nut/ups.conf

pollinterval = 1

[ups]
    driver = usbhid-ups
    port = auto
    desc = "Tripp Lite SMART1500LCD"
    vendorid = 09ae
    productid = 2012

これまでの24時間、USBの切断やUPSの古いデータの警告はありませんでした。

そこにはもっと優雅な解決策があるかもしれませんが、これは今のところうまくいきます。

1
Layne