C to read and write USB
by stockton from LinuxQuestions.org on (#4Y47Q)
I am currently writing some code to send a command to the inverter on my solar system and retrieve the current status.
Looking at wiringpi examples and using part of those examples I am attempting to understand how "/dev/hidraw0" relates to the two USB devices I have connected to that machine.
Those devices are 1) a WiFi connection and 2) a serial connection to the inverter.
How do I ascertain which is /dev/hidraw0 and what the other is called.
Code:lsusb
Bus 001 Device 005: ID 0665:5161 Cypress Semiconductor USB to Serial
Bus 001 Device 004: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubbut this tells me nothing that I understand about "/dev/hidraw0"
when I tail -f /var/log/messages and unplug and replug the inverter I get
Code:Jan 19 09:39:16 RPiDoor kernel: [ 8834.944711] usb 1-1.3: USB disconnect, device number 5
Jan 19 09:39:32 RPiDoor kernel: [ 8851.110475] usb 1-1.3: new low-speed USB device number 6 using dwc_otg
Jan 19 09:39:32 RPiDoor kernel: [ 8851.278926] usb 1-1.3: New USB device found, idVendor=0665, idProduct=5161, bcdDevice= 0.02
Jan 19 09:39:32 RPiDoor kernel: [ 8851.278948] usb 1-1.3: New USB device strings: Mfr=3, Product=1, SerialNumber=0
Jan 19 09:39:32 RPiDoor kernel: [ 8851.297871] hid-generic 0003:0665:5161.0002: hiddev96,hidraw0: USB HID v1.11 Device [HID 0665:5161] on usb-3f980000.usb-1.3/input0
Jan 19 09:39:32 RPiDoor mtp-probe: checking bus 1, device 6: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Jan 19 09:39:32 RPiDoor mtp-probe: bus: 1, device: 6 was not an MTP devicewhich tells me that device 5(which is now 6) is the inverter but again nothing about which device my program shouls be opening, writing to and reading from.
I have attempted using /dev/hidraw0 as well as /dev/hiddev96, as listed above in messages, but with no success.


Looking at wiringpi examples and using part of those examples I am attempting to understand how "/dev/hidraw0" relates to the two USB devices I have connected to that machine.
Those devices are 1) a WiFi connection and 2) a serial connection to the inverter.
How do I ascertain which is /dev/hidraw0 and what the other is called.
Code:lsusb
Bus 001 Device 005: ID 0665:5161 Cypress Semiconductor USB to Serial
Bus 001 Device 004: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubbut this tells me nothing that I understand about "/dev/hidraw0"
when I tail -f /var/log/messages and unplug and replug the inverter I get
Code:Jan 19 09:39:16 RPiDoor kernel: [ 8834.944711] usb 1-1.3: USB disconnect, device number 5
Jan 19 09:39:32 RPiDoor kernel: [ 8851.110475] usb 1-1.3: new low-speed USB device number 6 using dwc_otg
Jan 19 09:39:32 RPiDoor kernel: [ 8851.278926] usb 1-1.3: New USB device found, idVendor=0665, idProduct=5161, bcdDevice= 0.02
Jan 19 09:39:32 RPiDoor kernel: [ 8851.278948] usb 1-1.3: New USB device strings: Mfr=3, Product=1, SerialNumber=0
Jan 19 09:39:32 RPiDoor kernel: [ 8851.297871] hid-generic 0003:0665:5161.0002: hiddev96,hidraw0: USB HID v1.11 Device [HID 0665:5161] on usb-3f980000.usb-1.3/input0
Jan 19 09:39:32 RPiDoor mtp-probe: checking bus 1, device 6: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Jan 19 09:39:32 RPiDoor mtp-probe: bus: 1, device: 6 was not an MTP devicewhich tells me that device 5(which is now 6) is the inverter but again nothing about which device my program shouls be opening, writing to and reading from.
I have attempted using /dev/hidraw0 as well as /dev/hiddev96, as listed above in messages, but with no success.