社区
其他开发语言
帖子详情
*******关于 kylix下串口读写**********
piers
2003-09-21 09:23:24
linux下
可把串口当做文件/dev/ttyS0读写
但是在程序里设置波特率不知怎么做到
有没有类似mscomm的控件可用???
...全文
146
2
打赏
收藏
*******关于 kylix下串口读写**********
linux下 可把串口当做文件/dev/ttyS0读写 但是在程序里设置波特率不知怎么做到 有没有类似mscomm的控件可用???
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
piers
2003-09-29
打赏
举报
回复
thanks
swites
2003-09-22
打赏
举报
回复
mscomm是第三方控件,这里时没用的,用下面语句:
/* this is a test program for using serial port */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <time.h>
#include <string.h>
#define SER_DEV1 "/dev/ttyS0"
#define SER_DEV2 "/dev/ttyS1"
#define SER_DEV3 "/dev/ttyS2"
#define SER_DEV4 "/dev/ttyS3"
#define BR1 B19200
#define BR2 B9600
#define ESC 0x1b
#define CR 0x0d
#define LF 0x0a
static struct termios ser1_old, ser1_new;
/* open_port(device) -- open serial port */
int open_port(char *ser_port) {
int fd; /* port file descriptor */
fd = open(ser_port, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) {
printf ("open_port: Unable to open %s\n", SER_DEV1);
}
else fcntl(fd, F_SETFL, 0);
return (fd);
}
void init_port(int port_id) {
tcgetattr(port_id, &ser1_old); /* get the struct for old port settings */
bzero(ser1_new, sizeof(ser1_new)); /* clear struct for new port settings */
cfsetispeed(&ser1_new, BR1);
cfsetospeed(&ser1_new, BR1);
ser1_new.c_cflag |= (CLOCAL | CREAD); /* enable receiving, local state */
ser1_new.c_cflag &= ~PARENB;
ser1_new.c_cflag &= ~CSTOPB;
ser1_new.c_cflag &= ~CSIZE;
ser1_new.c_cflag |= CS8; /* set 8N1 */
ser1_new.c_cflag &= ~CRTSCTS; /* no flow control */
ser1_new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /* raw data input */
// ser1_new.c_oflag &= ~OPOST; /* raw data output */
// ser1_new.c_lflag = ICANON; /* input mode: non-canonical, no echo */
ser1_new.c_oflag = 0; /* raw output data */
ser1_new.c_iflag = IGNPAR | ICRNL; /* raw input data */
ser1_new.c_cc[VMIN]=1;
ser1_new.c_cc[VTIME]=0;
tcflush(port_id, TCIFLUSH); /* flush the buffer */
tcsetattr(port_id, TCSANOW, &ser1_new); /* set the new parameters */
}
void restore_port(int port_id) {
tcsetattr(port_id, TCSANOW, &ser1_old); /* restore the old port settings */
}
Kylix
3 linux下的delphi
Kylix
3。BLAND早期 linux下的 delphi,现在的linux也不一定支持了,怕误删除找不到了,所以放在这里。怀旧情节的人可下载了解一下。
参透Delphi_
Kylix
参透Delphi_
Kylix
Delphi.
Kylix
SOURCE
參透
KYLIX
﹐源碼
kylix
3序列号好的
kylix
3序列号 很不错的
Linux平台下运用
Kylix
开发数据库应用程序的方法.pdf
Linux平台下运用
Kylix
开发数据库应用程序的方法.pdf
其他开发语言
3,423
社区成员
15,635
社区内容
发帖
与我相关
我的任务
其他开发语言
其他开发语言 其他开发语言
复制链接
扫一扫
分享
社区描述
其他开发语言 其他开发语言
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章