Labels

Android (1) bash (2) boost (2) C (34) C++ (2) cheatsheet (2) CLion (6) css (3) Debian (33) DL (17) Docker (1) Dreamweaver (2) Eclipse (3) fail2ban (4) git (5) GitHub (4) Hacking (3) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (30) javascript (3) Linux (164) Mac (19) Machine Learning (1) mySQL (47) Netbeans (4) Networking (1) Nexus (1) OpenVMS (6) Oracle (1) Pandas (3) php (16) Postgresql (8) Python (9) raid (1) RedHat (14) Samba (2) Slackware (45) SQL (14) svn (1) tar (1) ThinkPad (1) Virtualbox (3) Visual Basic (1) Visual Studio (1) Windows (2)

Saturday 20 January 2024

Serial ports

Serial port pinouts

Fig's 1&2 show the more common 9 pin serial pinouts, on both the computer side and also the device side respectively. Fig.3 gives a more visual representation of the male variant, most commonly found non the PC side. I think this was historically due to a male being more prone to damage, hence the female end being more commonly used on cables, but I may be wrong.

Fig.5 is particularly useful when testing cables, although I have only really connected pints 2&3 for this purpose. The idea here is that you make a plug that connects the pins together and then you can open the port and whatever you type should be echoed back exactly. 

Fig's 6-10 provide details about Null Modem connectivity.

Fig.11 provides more pinout details for the DB25 connectors


Fig.1 [source]
Fig.2 [source]

Fig.3 [source]

Fig.4 [source]

Fig.5 [source]

Fig.6 [source]

Fig.7 [source]

Fig.8 [source]

Fig.9 [source]

Fig.10 [source]

Fig.11 [source]

What follows is some more information on terminal settings.

stty -F /dev/ttyS0 -a can be used to view terminal settings, while stty is used to change settings.

The output of stty -F /dev/ttyS0 -a could be;
 
speed 2400 baud; rows 0; columns 0; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = <undef>; stop = <undef>; susp = <undef>; rprnt = <undef>; werase = <undef>; lnext = <undef>;
flush = <undef>; min = 0; time = 1;
parenb -parodd cs7 -hupcl -cstopb cread clocal crtscts
-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
 
 with some explanations;
  • crtscts: Hardware flow control (RTS/CTS) is enabled.
  • -ixon: Software flow control (IXON) is disabled.
  • -ixoff: Software flow control (IXOFF) is disabled.
  • parenb: If present, it indicates that parity is enabled. If absent, parity is disabled.
  • parodd: If present, it indicates that odd parity is used. If absent, even parity is used.
  • rows: This typically indicates the number of rows or lines that are available on the terminal screen.
  • columns: This usually indicates the number of columns that are available on the terminal screen.
  • line: This refers to the number of lines per page.
The setting of a terminal with stty, for example;
stty crtscts -ixon -echo cs7 parenb -icrnl -inlcr -ocrnl onlcr speed 2400 -F /dev/ttyS0

  • crtscts: Enables hardware flow control using RTS/CTS (Request to Send/Clear to Send).
  • -ixon: Disables software flow control (IXON).
  • -echo: Disables echoing of input characters.
  • cs7: Sets the character size to 7 bits per byte.
  • parenb: Enables parity generation on output and parity checking for input.
  • -icrnl: Disables mapping of CR (Carriage Return) to NL (Newline) on input.
  • -inlcr: Disables mapping of NL to CR on input.
  • -ocrnl: Disables mapping of CR to NL on output.
  • onlcr: Enables mapping of NL to CR-NL on output.
  • speed 2400: Sets the baud rate to 2400 bps (bits per second).
  • -F /dev/ttyS0: Specifies the serial port device file, in this case, /dev/ttyS0
  • Hardware Flow Control (crtscts): Enables hardware-based flow control, which uses the RTS and CTS signals to control data transmission between devices.

  • Software Flow Control (-ixon): Disables software-based flow control. This is important when hardware flow control is used.

  • Echo (-echo): Disables the echoing of input characters back to the terminal.

  • Character Size (cs7): Sets the character size to 7 bits.

  • Parity (parenb): Enables parity generation on output and parity checking for input.

  • Input Carriage Return (-icrnl): Disables mapping of CR to NL on input.

  • Input Newline (-inlcr): Disables mapping of NL to CR on input.

  • Output Carriage Return (-ocrnl): Disables mapping of CR to NL on output.

  • Output Newline (onlcr): Enables mapping of NL to CR-NL on output.

  • Baud Rate (speed 2400): Sets the baud rate to 2400 bps.

  • Serial Port (-F /dev/ttyS0): Specifies the serial port device file, in this case, /dev/ttyS0.




No comments:

Post a Comment

Note: only a member of this blog may post a comment.