提供一个linux串口程序
来源:互联网 发布:linux 命令 竖线 编辑:程序博客网 时间:2024/06/05 05:03
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
int main(void)
{
int fd;
struct termios opts;
int ret;
char *buffer = "Hello";
fd = open("/dev/ttySAC3", O_RDWR);
if (fd < 0)
{
printf("open ttys3");
return 1;
}
printf("tty3 open ok!");
tcgetattr(fd, &opts);
opts.c_cflag |= CLOCAL;
opts.c_cflag &= ~CRTSCTS;
opts.c_cflag &= ~CSIZE;
opts.c_cflag |= CS8;
opts.c_cflag &= ~CSTOPB;
opts.c_cflag &= ~PARENB;
cfsetispeed(&opts, B115200);
cfsetospeed(&opts, B115200);
tcsetattr(fd, TCSANOW, &opts);
write(fd, buffer, 5);
close(fd);
return 0;
}
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
int main(void)
{
int fd;
struct termios opts;
int ret;
char *buffer = "Hello";
fd = open("/dev/ttySAC3", O_RDWR);
if (fd < 0)
{
printf("open ttys3");
return 1;
}
printf("tty3 open ok!");
tcgetattr(fd, &opts);
opts.c_cflag |= CLOCAL;
opts.c_cflag &= ~CRTSCTS;
opts.c_cflag &= ~CSIZE;
opts.c_cflag |= CS8;
opts.c_cflag &= ~CSTOPB;
opts.c_cflag &= ~PARENB;
cfsetispeed(&opts, B115200);
cfsetospeed(&opts, B115200);
tcsetattr(fd, TCSANOW, &opts);
write(fd, buffer, 5);
close(fd);
return 0;
}
0 0
- 提供一个linux串口程序
- 一个Linux下的串口程序
- 一个串口程序示例
- linux串口通信程序
- Linux串口通信程序
- linux 串口程序编程
- linux串口程序
- Linux串口测试程序
- Linux串口测试程序
- Linux串口程序
- linux串口测试程序
- linux串口收发程序
- linux串口程序
- 一个C串口通信程序
- 一个串口上位机程序
- 一个串口程序(转)
- linux下串口程序测试
- Linux下串口程序开发
- 欢迎使用CSDN-markdown编辑器
- 数据标准化/归一化方法(Data Normalization Method )
- 方法
- Java实现Md5加密
- 并发编程--公平锁和非公平锁
- 提供一个linux串口程序
- 用户权限设计(一)-数据库设计
- Opencv学习---霍夫变换
- 套接字模式
- 卸载win10 自带应用
- 栈
- 前台获取后台返回的图片并显示
- 宜信大数据创新中心2017实习生面试(三轮)
- Linux下访问网络文件系统