没有合适的资源?快使用搜索试试~ 我知道了~
首页Serial Programming Guide for POSIX Operating Systems
Serial Programming Guide for POSIX Operating Systems
需积分: 9 56 下载量 200 浏览量
更新于2023-03-16
评论
收藏 466KB DOC 举报
The Serial Programming Guide for POSIX Operating Systems will teach you how to successfully, efficiently, and portably program the serial ports on your UNIX® workstation or PC. Each chapter provides programming examples that use the POSIX (Portable Standard for UNIX) terminal control functions and should work with very few modifications under IRIX®, HP-UX, SunOS®, Solaris®, Digital UNIX®, Linux®, and most other UNIX operating systems. The biggest difference between operating systems that you will find is the filenames used for serial port device and lock files.
资源详情
资源评论
资源推荐
SERIAL PROGRAMMING GUIDE FOR POSIX OPERATING SYSTEMS Page 1 of 45
SERIAL PROGRAMMING GUIDE
FOR
POSIX OPERATING SYSTEMS
5th Edition, 6th Revision
Copyright 1994-2005 by Michael R. Sweet
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.2 or any later
version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the
license is included in Appendix C, GNU Free Documentation License.
TABLE OF CONTENTS
Introduction
License
Organization
Chapter 1, Basics of Serial Communications
What Are Serial Communications?
What Is RS-232?
o Signal Definitions
Asynchronous Communications
o What Are Full Duplex and Half Duplex?
o Flow Control
o What Is a Break?
Synchronous Communications
Accessing Serial Ports
o Serial Port Files
o Opening a Serial Port
o Writing Data to the Port
o Reading Data from the Port
o Closing a Serial Port
Chapter 2, Configuring the Serial Port
The POSIX Terminal Interface
o Control Options
o Local Options
SERIAL PROGRAMMING GUIDE FOR POSIX OPERATING SYSTEMS Page 2 of 45
o Input Options
o Output Options
o Control Characters
Chapter 3, MODEM Communications
What Is a MODEM?
Communicating With a MODEM
o Standard MODEM Commands
o Common MODEM Communication Problems
Chapter 4, Advanced Serial Programming
Serial Port IOCTLs
o Getting the Control Signals
o Setting the Control Signals
o Getting the Number of Bytes Available
Selecting Input from a Serial Port
o The SELECT System Call
o Using the SELECT System Call
o Using SELECT with the X Intrinsics Library
Appendix A, Pinouts
RS-232 Pinouts
RS-422 Pinouts
RS-574 (IBM PC/AT) Pinouts
SGI Pinouts
Appendix B, ASCII Control Codes
Control Codes
Appendix C, GNU Free Documentation License
How to use this License for your documents
Appendix D, Change History
Edition 5, Revision 6
Edition 5, Revision 5
Edition 5, Revision 4
Edition 5, Revision 3
INTRODUCTION
SERIAL PROGRAMMING GUIDE FOR POSIX OPERATING SYSTEMS Page 3 of 45
The Serial Programming Guide for POSIX Operating Systems will teach you
how to successfully, efficiently, and portably program the serial ports on your
UNIX® workstation or PC. Each chapter provides programming examples that
use the POSIX (Portable Standard for UNIX) terminal control functions and
should work with very few modifications under IRIX®, HP-UX, SunOS®,
Solaris®, Digital UNIX®, Linux®, and most other UNIX operating systems.
The biggest difference between operating systems that you will find is the
filenames used for serial port device and lock files.
LICENSE
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.2 or any later
version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the
license is included in Appendix C, GNU Free Documentation License.
ORGANIZATION
This guide is organized into the following chapters and appendices:
Chapter 1, Basics of Serial Programming
Chapter 2, Configuring the Serial Port
Chapter 3, Talking to MODEMs
Chapter 4, Advanced Serial Programming
Appendix A, RS-232 Pinouts
Appendix B, ASCII Control Codes
Appendix C, GNU Free Documentation License
Appendix D, Change History
SERIAL PROGRAMMING GUIDE FOR POSIX OPERATING SYSTEMS Page 4 of 45
CHAPTER 1, BASICS OF SERIAL
COMMUNICATIONS
This chapter introduces serial communications, RS-232 and other standards
that are used on most computers as well as how to access a serial port from a
C program.
WHAT ARE SERIAL COMMUNICATIONS?
Computers transfer information (data) one or more bits at a time. Serial refers
to the transfer of data one bit at a time. Serial communications include most
network devices, keyboards, mice, MODEMs, and terminals.
When doing serial communications each word (i.e. byte or character) of data
you send or receive is sent one bit at a time. Each bit is either on or off. The
terms you'll hear sometimes are mark for the on state and space for the off
state.
The speed of the serial data is most often expressed as bits-per-second
("bps") or baudot rate ("baud"). This just represents the number of ones and
zeroes that can be sent in one second. Back at the dawn of the computer age,
300 baud was considered fast, but today computers can handle RS-232
speeds as high as 430,800 baud! When the baud rate exceeds 1,000, you'll
usually see the rate shown in kilo baud, or kbps (e.g. 9.6k, 19.2k, etc). For
rates above 1,000,000 that rate is shown in megabaud, or Mbps (e.g.
1.5Mbps).
When referring to serial devices or ports, they are either labeled as Data
Communications Equipment ("DCE") or Data Terminal Equipment ("DTE").
The difference between these is simple - every signal pair, like transmit and
receive, is swapped. When connecting two DTE or two DCE interfaces
together, a serial null-MODEM cable or adapter is used that swaps the signal
pairs.
WHAT IS RS-232?
RS-232 is a standard electrical interface for serial communications defined by
the Electronic Industries Association ("EIA"). RS-232 actually comes in 3
SERIAL PROGRAMMING GUIDE FOR POSIX OPERATING SYSTEMS Page 5 of 45
different flavors (A, B, and C) with each one defining a different voltage range
for the on and off levels. The most commonly used variety is RS-232C, which
defines a mark (on) bit as a voltage between -3V and -12V and a space (off)
bit as a voltage between +3V and +12V. The RS-232C specification says
these signals can go about 25 feet (8m) before they become unusable. You
can usually send signals a bit farther than this as long as the baud is low
enough.
Besides wires for incoming and outgoing data, there are others that provide timing, status, and
handshaking:
Table 1 - RS-232 Pin Assignments
PIN DESCRIPTION PIN DESCRIPTION PIN DESCRIPTION PIN DESCRIPTION PIN DESCRIPTION
1 Earth Ground 6
DSR - Data
Set Ready
11 Unassigned 16 Secondary RXD 21 Signal Quality Detect
2
TXD -
Transmitted
Data
7
GND - Logic
Ground
12
Secondary
DCD
17 Receiver Clock 22 Ring Detect
3
RXD -
Received Data
8
DCD - Data
Carrier Detect
13
Secondary
CTS
18 Unassigned 23 Data Rate Select
4
RTS - Request
To Send
9 Reserved 14
Secondary
TXD
19 Secondary RTS 24 Transmit Clock
5
CTS - Clear
To Send
10 Reserved 15
Transmit
Clock
20
DTR - Data
Terminal Ready
25 Unassigned
Two standards for serial interfaces you may also see are RS-422 and RS-
574. RS-422 uses lower voltages and differential signals to allow cable
lengths up to about 1000ft (300m). RS-574 defines the 9-pin PC serial
connector and voltages.
SIGNAL DEFINITIONS
The RS-232 standard defines some 18 different signals for serial
communications. Of these, only six are generally available in the UNIX
environment.
GND - Logic Ground
Technically the logic ground is not a signal, but without it none of the other
signals will operate. Basically, the logic ground acts as a reference voltage so
that the electronics know which voltages are positive or negative.
剩余44页未读,继续阅读
CoolKin9
- 粉丝: 2
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- ExcelVBA中的Range和Cells用法说明.pdf
- 基于单片机的电梯控制模型设计.doc
- 主成分分析和因子分析.pptx
- 共享笔记服务系统论文.doc
- 基于数据治理体系的数据中台实践分享.pptx
- 变压器的铭牌和额定值.pptx
- 计算机网络课程设计报告--用winsock设计Ping应用程序.doc
- 高电压技术课件:第03章 液体和固体介质的电气特性.pdf
- Oracle商务智能精华介绍.pptx
- 基于单片机的输液滴速控制系统设计文档.doc
- dw考试题 5套.pdf
- 学生档案管理系统详细设计说明书.doc
- 操作系统PPT课件.pptx
- 智慧路边停车管理系统方案.pptx
- 【企业内控系列】企业内部控制之人力资源管理控制(17页).doc
- 温度传感器分类与特点.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0