linux:serial_ports
This is an old revision of the document!
Table of Contents
Possible alternatives for virtual serial ports
- Pseudo teletype – Linux C programming
- socat – Command
- fuse – Filesystem in userspace
- pipes – Heave data between processes
Scratchpad
Serial programming guide for posix
errno termios tcgetattr cfsetospeed cfsetispeed tcsetattr posix_openpt ioctl_tty Använd noncanonical input processing mode termios.h är en grej #include <errno.h> #include <fcntl.h> #include <string.h> #include <termios.h> #include <unistd.h> gör open på porten int fd = open (portname, O_RDWR | O_NOCTTY | O_SYNC);
Get info:
$ dmesg | egrep --color 'serial|ttyS'
Some commands to manage, read and write to the serial port
# Print info $ setserial -g /dev/ttyS0 # Using cu (call-up). Exit by typing ~. $ cu -l /dev/ttyS0 -s 115200 # Using screen. Exit with c-a k $ screen /dev/ttyS0 115200 # Read current configuration using stty $ stty -a < /dev/ttyS0 # or $ stty -a -F=/dev/ttyS0 # Set baud rate and hardware flow control using stty $ stty -F=/dev/ttyS0 9600 crtscts ixon
Serial port basics
| DTE | Data terminal equipment (computer/MCU) |
| DCE | Data circuit-terminating equipment (modem/device) |
| RTS | Request to send |
| CTS | Clear to send |
| DTR | Data terminal ready |
| DSR | Data set ready |
Accessing a serial port
Pseudo teletype
linux/serial_ports.1601473047.txt.gz · Last modified: 2022/09/12 00:30 (external edit)


