85

I'm not quite certain what you're asking. You mention 'port' several times, but then in your example, you say the answer is /dev/ttyUSB0, which is a device dev path, not a port. So this answer is about finding the dev path for each device. Below is a quick and dirty script which walks through devices in /sys looking for USB devices with a ID_SERIAL ...


61

Same as with output. Example: cat /dev/ttyS0 Or: cat < /dev/ttyS0 The first example is an app that opens the serial port and relays what it reads from it to its stdout (your console). The second is the shell directing the serial port traffic to any app that you like; this particular app then just relays its stdin to its stdout. To get better ...


59

All devices on Unix are mapped to a device file, the serial ports would be /dev/ttyS0 /dev/ttyS1 ... . First have a look at the permissions on that file, lets assume you are using /dev/ttyS1. ls -l /dev/ttyS1 You will want read.write access, if this is a shared system then you should consider the security consequences of opening it up for everyone. ...


43

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 http:/...


43

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 ...


39

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. There exists a more specific function fflush() that does the same, but is not available in older versions of awk. An important piece of ...


37

The rule syntax above may work on some distributions, but did not work on mine (Raspbian). Since I never found a single document that explains all the ins and outs, I wrote my own, to be found here. This is what it boils down to. 1. find out what's on ttyUSB: dmesg | grep ttyUSB 2. list all attributes of the device: udevadm info --name=/dev/ttyUSBx --...


36

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 ...


36

Unfortunately serial ports are non-PlugNPlay, so kernel doesn't know which device was plugged in. After reading a HowTo tutorial I've got the working idea. The /dev/ directory of unix like OSes contains files named as ttySn (with n being a number). Most of them doesn't correspond to existing devices. To find which ones do, issue a command: $ dmesg | grep ...


31

socat is a tool to connect (nearly) everything to (nearly) everything, and tee can duplicate streams. In your usecase you could connect your serial port /dev/ttyS0 to a PTY /tmp/ttyV0, then point your application to the PTY, and have socat tee out Input and Output somewhere for you to observe. Googling "socat serial port pty tee debug" will point you to ...


26

the best way to pass a file through xmodem is to use sx. In debian this application is part of 'lrzsz' package. In debian: apt-get install screen lrzsz screen /dev/ttyUSB0 115200 Then press Ctrl-A followed by : and type: exec !! sx yourbinary.bin This will send the file to ttyUSB0 over xmodem protocol


26

You can use the stty command to set such parameters. This will show all settings on the first serial port (replace ttyS0 with ttyUSB0 if using an USB serial port): stty -F /dev/ttyS0 -a This will set the baud rate to 9600, 8 bits, 1 stop bit, no parity: stty -F /dev/ttyS0 9600 cs8 -cstopb -parenb One thing that generally confuses people is that most ...


24

Use the screen quit command (normally ctrl-A \).


23

I use the command stty -F /dev/ttyUSB0 9600.


22

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 ...


17

You don't need to modify the kernel to just it just once; you can override it. Unplug the device modprobe ftdi_sio echo 0403 6001 >/sys/bus/usb-serial/drivers/ftdi_sio/new_id Plug in the device And your device should work. Your other alternative is to use the bind sysfs interface; I suggest using lsusb -t to figure out the correct path+interface in ...


15

Try http://tio.github.io "tio" is a simple TTY terminal application which features a straightforward commandline interface to easily connect to TTY devices for basic input/output. Typical use is without options. For example: tio /dev/ttyS0 Which corresponds to the commonly used options: tio --baudrate 115200 --databits 8 --flow none --stopbits 1 --...


14

This script is based on another answer, but sends everything over the serial port (except Ctrl+Q), not just single commands followed by Enter. This enables you to use Ctrl+C or Ctrl+Z on the remote host, and to use interactive "GUI" programs like aptitude or alsamixer. It can be quit by pressing Ctrl+Q. #!/bin/bash if [[ $# -lt 1 ]]; then echo "Usage:" ...


14

You don't need to modify the kernel, you can automate the process like this: Add the following single line to /etc/udev/rules.d/99-ftdi.rules ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", RUN+="/sbin/modprobe ftdi_sio" RUN+="/bin/sh -c 'echo 0403 6001 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'" Either reboot or run sudo udevadm ...


14

All you have to do is open two terminals. In the first terminal you cat everything from the device, e.g. cat /dev/ttyS0 in the other terminal, you can send arbitrary hex characters and text to the terminal e.g. as follows: echo -e "\x7E\x03\xD0\xAF und normaler Text" > /dev/ttyS0 The echo -e command enables the interpretation of backslash escapes. ...


12

Programs that talk to serial devices: picocom minicom socat or from shell you can do: stty -speed 19200 < /dev/ttyS0 # sets the speed of the port exec 99<>/dev/ttyS0 (or /dev/ttyUSB0...etc) printf "AT\r" >&99 read answer <&99 # this reads just a CR read answer <&99 # this reads the answer OK exec 99>&-


12

You can use this command to explore your device if connected to usb0: udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)


11

The multiple-identical-USB-device problem I have a Rasperry Pi with four cameras. I take pix with fswebcam which identifies the cameras as /dev/video0 .. video3. Sometimes the camera is video0, vide02, video4 and video6 but we can forget about that for now. I need a persistent ID to identify a camera number so that, e.g. video0 is always the same camera ...


10

It is likely to be buffering in awk, not cat. In the first case, awk believes it is interactive because its 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, ...


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 ...


9

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 = cfgetispeed(&...


9

Try socat - /dev/ttyUSB2,crnl This tells socat to send a carriage return as well as a line feed. Clarification - this goes back to the dark days of electric typewriters, where you would have to tell it to roll the carriage back to position 0 on the page - ergo, a carriage return - as well as telling it to move the paper up one line.


9

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, ...


8

If you want to use zmodem you have to set the zmodem option to pass, if your screen session is already running, press CTRL+A : and just enter zmodem pass . To send the data just use the sz command from the lrzsz package. If you want to receive data via screen you have to set the value to catch.


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