Solution to keeping Teensy 3.1 Serial connection open (reconnect) after a reboot

Status
Not open for further replies.

kig

Active member
Hey folks!

One of the inconveniences of working with Teensy 3.1 compared to Arduino for me, is the fact that after I reboot Teensy, my serial monitor connection has to be manually restarted, which is not the case with Arduino (where it continues to work after Arduino resets).

My development environment IDE is:
  • Eclipse MARS C/C++
  • Eclipse Arduino Plugin nightly build
  • Arduino 1.5.8Beta

I am not married to Eclipse window to show me Serial output, and would be happy with iTerm window, or a screen window connected directly to the Teeensy TTY, but whenever Teensdy reboots these devices go away, and the connection is no longer working. In Eclipse I have to remove it, and re-add it, and then I see all output again.

Does anyone have a way to monitor serial output, and have this monitor auto-reconnect as soon as the device is backup and available?

Thanks a million!
 
If you care to use WIndows and Atmel Studio+visual Micro (both free) to target Teensy 3, it supports multiple serial monitors that don't close their windows during download. They auto-reconnect after download, after power cycle.
Much better IDE.
 
Didn't someone recently post a program they wrote, which automatically reopens the serial port after programming?

I remember seeing it a while back, but I don't have the link handy. Does anyone know where it is?
 
Solution found: minicom!

Thanks everyone for great suggestions! I should have mentioned that am on Mac OS-X, so Windows only, or Linux only solutions are not for me.

But this discussion prompted me to look into two additional solutions, one of which yielded the exact result I was hoping to achieve!

  1. The first thing I tried is iTerm2 profile with screen. Screen is UNIX tool that creates virtual TTYs and allows the user to detach and re-attach to them later. You can connect screen to a serial port by passing it as a second argument on the command line, like this:

    Code:
    screen /dev/tty.usbmodem619321 -f 9600,cs8,-parenb,-cstopb,-hupcl

    (where /dev/tty.usbmodemNNNYYY is the serial/USB port created by Teensy). So I configure a terminal profile, that runs the above command upon start, and vola – I see the serial output. However, when I upload the sketch and Teensy reboots, screen (just like jante's Eclipse plugin) would not reconnect and just freeze.


  2. The second thing I tried is a well known free serial utility called "minicom". You can install it everywhere, and on Mac OS-X it is easiest to install with brew (http://brew.sh/).

    You run it like this:

    Code:
    minicom -D /dev/tty.usbmodem619321

    Minicom then automatically reconnects to the serial device, after it disappears and re-appears. Neat!

Thanks,
Konstantin
 
@kig,
I was wondering if some virtual port stuff would work as well. I have a program called com0com (Windows) that will allow connections to a port and creates its own port. I think it is also smart enough to know when a port is gone. So it can help recover from misbehaving (development) ports.

I also use minicom in linux. Very nice. Another toy you could play with is a network serial port server (ser2net or socat). So if you put your teensy on a networked device you can still read the serial messages. The client will need some RFC2217 driver to create a virtual serial port. I think socat allows the client to just read a TCP port to get the data.

Glad you figured a solution out and posted it here. I will definitely mess with this on my embedded linux machines.
 
Arduino's Serial Monitor sucks. I'm considering adopting some of these patches into the next Teensyduino installer.

If anyone has feedback or opinions, or other patches, now's the time to comment.


Leave serial monitor open during upload, reconnect when board comes online:

https://github.com/arduino/Arduino/pull/2180

https://github.com/arduino/Arduino/pull/1891


Or, reopen the serial monitor automatically after upload to board:

https://github.com/arduino/Arduino/pull/1613

https://github.com/arduino/Arduino/pull/1272


Send binary data

https://github.com/arduino/Arduino/pull/1276


Graphical display of numerical data

https://github.com/arduino/Arduino/pull/2177


Carriage return handling

https://github.com/arduino/Arduino/issues/1223


Excessive memory usage (no solution yet)

https://github.com/arduino/Arduino/issues/2233
 
Status
Not open for further replies.
Back
Top