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.

PeterT
  • 103
  • 4
  • `/dev/tty1` is a console, not a serial port – Milliways Aug 25 '16 at 23:58
  • @Milliways /dev/facepalm. Thanks. Is there a /dev/* device attached to UART0? – PeterT Aug 25 '16 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 Aug 26 '16 at 00: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. – PeterT Aug 26 '16 at 00: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 Aug 26 '16 at 00:15
  • @milliways i found that i had to set "enable_uart=1" in config.txt. Not sure why that was off. – PeterT Aug 26 '16 at 00:28
  • See [How-do-i-make-serial-work-on-the-raspberry-pi3](http://raspberrypi.stackexchange.com/a/45571/8697) The Foundation seems to have decided (without telling anyone) to disable serial in kernel 4.4.9 – Milliways Aug 26 '16 at 01:22

1 Answers1

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.

goldilocks
  • 56,430
  • 17
  • 109
  • 217
  • 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. – PeterT Aug 26 '16 at 00:10
  • Note that the connection / cables are good because I can re-enable console login and it works fine. – PeterT Aug 26 '16 at 00:18
  • I add to set "enable_uart=1" in config.txt. Works now (with /dev/serial0) – PeterT Aug 26 '16 at 00: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 Aug 26 '16 at 00:30