用c语言编写串口程序

所属分类:串口编程
开发工具:C/C++
文件大小:6KB
下载次数:163
上传日期:2005-09-03 21:00:34
上 传 者xiaotaoqi
说明:  用c语言编写串口程序 在当今,流行的编程软件种类繁多,它们编程方便、易于维护,但是在与硬 件直接打交道和编制系统软件时却束手无策,于是C语言就有了用武之地。C语言 作为汇编语言与高级语言之间的一种过渡语言,兼有汇编语言的高效和高级语言 的方便。   在通讯中,为了保证行运安全可靠,标准的串行口必须具有许多握手信号和 状态信息。这是因为通讯的各个计算机CPU速度不一样(这会导致“错帧”)以 及发送机发送数据速度比接收机接收速度快(这会导致“过冲”)。为解决这个 问题,我们采用一个简单的握手信号,即发送机每次仅发送半个字节(低4位) 的数据,而另外半个字节(高4位)则用来传送信息。我们可以对信息位(高4位) 进行如下简单的编码: 0H:发送的是新的半个字节数据 1H:重新发送上次传送错误的数据 2H:文件名结束 3H:文件结束 这样,每当发送机发送一个字节以后,就等待接受机发回送信号,这回送信号就 是发送机发送过来的那个字节。发送机接收到回送信号后,把它与刚发送的字节 相比较,如果相同,就发送新的半个字节,否则就重新发送。新数据与旧数据通 过信息位来区分。下面就是用C语言编写控制串行口的程序。
(Serial procedures in the preparation of today's popular programming software, and a large variety of their programming and easy to maintain, but to deal directly with the hardware and system software when compiled a loss, so there will be a C language battlefield. C language as the compilation and Advanced Language a transition between languages, both assembly language and the efficient high-level language convenience. In telecommunications, in order to ensure safe and reliable transport firms, the standard serial I must have shook hands with many signals and state information. This is because the various computer communications CPU speed is not the same (this would lead to "the wrong frame") and transmitter to send data faster than fast receiver to receive (this would lead t)

文件列表:
用c语言编写串口程序.doc (30720, 2005-09-03)

近期下载者

相关文件


收藏者