user space串口编程

来源:互联网 发布:淘宝软文范例 编辑:程序博客网 时间:2024/05/01 19:42

源码:

#include     <stdio.h>

#include     <stdlib.h>
#include     <unistd.h>
#include     <sys/types.h>
#include     <sys/stat.h>
#include     <fcntl.h>
#include     <termios.h>
#include     <errno.h>


int main(int argc, char **argv){
        int fd = open("/dev/tty0" , O_RDWR );      
while (1)
{
        write(fd, "hello" ,6);
}
}

编译和运行

结果:


0 0