Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serial! It's what's for breakfast

Serial! It's what's for breakfast

Me: I want to write a program that talks to a serial port. Reality: What is serial port? How does work?

This talk aims to fill in that reality gap. I'll cover the basics of what serial is, how it works (RTS/CTS, stop signals, buffers), and possibly go over how to write/interact with Unix serial ports (in C or walk through part of the python pyserial library. TBD).

All serial info to be based on the RS-232 protocol.

Presented at bangbangcon 2014
Talk recording: http://youtube.com/watch?v=J1CQz8XyWoo

NeiL saitug

May 18, 2014
Tweet

More Decks by NeiL saitug

Other Decks in Programming

Transcript

  1. RX Received Data Pin 2 TX Transmitted Data Pin 3

    GRD Ground Pin 5 RTS Ready to Send Pin 7 CTS Clear to Send Pin 8
  2. GRD

  3. #define CS5 0x00000000 /* 5 bits (pseudo) */ #define CS6

    0x00000100 /* 6 bits */ #define CS7 0x00000200 /* 7 bits */ #define CS8 0x00000300 /* 8 bits */
  4. 33<

  5. /* * Defaults on "first" open. */ #define TTYDEF_IFLAG (BRKINT

    | ICRNL | IMAXBEL | IXON | IXANY) #define TTYDEF_OFLAG (OPOST | ONLCR) #define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL) #define TTYDEF_CFLAG (CREAD | CS8 | HUPCL) #define TTYDEF_SPEED (B9600)