iloveallpi
Posts: 4
Joined: Thu Sep 05, 2019 11:15 am

Serial Console

Thu Sep 05, 2019 11:40 am

Hi all,

I have a device connected to a USB port -> a device the device says its connected to the end point using USB. There USB cable looks like a normal USB Mini A. No serial - USB type cable that I can detect.

The application on the PI reads a number of parameters from the external device but is not reading the correct parameters, I am trying to trouble shoot which data is incorrect or what the application is querying from the device. I know with a serial port you can see the RX and TXD communication between two devices connected via USB.

Is there a way to do this with a USB connection in PI and if so any pointers to where I could start. Thank you

Andyroo
Posts: 4467
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Serial Console

Thu Sep 05, 2019 12:36 pm

Most USB 'sniffers' cost most of an arm and a chunk of leg :(

You could try this https://github.com/usb-tools/USBProxy BUT it is rough and may not work for you (even the author admits it) and the other option (more complex hardware wise) is https://github.com/usb-tools/Facedancer

Without knowing any more about 'the device' its a bit hard to give anything concrete for debugging.
Need Pi spray - these things are breeding in my house...

iloveallpi
Posts: 4
Joined: Thu Sep 05, 2019 11:15 am

Re: Serial Console

Thu Sep 05, 2019 12:50 pm

Thank you - the device is an inverter that I built with a inverter part I bought from China and batteries I connected. They didnt provide any info but *some* api info however the API info doesn't really work wanted to see what I was sending and what it was returning.

User avatar
scruss
Posts: 2477
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Serial Console

Thu Sep 05, 2019 1:37 pm

Before plugging the device in, enter lsusb in the terminal. Plug it in, and enter lsusb again. Check for differences.

If it's a cheap USB serial device, it's likely to display as a QinHeng Electronics HL-340 USB-Serial adapter or similar. It won't need drivers. Check the end of the output of the dmesg command for any lines like

Code: Select all

ch341-uart converter now attached to ttyUSB0
That means your device is available on /dev/ttyUSB0. And yes, HL-340 ≠ ch341, but that's drivers for you
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

iloveallpi
Posts: 4
Joined: Thu Sep 05, 2019 11:15 am

Re: Serial Console

Thu Sep 05, 2019 2:08 pm

scruss wrote:
Thu Sep 05, 2019 1:37 pm
Before plugging the device in, enter lsusb in the terminal. Plug it in, and enter lsusb again. Check for differences.

If it's a cheap USB serial device, it's likely to display as a QinHeng Electronics HL-340 USB-Serial adapter or similar. It won't need drivers. Check the end of the output of the dmesg command for any lines like

Code: Select all

ch341-uart converter now attached to ttyUSB0
That means your device is available on /dev/ttyUSB0. And yes, HL-340 ≠ ch341, but that's drivers for you
Thank you very much so when I run

Code: Select all

dmesg | grep USB*
returns:
[ 0.796537] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
[ 0.827589] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
[ 0.835348] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.867194] hub 1-0:1.0: USB hub found
[ 0.981943] usbhid: USB HID core driver
[ 2.397397] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 2.662067] usb 1-1: New USB device found, idVendor=0424, idProduct=9514, bcdDevice= 2.00
[ 2.678460] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 2.724587] hub 1-1:1.0: USB hub found
[ 3.091770] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[ 3.232056] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00, bcdDevice= 2.00
[ 3.249010] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3.365352] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:3c:6e:7b
[ 3.481778] usb 1-1.2: new full-speed USB device number 4 using dwc_otg
[ 3.637797] usb 1-1.2: New USB device found, idVendor=0665, idProduct=5161, bcdDevice= 0.02
[ 3.668976] usb 1-1.2: New USB device strings: Mfr=3, Product=1, SerialNumber=0
[ 3.720825] hid-generic 0003:0665:5161.0001: hiddev96,hidraw0: USB HID v1.11 Device [STMicroelectronics HID in FS Mode] on usb-3f980000.usb-1.2/input0
[ 3.851803] usb 1-1.4: new low-speed USB device number 5 using dwc_otg
[ 4.019810] usb 1-1.4: New USB device found, idVendor=0c40, idProduct=8000, bcdDevice= 0.01
[ 4.038220] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 4.182618] hid-generic 0003:0C40:8000.0002: input,hidraw1: USB HID v1.11 Keyboard [ELMCU iPazzPort] on usb-3f980000.usb-1.4/input0
[ 4.356355] hid-generic 0003:0C40:8000.0003: input,hidraw2: USB HID v1.11 Mouse [ELMCU iPazzPort] on usb-3f980000.usb-1.4/input1
If I run the following there are interesting results but they seem to match above:

Code: Select all

dmesg | grep usb
[    0.071506] usbcore: registered new interface driver usbfs
[    0.071582] usbcore: registered new interface driver hub
[    0.071696] usbcore: registered new device driver usb
[    0.356435] usbcore: registered new interface driver lan78xx
[    0.356668] usbcore: registered new interface driver smsc95xx
[    0.384899] dwc_otg 3f980000.usb: base=(ptrval)
[    0.788720] dwc_otg 3f980000.usb: DWC OTG Controller
[    0.796537] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
[    0.804360] dwc_otg 3f980000.usb: irq 56, io mem 0x00000000
[    0.827589] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
[    0.835348] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.843120] usb usb1: Product: DWC OTG Controller
[    0.850844] usb usb1: Manufacturer: Linux 4.19.66-v7+ dwc_otg_hcd
[    0.858730] usb usb1: SerialNumber: 3f980000.usb
[    0.883583] usbcore: registered new interface driver usb-storage
[    0.974091] usbcore: registered new interface driver usbhid
[    0.981943] usbhid: USB HID core driver
[    2.397397] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    2.662067] usb 1-1: New USB device found, idVendor=0424, idProduct=9514, bcdDevice= 2.00
[    2.678460] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.091770] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    3.232056] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00, bcdDevice= 2.00
[    3.249010] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.365352] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:3c:6e:7b
[    3.481778] usb 1-1.2: new full-speed USB device number 4 using dwc_otg
[    3.637797] usb 1-1.2: New USB device found, idVendor=0665, idProduct=5161, bcdDevice= 0.02
[    3.668976] usb 1-1.2: New USB device strings: Mfr=3, Product=1, SerialNumber=0
[    3.668988] usb 1-1.2: Product: HID in FS Mode
[    3.698879] usb 1-1.2: Manufacturer: STMicroelectronics
[    3.720825] hid-generic 0003:0665:5161.0001: hiddev96,hidraw0: USB HID v1.11 Device [STMicroelectronics HID in FS Mode] on usb-3f980000.usb-1.2/input0
[    3.851803] usb 1-1.4: new low-speed USB device number 5 using dwc_otg
[    4.019810] usb 1-1.4: New USB device found, idVendor=0c40, idProduct=8000, bcdDevice= 0.01
[    4.038220] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    4.055437] usb 1-1.4: Product: iPazzPort
[    4.069279] usb 1-1.4: Manufacturer: ELMCU
[    4.098950] input: ELMCU iPazzPort as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:0C40:8000.0002/input/input0
[    4.182618] hid-generic 0003:0C40:8000.0002: input,hidraw1: USB HID v1.11 Keyboard [ELMCU iPazzPort] on usb-3f980000.usb-1.4/input0
[    4.222545] input: ELMCU iPazzPort Mouse as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.1/0003:0C40:8000.0003/input/input1
[    4.245778] input: ELMCU iPazzPort System Control as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.1/0003:0C40:8000.0003/input/input2
[    4.332131] input: ELMCU iPazzPort Consumer Control as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.1/0003:0C40:8000.0003/input/input3
[    4.356355] hid-generic 0003:0C40:8000.0003: input,hidraw2: USB HID v1.11 Mouse [ELMCU iPazzPort] on usb-3f980000.usb-1.4/input1
[    6.904231] usbcore: registered new interface driver brcmfmac
Then run

Code: Select all

lsusb

Code: Select all

Bus 001 Device 005: ID 0c40:8000
Bus 001 Device 004: ID 0665:5161 Cypress Semiconductor USB to Serial
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 hub
Now I am trying to marry the two On dmesg it shows almost all of them are allocated to SerialNumber=0 now I am not sure if that is the actual serial connection found on:

Code: Select all

lrwxrwxrwx 1 root root 5 Sep  5 12:49 /dev/serial0 -> ttyS0
lrwxrwxrwx 1 root root 7 Sep  5 12:49 /dev/serial1 -> ttyAMA0
My understanding is ttyAMA0 is the bluetooth device. If do a quick:

Code: Select all

:~ $ ls -lh /dev/ | grep usb*
drwxr-xr-x  3 root root          60 Jan  1  1970 bus
crw-------  1 root root     10, 203 Sep  5 12:49 cuse
crw-rw-rw-  1 root root     10, 229 Sep  5 12:50 fuse
drwxr-xr-x  2 root root          60 Nov  3  2016 usb
There is nothing around tty<USB_HERE>

However even if I do find the USB link how am I going to see what is being sent and received?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7288
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Serial Console

Thu Sep 05, 2019 2:17 pm

A quick Google on the string "usb 0665:5161" gives a number of hits, including several talking about the device being an inverter.
https://community.cypress.com/thread/30 ... 0&tstart=0
http://allican.be/blog/2017/01/28/rever ... l-usb.html

Linux seems to initially identify it as a Human Interface Device (HID), which is part of the issue. I'll leave you to read the rest of the links and do your own Googling.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

iloveallpi
Posts: 4
Joined: Thu Sep 05, 2019 11:15 am

Re: Serial Console

Thu Sep 05, 2019 2:20 pm

Thank you very much for your response. Wasn't sure what to google for i was going down the SMC and dwc_otg route but with no success. Let me go do some reading on those links thank you once again.

User avatar
scruss
Posts: 2477
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Serial Console

Thu Sep 05, 2019 6:36 pm

Looks like there isn't a kernel driver for this Cypress USB-Serial device, not at least for Raspberry Pi. There's a small change that the serial port is at /dev/ttyACM0 (check for ttyACM in dmesg output) but you may be out of luck with this one.

Though searching for the USB ID string in the forum turned this up: https://www.raspberrypi.org/forums/view ... 61#p499783
- this is for UPS monitoring, but if you can open the device as some kind of serial port, it's a start
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Return to “Interfacing (DSI, CSI, I2C, etc.)”