I am building a dumb terminal with an arduino and I can now see the output of serial connections. How do I get a login/shell?
I have tried screen /dev/ttyACM0 and that lets me type on the host computer and see the results on the terminal screen, but no shell. Using screen's :exec /bin/sh command starts a shell on that controlling xterm window but no longer outputs to the serial line. various attempts with agetty -L /dev/ttyACM0 9600 just sit and hang for a minute then exits without ever having put anything on the screen. I have tried cu -l /dev/ttyACM0 -s 9600 and again it hangs with no screen interaction. I have connected minicom to echo keys onto the arduino similar to screen but could not figure out how to get a shell. To be clear I am trying to access my main computer via the arduino based terminal, and I can not find a way to make my main computer offer a shell session to the arduino over a USB serial connection.
Asked
Active
Viewed 641 times
1
Gregory
- 53
- 4
-
`setsid getty -8 -L /dev/ttyACM0 9600 dumb` as root *should* work, provided that `9600` is the right speed (I'm getting this from my command line history, I'm not able to test). – Feb 10 '21 at 03:15
-
Hi, thanks for the fast answer. Unfortunately this didn't work either, No output shows up on the terminal, even trying vt100 instead of dumb and with and without the 8 bit part. Could it be that there is some signal to start the tty that the arduino is responsible for sending first? I am writing the arduino code myself so something like that could be missing if I didn't know about it but I can't find many resources on this. – Gregory Feb 10 '21 at 03:40
1 Answers
1
agetty seems to be fairly quiet about problems. I tried:
$ strace -e open agetty -I 'hello\012' -L /dev/ttyS0 9600
and it opened /dev//dev/ttyS0, which failed of course. It then hung around a few seconds and stopped.
The man page does say it wants a relative filename, so I then tried:
$ strace -e open agetty -I 'hello\012' -L ttyS0 9600
and it opened the right device this time, but failed again:
open("/dev/ttyS0", O_RDWR|O_NOCTTY|O_NONBLOCK) = -1 EACCES (Permission denied)
Finally, this worked and wrote something on the tty:
$ sudo strace -e open agetty -I 'hello\012' -L ttyS0 9600
You should also add the setsid mentioned in the comments.
You can also use systemd (if you have it) to start the login with:
$ sudo systemctl start serial-getty@ttyACM0
This runs agetty with --keep-baud 115200,38400,9600.
If you systemctl enable the service, it might start automatically whenever device ttyACM0 is created.
meuh
- 49,672
- 2
- 52
- 114
-
This got output on my screen, thank you so much. I appreciate you walking me through your process with strace as well, will be useful in the future. – Gregory Feb 10 '21 at 16:13