Linux串口通信程序
毕业设计用到一些接口测试代码,其中就有串口的测试,这其中基本借鉴了华清远见那本书里面的代码,读串口程序交叉编译到开发板中,写串口程序在PC端执行。代码很简单,因为串口在linux下也只是个文件,只需要打开这文件进行读写操作就好了。其中使用了2个函数,分别是配置端口和打开端口的函数,这2个函数比较死,可移植性也比较强。
/******************************************
Filename : serial_read.c
Function : read with serial port
Author : wanxiao
Date : 2010-5-7
******************************************/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <stdlib.h>
int set_opt(int fd, int nSpeed, int nBits, char nEvent, int nStop);
int open_port(int fd, int comport);
int main(void)
{
int fd;
int nread , nwrite;
int i;
char buff[8];
fd_set rd;
if((fd = open_port(fd,1)) < 0)
{
perror("open_port error");
return ;
}
if((i = set_opt(fd,115200,8,'N',1)) < 0)
{
perror("set_opt error");
return ;
}
FD_ZERO(&rd);
FD_SET(fd,&rd);
while(FD_ISSET(fd,&rd))
{
if(select(fd+1,&rd,NULL,NULL,NULL) < 0){
perror("select");
}
else{
while((nread = read(fd,buff,8)) > 0)
{
printf("nread=%d,%s\n",nread,buff);
}
}
}
close(fd);
return ;
}
/******************************************
Filename : serial_write.c
Function : communication with serial port
Author : wanxiao
Date : 2010-5-7
******************************************/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <stdli
相关文档:
以下步骤均为root登录状态下进行执行。
一、卸载JDK
Linux会自带JDK,如果不使用自带版本的话需要卸载。
1、卸载系统自带的jdk版本
查看自带的jdk
#rpm -qa | grep gcj
看到如下信息:
libgcj-4.1.2-44.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
使用rpm -e -nodeps 命令删除上面查找的内容:
#rpm -e -nodep ......
2.1 安装JDK
2.1.1 检查Linux自带JDK
命令:rpm –q jdk
如果安装强制卸载
查看已经安装的jdk:
# rpm -qa|grep jdk ← 查看jdk的信息或直接执行
#rpm -qa|grep ......
1、安装所需的pcre库
tar zxvf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make && make install
2、安装包:
下载网址:http://www.lighttpd.net/
lighttpd-1.4.23.tar(版本:1.4.23)
3、解压与编译
tar zxvf lighttpd-1.4.23.tar.gz
cd lighttpd-1.4.23
./configure --prefix=/usr/local/lighttpd
......
PCI是外围设备互连(Peripheral Component Interconnect)的简称,作为一种通用的总线接口标准,它在目前的计算机系统中得到了非常广泛的应用。PCI提供了一组完整的总线接口规范,其目的是描述如何将计算机系统中的外围设备以一种结构化和可控化的方式连接在一起。
&nbs ......