MindFreeze / hassio-axpert

Hassio addon to monitor voltronic axpert inverters through USB
28 stars 10 forks source link

hidraw0 not correct one. #9

Open Saentist opened 2 years ago

Saentist commented 2 years ago

hidraw0 is not correct device all time. What happens if PC used have Touch screen? What if have also attached UPS?

# ll /dev/hidraw*
crw-rw-rw- 1 root plugdev 240, 0 юли 30 23:58 /dev/hidraw0
crw-rw-rw- 1 root plugdev 240, 1 юли 30 23:58 /dev/hidraw1
crw-rw-rw- 1 root plugdev 240, 2 юли 30 23:58 /dev/hidraw2

what is what

#!/bin/bash

FILES=/dev/hidraw*
for f in $FILES
do
  FILE=${f##*/}
  DEVICE="$(cat /sys/class/hidraw/${FILE}/device/uevent | grep HID_NAME | cut -d '=' -f2)"
  printf "%s \t %s\n" $FILE "$DEVICE"
done

in case

# ./hid.sh
hidraw0          American Power Conversion  Smart-UPS C 1500 FW:UPS 10.0 / ID
hidraw1          STMicroelectronics HID in FS Mode
hidraw2          HID TOUCH HID Touch Panel

# lsusb
Bus 001 Device 007: ID 13d3:5129 IMC Networks USB2.0 UVC VGA WebCam
Bus 001 Device 005: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader
Bus 001 Device 002: ID 04ca:f001 Lite-On Technology Corp. TvTUNER
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 1bfd:1688 TouchPack Resistive Touch Screen
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0665:5161 Cypress Semiconductor USB to Serial  <<< INVERTER
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 051d:0003 American Power Conversion UPS
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Is it possible to have some automation for this cases?

MindFreeze commented 2 years ago

There are links to devices based on there IDs somewhere under /dev/usb . You can fork the repo and change the config to use that.

Saentist commented 2 years ago

If is so simple this will be PR not FR

https://matoking.com/blog/2015/12/29/writing-touchscreen-driver-python/ some sources how to detect something with python attached to hidraw /някой не е прочел последния ред ;) /