Having problems to connect to a serial port? There might be other process already using it. Let us check it (using "list open files" command lsof):
$ sudo lsof /dev/ttyS0
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
minicom 16737 ubuntu 3u CHR 4,64 0t0 1145 /dev/ttyS0
That's it.
If the output is empty, there is either no process using your serial port, or you mistyped something :-(
A bit more carefully: Start with a check, what serial ports are available in the system (not all of them are real):
$ sudo ls -1 /dev/ttyS*
/dev/ttyS0
/dev/ttyS1
/dev/ttyS10
/dev/ttyS11
/dev/ttyS12
/dev/ttyS13
/dev/ttyS14
/dev/ttyS15
/dev/ttyS16
/dev/ttyS17
/dev/ttyS18
/dev/ttyS19
/dev/ttyS2
/dev/ttyS20
/dev/ttyS21
/dev/ttyS22
/dev/ttyS23
/dev/ttyS24
/dev/ttyS25
/dev/ttyS26
/dev/ttyS27
/dev/ttyS28
/dev/ttyS29
/dev/ttyS3
/dev/ttyS30
/dev/ttyS31
/dev/ttyS4
/dev/ttyS5
/dev/ttyS6
/dev/ttyS7
/dev/ttyS8
/dev/ttyS9
and which ones are used by some process?
$ sudo lsof /dev/ttyS*
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
minicom 16737 ubuntu 3u CHR 4,64 0t0 1145 /dev/ttyS0
java 17051 jboss 109u CHR 4,69 0t0 1148 /dev/ttyS5
java 17051 jboss 125u CHR 4,68 0t0 1147 /dev/ttyS4
Now you know, for /dev/ttyS5 it is your (j)boss :-). Better not to touch him, so let us learn more about minicom process using /dev/ttyS0.
Ask ps command to tell us more (-f for full details) about the process with given PID (-p 16737):
$ ps -f -p 16737
UID PID PPID C STIME TTY TIME CMD
ubuntu 16737 16145 0 13:40 pts/0 00:00:00 minicom
If you even wonder, which directory is the minicom using now:
$ pwdx 16737
16737: /home/ubuntu
Now you know all and may decide to stop the minicom, you have started at 13:40 in another console and forget about it.
No comments:
Post a Comment