0

I have one development board attached via USB to my Linux machine. For the sake of debugging I want to monitor the serial port. My problem is that I don't know how understand which serial port should I monitor.

When running lsusb in the terminal, I see

Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0461:4e1d Primax Electronics, Ltd 
Bus 001 Device 004: ID 0d28:0204 NXP LPC1768
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 046d:c019 Logitech, Inc. Optical Tilt Wheel Mouse
Bus 003 Device 002: ID 03f0:c511 Hewlett-Packard 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The device I am interested in is the NXP LPC1768,so it is "attached" to Bus01, device 04. However, which port should I monitor to read the serial port of that NXP LPC1768 device?

When running dmesg | grep tty, I see

[    0.000000] console [tty0] enabled
[   97.204143] cdc_acm 1-1.2:1.1: ttyACM0: USB ACM device

but this still doesn't give me that information I am looking for.

When I used Windows, I would go to the Device manager, Ports tab, see the COM port associated to the device and use software like Putty for monitoring the serial port.

Do you how can I do that in Linux?

I'm sorry if this question has been asked before but I've searched for an hour and still couldn't find the answer..

4
  • "I have one development board ..." -- Can you be more specific? "When running lsusb in the terminal..." -- You mean on your Linux PC? If this "one development board" is recognized as a USB gadget by your Linux PC, then there will be syslog entries. Disconnect the board, wait 15 seconds, then connect the board. Use the dmesg command to review the end of the syslog. If the board does connect as a serial device (e.g. /dev/ttyACM0 ), then you can use a terminal emulator program, such as minicom or puTTY. Commented Sep 22, 2016 at 8:34
  • I am using the BBC micro:bit as development board. Yes, the I am running lsusb and dmesg | grep tty on my Linux machine and not on the dev board. What message should I look into when running the dmesg command? Can you give me a specific example? Many thanks Commented Sep 22, 2016 at 11:27
  • Read the directory in /sys/class/tty. Each symbolic link there is a tty and points to the real sysfs device, that should be easy to recognize. Commented Sep 22, 2016 at 19:47
  • Which tty should I be reading? Also what do you mean by "read"? Is it to do a cat command on every single tty that is available? Thanks Commented Sep 22, 2016 at 20:41

1 Answer 1

1

My problem is that I don't know how understand which serial port should I monitor.

If this "one development board" is recognized as a USB gadget by your Linux PC, then there will be syslog entries.
Disconnect the board, wait 15 seconds, then connect the board.
Use the commands dmesg | tail to review the end of the syslog.
You might get something like this:

$ dmesg | tail
[ 2094.481014] usb 1-1: Product: EDBG CMSIS-DAP
[ 2094.481019] usb 1-1: Manufacturer: Atmel Corp.
[ 2094.481023] usb 1-1: SerialNumber: ATML0000001351195199
[ 2095.033449] hidraw: raw HID events driver (C) Jiri Kosina
[ 2095.038550] cdc_acm 1-1:1.1: ttyACM0: USB ACM device
[ 2095.038874] usbcore: registered new interface driver cdc_acm
[ 2095.038877] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[ 2095.112372] usbcore: registered new interface driver usbhid
[ 2095.112376] usbhid: USB HID core driver
[ 2095.237686] hid-generic 0003:03EB:2111.0001: hiddev0,hidraw0: USB HID v1.11 Device [Atmel Corp. EDBG CMSIS-DAP] on usb-0000:00:1d.7-1/input0
$ 

The first three lines shown relate to the completion of the low-level USB protocol.
The remaining seven lines are the USB device installation.
It's the fifth line that's salient, as that indicates that the attached board implements the USB CDC (Communications Device Class) ACM (Abstract Control Model) to emulate a serial port.

If the SBC does connect as a serial device (e.g. /dev/ttyACM0 ), then you can use a terminal emulator program, such as minicom or puTTY.

$ minicom --device /dev/ttyACM0

When running dmesg | grep tty, I see

 [    0.000000] console [tty0] enabled  
 [   97.204143] cdc_acm 1-1.2:1.1: ttyACM0: USB ACM device  

but this still doesn't give me that information I am looking for.

Actually that is the information that you need (assuming this device is for your SBC).


ADDENDUM

When I tried to access it with putty, I got the error message "Unable to open connection Unable to access serial port".

Presumably the device node ttyACM is owned by root and the group dialout:

$ ls -l /dev/ttyACM*
crw-rw---- 1 root dialout 166, 0 Sep 22 15:54 /dev/ttyACM0

Verify that your username belongs to the dialout group (so that you have access to this device).

$ whoami
george

$ grep dialout </etc/group
dialout:x:20:george

If your username is not a member of the dialout group, then use the administrative (or system tool) program of your Linux distro to add your username to dialout. Or see https://unix.stackexchange.com/questions/14354/read-write-to-a-serial-port-without-root or https://askubuntu.com/questions/112568/how-do-i-allow-a-non-default-user-to-use-serial-device-ttyusb0

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks sawdust. For some reason I don't see anything appearing in the console when using [$ minicom --device /dev/ttyACM0] and I am sure my application prints messages on the serial port. Is there another way to access the ttyACM0? When I tried to access it with putty, I got the error message "Unable to open connection Unable to access serial port".
Sounds like a permissions issue. See above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.