User Tools

Site Tools


linux:serial_ports

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:serial_ports [2020/09/30 07:41] – ↷ Page moved and renamed from linux_serial_ports to linux:serial_ports utedasslinux: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
 +  * <del>named pipes -- Heave data between processes</del> <color #ed1c24>One-way</color>
 +
 +
 +^ Method ^ Description ^ Pros ^ Cons ^ Dependencies ^
 +| pty    | Virtual terminal device | Full duplex     | Must create links to name them         | native      |
 +| socat  | Multipurpose relay      | Super flexible  | External program.\\ Maybe less control | socat       |
 +| fuse   | Filesystem in userspace | ??              | ????                                   | libfuse-dev |
 +| fifo   | Named pipes             | Simple          | One-way only                           | native      |
 +====== Scratchpad ======
 +
 +[[https://www.gnu.org/software/libc/manual/pdf/libc.pdf|glibc manual]] -- Innehåller massa bra info!
 +
 +[[https://linux.die.net/man/3/termios|termios man page]]
 +
 +[[https://linux.die.net/man/4/tty_ioctl|tty_ioctl man page]]
 +
 +[[http://kirste.userpage.fu-berlin.de/chemnet/use/info/libc/libc_12.html#SEC237|Seting up terminals]]
 +
 +[[https://www.cmrr.umn.edu/~strupp/serial.html|Serial programming guide for posix]]
 +
 +<code>
 +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 <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);
 +</code>
 +
 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=/dev/ttyS0
 +
 +# Set baud rate and hardware flow control using stty
 +$ stty -F=/dev/ttyS0 9600 crtscts ixon
  
 </code> </code>
 +
 +[[https://man7.org/linux/man-pages/man2/poll.2.html|Polla för satan!]]
 +
 +[[https://man7.org/linux/man-pages/man7/signal.7.html|Läs på om signaler!]]
 +
 +
 +
 +====== Serial port basics ======
 +{{ :linux:serial.jpg?400|}}
 +
 +|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 |
 +
 +{{:linux:db9-pinout.gif?400 |}}
 +
 +
 +====== Accessing a serial port ======
 +
 +
 +
 +====== Pseudo teletype ======
 +
 +
linux/serial_ports.1601451701.txt.gz · Last modified: 2022/09/12 00:30 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki