0

I'm trying to run a process on my RPi that acts as a SerialPort echo: that is, simply log to a file every character it receives.

My RPi is connected to my Mac (or PC) by a USB>TTL cable. I confirmed the cable works by logging into the console via UART0, by using screen /dev/cu.usbserial on my Mac.

The OS is Raspbian Jessie and I have disabled serial login using raspi-config and removed the console arguments from /boot/cmdline.txt. This works since I can no longer log in via screen or putty.

I figured before writing the Python/Perl/Node code to act as the echo, I'd test out the connection first using screen.

The problem is, I assumed I could simply run screen /dev/tty1 9600 on my RPi, and then run screen /dev/cu.usbserial 9600 on my Mac (or COMx/9600 on PuTTY on my PC) and then both terminals would just echo to each other.

Both instances of screen start (the ports are open), but neither one is echoing to the other.

What am I missing in terms of configuration on the PI, or misunderstanding about serial/UART communication?

Thanks in advance, PT

SOLUTION: Milliways and goldilocks pointed out that /dev/tty1 is a terminal. Once that was cleared up I saw that serial0 is a link to ttyAMA0. However, neither of those worked. I had to go into /boot/config.txt and fix this "enable_uart=0" to "enable_uart=1". Now screen to screen works with /dev/serial0.

7
  • /dev/tty1 is a console, not a serial port
    – Milliways
    Commented Aug 25, 2016 at 23:58
  • @Milliways /dev/facepalm. Thanks. Is there a /dev/* device attached to UART0?
    – Freeman
    Commented Aug 25, 2016 at 23:59
  • try dev/serial0 depends on which OS and which Pi. The Foundation has been fiddling with firmware, and disabling serial by default on some e.g. Pi3
    – Milliways
    Commented Aug 26, 2016 at 0:03
  • @Milliways I tried serial0 and ttyAMA0 (also tried using a perl Device::SerialPort object instead of screen. No luck. Thanks tho. If you can think of anything else I'm all ears.
    – Freeman
    Commented Aug 26, 2016 at 0:06
  • If dev/serial0 exists then your problem is probably the connections. I have never used screen on the Pi - it doesn't seem to exist on my Pi.
    – Milliways
    Commented Aug 26, 2016 at 0:15

1 Answer 1

1

I think your problem is on the Pi /dev/tty1 isn't a UART anything.

TTY is a generic term for a text based terminal interface. A serial console is a sort of subcategory of that, but not all ttys are serial consoles. The OS will normally run 6 such virtual terminals ("virtual" by the fact that they aren't actually hardware artifacts) which you can access locally using AltCtrlF-[1-6]. You can run screen within such a terminal, because screen isn't exclusively for the purpose of making remote serial connections.

On the pi, both /dev/tty1 and a UART interface (such as /dev/ttyAMA0) are specified in cmdline.txt for use as outputs for console messages from the kernel, which create some confusion. The UART allows for the messages to be read via a serial connection; tty1 means they will also show up on the primary hardware display.

4
  • Thanks! Milliways above caught that too. I tried using ttyAMA0 and serial0 but I still wasn't arriving at the expected behavior. Is my idea of using screen<>screen sound to begin with? Wondering if that my be my problem.
    – Freeman
    Commented Aug 26, 2016 at 0:10
  • Note that the connection / cables are good because I can re-enable console login and it works fine.
    – Freeman
    Commented Aug 26, 2016 at 0:18
  • I add to set "enable_uart=1" in config.txt. Works now (with /dev/serial0)
    – Freeman
    Commented Aug 26, 2016 at 0:28
  • :) Was just about to mention serial0 -- it's now being used as a symbolic link since the Pi 3's setup complicated all this.
    – goldilocks
    Commented Aug 26, 2016 at 0:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.