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 08:59] utedasslinux:serial_ports [2022/09/12 00:30] (current) – external edit 127.0.0.1
Line 4: Line 4:
   * socat -- Command   * socat -- Command
   * fuse -- Filesystem in userspace   * fuse -- Filesystem in userspace
-  * pipes -- Heave data between processes+  * <del>named pipes -- Heave data between processes</del> <color #ed1c24>One-way</color>
  
  
-====== Experiments ======+^ 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 25: 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 ====== ====== Serial port basics ======
Line 38: Line 93:
 |DSR | Data set ready | |DSR | Data set ready |
  
-{{ :linux:db9-pinout.gif?400|}}+{{:linux:db9-pinout.gif?400 |}} 
  
 ====== Accessing a serial port ====== ====== Accessing a serial port ======
linux/serial_ports.1601456380.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