Linux下串口编程之二:读串口和写串口
1,打开串口
/**打开串口,dev 串口设备名, mode 打开方式,**/
int opendev(char *dev,mode_t mode)
{
int fd;
fd = open(dev, mode);
if (-1 == fd){
perror("Can't Open Serial Port");
return -1;
}
else{
fcntl(fd, F_SETFL, FNDELAY);
return fd;
}
}
2,写串口
#define FALSE -1
#define TRUE 0
#define NET_PORT 19988
#define MAX_BUF_SIZE 4096
struct net2net_buf{
int len;
char buf[MAX_BUF_SIZE];
};
#define RSDEV_NAME "/dev/ttyS1"
int main(void)
{
int rsfd = 0;
int nwrite;
char input_buf[64];
rsfd = opendev(RSDEV_NAME,O_RDWR | O_NOCTTY |
相关文档:
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
所谓“阅兵”就是检阅部队的意思。
Linux
大军(发行版)可谓“散兵游勇”,谈何大阅兵?此言差矣。
......
目录结构为:
inc/hello.h
src/hello.c
main/main.c
Makefile
文件内容为:
hello.h:
void hello(char name[]);
hello.c:
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}
main.c:
#include <stdio.h>
#include "hello.h"
// The second hello.h should ......
在Linux中,如果要让进程在后台运行,一般情况下,我们在命令后面加上&即可,实际上,这样是将命令放入到一个作业队列中了:
[root@localhost /]# ./test.sh &
[1] 17208
然后我们就可以用以下命令进行查看:
[root@localhost /]# jobs -l
[1] 17208 Running ./test.sh &
对于已经在前台执行的命令 ......
安装程序所需要的共享库时需要注意的问题。
起因:安装libsqlite3.so.0 后,使用ldd test 时,却找不到该库文件。
在使用cpptest对原程序运行单元测试时,发现错误,即找不到库文件。
安装完libsqlite3.so.0后,其是存储在usr/local/lib的。所以问题在于,linux下的装载程序 ......
一、修改IP、网关
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.117
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
二、修改DNS
[root@lvs_master ~]# vi /etc/resolv.conf
n ......