Tag Info

Hot answers tagged

30

These /dev nodes appear because the standard PC serial port driver is compiled into the kernel you're using, and it is finding UARTs. That causes /sys/devices/platform/serial8250 (or something compatible) to appear, so udev creates the corresponding /dev nodes. These UARTs are most likely one of the many features of your motherboard's chipset. Serial UARTs ...


18

I find screen the most useful program for serial communication since I use it for other things anyway. It's usually just screen /dev/ttyS0 <speed>, although the default settings may be different for your device. It also allows you to pipe anything into the session by entering command mode and doing exec !! <run some program that generates ...


13

Background The main reason why you need any program like minicom to communicate over a serial port is that the port needs to be set up prior to initiating a connection. If it weren't set up appropriately, the cat and echo would not for you as expected. Notice that once you run a program like minicom, the port is left with a a set of settings that minicom ...


10

It's not clear exactly what you want. If you want to use your existing Ethernet port, that won't be an option for many reasons; the most fundamental being that Ethernet requires precise termination and voltage levels, the hardware on the interface (the PHY) is made to deal with that. Ethernet uses strictly +/- 0.85V and 50ohm termination impedance; RS-232 ...


10

The stty utility sets or reports on terminal I/O characteristics for the device that is its standard input. These characteristics are used when establishing a connection over that particular medium. cat doesn't know the baud rate as such, it rather prints on the screen information received from the particular connection. As an example stty -F /dev/ttyACM0 ...


9

Are you sure the data isn't corrupted by your terminal (or wherever cat is displaying)? cat is unlikely to corrupt your data. Try using od (octal dump) to dump the data coming from the serial port, so you can see exactly what is coming across (without relying on it being printable). Use od -c if you're expecting ASCII data. If you're still seeing ...


8

If UUCP is installed on the system, you may use the command cu, e.g. $ cu -l /dev/ttyS0 -s 9600


7

The right to access a serial port is determined by the permissions of the device file (e.g. /dev/ttyS0). So all you need to do is either arrange for the device to be owned by you, or (better) put yourself in the group that owns the device, or (if Fedora supports it, which I think it does) arrange for the device to belong to the user who's logged in on the ...


6

I found projects called Linux Serial Sniffer, jpnevulator, and Moni. The first two look like they do exactly what you want. The last one calls itself a monitor, but it actually looks like a standard serial communication program.


6

cat just uses whatever settings the port is already configured for. With this little C snippet you can see the baud rate currently set for a particular serial port: get-baud-rate.c #include <termios.h> #include <unistd.h> #include <stdio.h> int main() { struct termios tios; tcgetattr(0, &tios); speed_t ispeed = ...


6

SAK in this case really means Secure Attention Key. The message you are seeing is a kernel message defined in drivers/tty/tty_io.c. SAK is a key combination which ensures secure login for a user on console. On Linux SAK ensures this by killing all processes attached to the terminal SAK is invoked on. It is expected that init will then restart the trusted ...


5

I know it is an old question, but a one-liner may help those who come here searching: cat /dev/ttyPSC9 | awk '{ print $0; system("")}' system("") does the trick, and is POSIX compliant. Non-posix systems: beware.


5

It is likely to be buffering in awk, not cat. In the first case, awk believes it is interactive because it's input and output are ttys (even though they're different ttys - I'm guessing that awk is not checking that). In the second, the input is a pipe so it runs non-interactively. You will need to explicitly flush in your awk program. This is not portable ...


5

I found a way using a shell script here that put cat as a background process and a while loop that read the user input and echo it out to the port. I modified it to be more general and it fitted my purpose perfectly. #!/bin/sh # connect.sh # Usage: # $ connect.sh <device> <port speed> # Example: connect.sh /dev/ttyS0 9600 # Set up device ...


5

Many devices use nonstandard connectors for serial ports. RJ-45 is probably the most common connector used for RS-232 serial after DB-9, but unlike with DB-9, there aren't even de facto standards for the pinout. I'm aware of 4 different RJ-45 RS-232 pinouts, and there are probably others I haven't seen yet. None of this means that people are somehow ...


5

I don't think the serial driver has any tracing functionality that would allow you to watch packets. You can use strace to observe all the reads and writes from your application: strace -s9999 -o myapp.strace -eread,write,ioctl ./myapp


5

Thanks to the second comment by Bruce, I was able to figure out the problem on my own. After running stty -a -F /dev/ttyS1, there were 3 options I found to contribute to the problem: "echo", "onlcr", and "icrnl". Since this serial port is looped back to itself, here is what happened after running echo "hi" > /dev/ttyS1: The echo command appends a ...


5

I don't know if the existing options (e.g. Scilab, or Octave with the control systems package) can deal with real-time data. In any case, it shouldn't be hard to make your own; I would probably use Python + SciPy + NumPy + pyserial + matplotlib (+ any web framework if you eventually plan to control this over the network). There's a control systems ...


5

As suggested, you can add some udev rules. I edited the /etc/udev/rules.d/10-local.rules to contain: ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="my_uart" You can check for the variables of your device by running udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0) There is a more in depth guide you can read on ...


5

USB has a standardized method to learn device information including PID and VID. This information is available by the enumeration phase and takes place of the control endpoint. This is possible because there is an additional protocol on top of the raw data signals. The RS232 serial port is much simpler and does not have similar functionality defined. Data ...


4

You could try making the device node manually. On my system /dev/ttyUSB0 is major 188 and minor 0., and hopefully my supposition is correct that it's a type c meaning character device (maybe try u for unbuffered character device if c doesn't work). mknod /dev/ttyUSB0 c 188 0 If this worked, and the device file was appearing automatically before, something ...


4

cat doesn't modify the data. There might be old Unix systems where it truncates lines that contain null bytes, but not Linux, and I think not any modern unix-like system. On the other hand, if you try to display binary data directly on your terminal, the terminal will interpret control characters as commands to control the display. That's what control ...


4

It's not corrupted. What's happening is that the cat command is getting some of the bytes, and your application is getting some of them. So when you run cat, any bytes read by it are missed by the app, and both cat and the app will see (different) partial streams that appear corrupted.


4

I managed to resolve the issue with the help of pabouk's answer. The code based solution that I finally discovered which allows the SAK flag to be set/unset on the serial port when opening using userspace API can be found on stackoverflow here How can I disable the serial port SAK option on Linux using userspace API?


4

Why doesn't the below work? # in one terminal: echo "asdf" > /dev/ttyUSB0 # in another terminal, this hangs and does nothing cat < /dev/ttyS0 Because, as a rule, serial ports don't buffer data. If there's no client app to receive the bytes landing on the serial port, they will simply be discarded. As an experiment, try launching minicom or cu ...


4

interceptty looks like what you want. I found that from this Ubuntu page interceptty - Intercept traffic to and from a serial port. Example If you want to use interceptty as an external serial monitor [connected to two serial ports on your machine and relaying between them, while recording the output] you can use one device as the backend, ...


4

Unix version 7 (1979): # ls -l /dev/console /dev/tty?* crw--w--w- 1 root 0, 0 Sep 22 06:46 /dev/console crw-rw-r-- 1 root 0, 1 Sep 22 05:47 /dev/tty1 crw-rw-r-- 1 root 0, 2 Sep 22 05:47 /dev/tty2 (no pty there yet) Linux 3.2.0 (debian wheezy). Note: you can also find these by searching /dev for owned by group tty and dialout. That's a Debian ...


3

Have a look at http://sourceforge.net/projects/ttyusbspy/?source=navbar It is on alpha stage but it works


3

When I debug interaction of my application with a serial port, I use moserial.



Only top voted, non community-wiki answers of a minimum length are eligible