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
相关文档:
内核中所有已分配的字符设备编号都记录在一个名为 chrdevs
散列表里。该散列表中的每一个元素是一个 char_device_struct 结构,它的定义如下:
static struct char_device_struct {
struct char_device_struct *next; // 指向散列冲突链表中的 ......
以下步骤均为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 ......
两家技术型Linux VPS供应商的技术文档 当我们为了节约成本而不得不选择Linux作为服务器系统,基础技术就成了我们最大的障碍,除了去Linux的相关论坛外,这里推荐两家VPS商的技术文档,他们的VPS价格很贵,但技术很好,技术文档的含金量甚至超过了那些Linux论坛。 第一个是Linode文档库(我使用Linode将近1年,很好): h ......
1。获得源代码
src 官网下载地址:ftp://ftp.qt.nokia.com/qt/source/
2009 年 10 月 1 日发布的 qt-x11-opensource-src-4.5.3.tar.gz,大小 122 Mb。
2。解压缩
tar xvfz qt-x11- ......
Qt 以其开源,免费,完全面向对象(很容易扩展),允许真正的组件编程以及可移植跨平台等诸多优势得到越来越多的开发人员的青睐。Qt
Creator 是 Nokia 官方推出的专门针对 Qt 开发的 IDE。本文详细介绍了 Linux 下 Qt Creator 的安装,并针对
Qt Creator 的使用举了一个 Hello World 级别的例子,希望对第一次接触 Qt Cre ......