当前位置: 技术问答>linux和unix
请教UNIX下的串口编程
来源: 互联网 发布时间:2014-11-08
本文导语: 现在有些串口编程的工作需要在UNIX下完成(具体工作是通过串口通信的方式将一些指令发送给程控交换机)。在此请教一下,需要调用些什么函数,有没有像Windows的TAPI那样封装好的API? | 更...
现在有些串口编程的工作需要在UNIX下完成(具体工作是通过串口通信的方式将一些指令发送给程控交换机)。在此请教一下,需要调用些什么函数,有没有像Windows的TAPI那样封装好的API?
|
更文件操作一样...
unix函数: open, write, read 等.
unix函数: open, write, read 等.
|
/*
This is like all programs in the Linux Programmer's Guide meant
as a simple practical demonstration.
It can be used as a base for a real terminal program.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define BAUDRATE B9600
#define MODEMDEVICE "/dev/ttyS0"
#define FALSE 0
#define TRUE 1
volatile int STOP=FALSE;
void child_handler(int s)
{
STOP=TRUE;
}
main()
{
int size ,i;
int fd;
unsigned char c;
unsigned char buff[1024];
struct termios oldtio,newtio,oldstdtio,newstdtio;
struct sigaction sa;
fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY);
if (fd
This is like all programs in the Linux Programmer's Guide meant
as a simple practical demonstration.
It can be used as a base for a real terminal program.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define BAUDRATE B9600
#define MODEMDEVICE "/dev/ttyS0"
#define FALSE 0
#define TRUE 1
volatile int STOP=FALSE;
void child_handler(int s)
{
STOP=TRUE;
}
main()
{
int size ,i;
int fd;
unsigned char c;
unsigned char buff[1024];
struct termios oldtio,newtio,oldstdtio,newstdtio;
struct sigaction sa;
fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY);
if (fd
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
站内导航:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!