7

I'm trying to connect to a Khepera robot using serial interface (running Scientific Linux 6.1) I used the command screen /dev/ttyS0 to communicate which worked OK, but then I wanted to close it and use MATLAB, but I found no way to close that session, so I just clicked X on the terminal window running screen.

Now my ttyS0 port cannot be opened. Both MATLAB and screen says that it cannot open that port.

How can I reset the ttyS0 port? I mean one choice is to restart the computer. But how to do it without restarting?

What is the proper way to terminate a serial communication?

Also, what does the following command do? I've found it with Google and run it but nothing happened. Did it do anything bad what I need to fix?

/sbin/agetty -L -f /etc/issueserial 9600 ttyS0 vt100
Hennes
  • 65,804
  • 7
  • 115
  • 169
hyperknot
  • 952

2 Answers2

5

You can issue the command screen -ls to get a status of all current screen sessions. Then use the screen -r option to "reattach" to the disconnected screen session and the -X option to kill the session.

Here's an example shell session. I'm using the -d -m options to start the screen session in "detached" mode (in the background) to simulate closing the session using the X on the terminal window running screen. The 5207 from screen's -ls output is the process ID number, which will be used to "reattach" to that specific screen session.

$ screen -d -m /dev/ttyS0
$ screen -ls
There is a screen on:
    5207..host  (10/04/2011 10:16:50 AM)    (Detached)
1 Socket in /var/run/screen/S-user.

$ screen -r 5207 -X kill
$ screen -ls 
No Sockets found in /var/run/screen/S-user.

$ 
Go Dan
  • 1,195
1

What is the proper way to terminate a serial communication?

From a programming point of view – simply close() the opened file descriptor. Exiting the program does that automatically. However, you did not exit Screen.

One of the most commonly used GNU Screen features is the ability to detach and reattach to sessions. When you closed the window, the "server" part of Screen remained running, and you can reattach to it with screen -r.

Use C-a, k to actually kill a Screen window.

Also, what does the following command do? I've found it with Google and run it but nothing happened. Did it do anything bad what I need to fix?

/sbin/agetty -L -f /etc/issueserial 9600 ttyS0 vt100

agetty is a TTY monitor program. Its job is to reinitialize the terminal device's configuration and to display a login prompt; you can see it in action by switching to the console login prompts at tty1...tty6. 1

In this case, when you started agetty on your end, it sent a login prompt2 to the robot, which probably discarded it as garbage. It is normally harmless, unless the robot somehow interprets "login:" as "initiate world takeover". The configuration done by agetty shouldn't break anything either.


1 Note that getty does not handle actual logins – it just asks for the user name. Once you enter it, agetty starts /sbin/login to perform the login process.

2 It would also have sent the contents of /etc/issueserial text file, but since you found the command on Google, it's most likely that you don't even have that file.

grawity
  • 501,077