Linux sees nothing from teensy 3.1 serial port

Status
Not open for further replies.

pb5

New member
I have programmed my teensy 3.1 board via my MacBook Pro, and all works great. My program displays a line of text every few seconds. However, when I plug it into my Linux box, the device is recognized, but when I try to read from the device, nothing. I have verified that /dev/ttyACM1 is the teensy (I unplug the teensy and it goes away). I have verified the teensy is getting power (my program blinks the led as well). Needless to say, I am using the exact same cable for both the Mac and the Linux box.

One difference is my Mac has USB 2.0 ports and my Linux box only has USB 3.1 Gen 1 and Gen 2 ports. Is there a known issue with using USB 3.x ports with the teensy? I have been searching the net but have not found anything that sheds light on this specifically problem.

Normally I would just cat /dev/ttyACM1 to watch the output. I have also used a serial port program I wrote for other devices, it can successfully communicate with my /dev/ttyACM0 device (a fan controller hub), so I am pretty darn sure it isn't that I am just not reading it correctly.

Below I have a bunch of data, including what "lsusb -v" sees for the device, and the terminal settings for both the Mac (it works) and Linux (it doesn't). Any help would be appreciated.

Thanks,

-Paul

Using lsusb I see the line:

Code:
Bus 001 Device 023: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial

I did notice the teensy advertises bmAttributes as 0xC0, which mean it is self powered. I modified the usb driver to report 0x80, no change.

The relevant output from lsusb -v is:

Code:
Bus 001 Device 023: ID 16c0:0483 Van Ooijen Technische Informatica Teensyduino Serial
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.01
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x16c0 Van Ooijen Technische Informatica
  idProduct          0x0483 Teensyduino Serial
  bcdDevice            2.00
  iManufacturer           1 Teensyduino
  iProduct                2 USB Serial
  iSerial                 3 627840
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           67
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      1 AT-commands (v.25ter)
      iInterface              0 
      CDC Header:
        bcdCDC               1.10
      CDC Call Management:
        bmCapabilities       0x01
          call management
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x06
          sends break
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              64
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)

On my Mac I have the following settings:

Code:
Mac$ sudo stty -af /dev/cu.usbmodem627841
speed 9600 baud; 0 rows; 0 columns;
lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl
	-echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin
	-nokerninfo -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel -iutf8
	-ignbrk -brkint -inpck -ignpar -parmrk
oflags: -opost -onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb crtscts -dsrflow
	-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
	eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
	min = 0; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
	stop = ^S; susp = ^Z; time = 0; werase = ^W;
On Linux my settings are:

Code:
Linux$ stty -aF /dev/ttyACM1
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 0; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
(Even though it shouldn't make a difference, I have tried with hupcl on and off).
Code:
 
have you set the udev rule ? https://www.pjrc.com/teensy/td_download.html
what version of linux?

Thank you, manitou,

Ubuntu 16.04.1.

I was not using the udev rule as I would just chmod the device (or run as root) and didn't mind the extra time it took to identify the device while the modem manager was interrogating it. I have since removed the modem manager. I have now tried with and without the udev rule and the behavior is the same (I am using a udev rule to automatically link /dev/ttyACM? to /dev/teensy, however, so it was useful to add).

The one interesting change in behavior, now that I don't have to wait for the modem manager, is that I actually do get about 5 or 10 seconds of buffered output (under a hundred bytes), and maybe a few more lines of newly generate output (about 10 characters per line), when first plugging in the device. After that it is crickets all the way. I have used lsof to verify that nothing else had the device open (at least not obviously), so I am puzzled as to why it stops receiving data. I have tried with and without crtscts, always keeping clocal enabled. With the modem manager I did not see those first lines of data as I assume it was consuming them. (I even used dd if=/dev/teensy bs=1 to force single byte reads, to no avail). It sure feels like some sort of flow control issue, but it only has a problem on Linux (not sure if USB 3 is the problem or not).

As I mentioned, I am not having any issues with reading a different USB Serial based device.

Thank you for any thoughts or suggestions,

-Paul
 
Interesting update. I used the usbreset program from commands-to-simulate-removing-and-re-inserting-a-usb-peripheral (I am remote from the box so wanted to virtually unplug and plug it in) and now I am getting continuing output.

I am not sure why that unwedged it, but it has been outputting for a minute now, so it looks good. I am still puzzled as to why I need to reset the USB Bus, however.

-Paul
 
I was not using the udev rule as I would just chmod the device (or run as root) and didn't mind the extra time it took to identify the device while the modem manager was interrogating it. I have since removed the modem manager. I have now tried with and without the udev rule and the behavior is the same (I am using a udev rule to automatically link /dev/ttyACM? to /dev/teensy, however, so it was useful to add).

Even if you get serial working, Teensy does uploading using HID protocol, not serial. The udev rules cover both HID & serial.
 
I'm seeing a problem similar to this, though with Teensy LC, not 3.1. I'm using a Raspberry Pi 3B+ with Raspbian 9.8. The Teensy LC has been pre-programmed on a different computer, as I have not installed Teensyduino on the Pi. I have installed the udev rule. I do not have modemmanager.

If I plug in the USB cable and type "cat /dev/ttyACM0", I get the first dozen lines of output from the Teensy, and then it stops. I have to use CTRL+C to get back to the command prompt. If I repeat the command, it hangs immediately, with no output. If I use the usbreset utility from above, and then try to cat the serial port, I get two or three more lines of output before it hangs again. I can reproduce these steps every time I unplug and replug the USB cable.

On Windows, which I used to program the Teensy, I can view the serial output just fine with the serial monitor.

Any ideas what could be going wrong, here?
 
The "cat" command isn't a valid way to view ongoing (but intermittent) serial data. Use the Arduino Serial Monitor, or a program like minicom or seyon.
 
Minicom doesn't seem to work any better. So far, I've only able to get two lines of output before it stopped. Since then, I haven't been able to get any output at all, even after unplugging and replugging the USB cable.

I don't think Arduino Serial Monitor is an option, as this is a headless Pi. Likewise, I don't think seyon is an option, either.
 
I don't think Arduino Serial Monitor is an option, as this is a headless Pi.

Maybe for the sake of testing, you could temporarily connect a monitor, keyboard and mouse, and then run the Arduino IDE to see whether the Arduino Serial Monitor works?
 
Maybe for the sake of testing, you could temporarily connect a monitor, keyboard and mouse, and then run the Arduino IDE to see whether the Arduino Serial Monitor works?

Ok, for the sake of testing, I installed the desktop environment and a VNC server, and was able to run the Arduino IDE that way. (That required hundreds of packages... which is why I was reluctant!) Anyway, the Arduino serial monitor had the same problem. But...

Those having issues getting serial from teensy Try suggestion from post 18 in this thread

https://forum.pjrc.com/threads/5573...-to-Raspberry-Pi-with-USB?p=203769#post203769

That worked! (Correct link: https://forum.pjrc.com/threads/5573...ry-Pi-with-USB?p=203721&viewfull=1#post203721)

For some reason, waiting on Serial did the trick. But what's going on here? On Windows, I didn't need to do this, but on Raspbian, I did.
 
Status
Not open for further replies.
Back
Top