linux:serial_ports
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:serial_ports [2020/09/30 07:41] – ↷ Page moved and renamed from linux_serial_ports to linux:serial_ports utedass | linux:serial_ports [2022/09/12 00:30] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Possible alternatives for virtual serial ports ====== | ||
| + | |||
| + | * Pseudo teletype -- Linux C programming | ||
| + | * socat -- Command | ||
| + | * fuse -- Filesystem in userspace | ||
| + | * < | ||
| + | |||
| + | |||
| + | ^ Method ^ Description ^ Pros ^ Cons ^ Dependencies ^ | ||
| + | | pty | Virtual terminal device | Full duplex | ||
| + | | socat | Multipurpose relay | Super flexible | ||
| + | | fuse | Filesystem in userspace | ?? | ???? | libfuse-dev | | ||
| + | | fifo | Named pipes | Simple | ||
| + | ====== Scratchpad ====== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | < | ||
| + | errno | ||
| + | termios | ||
| + | tcgetattr | ||
| + | cfsetospeed | ||
| + | cfsetispeed | ||
| + | tcsetattr | ||
| + | posix_openpt | ||
| + | ioctl_tty | ||
| + | |||
| + | Använd noncanonical input processing mode för att kunna styra RTS och DTR | ||
| + | |||
| + | termios.h är en grej | ||
| + | |||
| + | |||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | gör open på porten | ||
| + | int fd = open (portname, O_RDWR | O_NOCTTY | O_SYNC); | ||
| + | </ | ||
| + | |||
| Get info: | Get info: | ||
| Line 15: | Line 66: | ||
| # Using screen. Exit with c-a k | # Using screen. Exit with c-a k | ||
| $ screen /dev/ttyS0 115200 | $ screen /dev/ttyS0 115200 | ||
| + | |||
| + | # Read current configuration using stty | ||
| + | $ stty -a < /dev/ttyS0 | ||
| + | # or | ||
| + | $ stty -a -F=/ | ||
| + | |||
| + | # Set baud rate and hardware flow control using stty | ||
| + | $ stty -F=/ | ||
| </ | </ | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | |||
| + | |||
| + | ====== Serial port basics ====== | ||
| + | {{ : | ||
| + | |||
| + | |DTE | Data terminal equipment (computer/ | ||
| + | |DCE | Data circuit-terminating equipment (modem/ | ||
| + | |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.1601451701.txt.gz · Last modified: 2022/09/12 00:30 (external edit)
