嵌入式Linux下串口编程
嵌入式Linux下串口编程
一、配置内核
在嵌入式Linux下进行串口编程之前,先在内核中配置串口部分,如下:
Device Drivers--->
character devices--->
Serial drivers--->
<*>Samssung S3C2440/S3C2442 Serial port support
二、应用程序
C文件:
uart_init.c:打开设备、初始化串口(设置参数)
main.c:测试串口读写
头文件:
uart_init.h
Makfile
uart_init.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <error.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
int open_termios(char *dev)
{
int fd = -1;
if(-1 == (fd = open(dev,O_RDWR|O_NOCTTY|O_NONBLOCK)))
{
printf("open termios error!\n");
}
return fd;
}
int set_termios(int fd,long speed,char databit,char stopbit,char oebit)
{
struct termios newtio;
int err = -1;
//清零结构体
bzero(&newtio,sizeof(newtio));
//设置接收使能
newtio.c_cflag |= CLOCAL | CREAD;
// 设置数据位
switch(databit)
{
case 7:
&n
相关文档:
2.1.2 用NFS实现资源共享
前面讲的Samba是实现Linux主机之间、Windows和Linux之间实现资源共享的途径。而NFS是实现Linux主机之间共享的另一种途径。NFS最早使用在Sun服务器上,现在已经移植到各种类UNIX系统下了,Windows下也有相应的版本。相对Samba服务,NFS共享具有简单快速的特点,所以目前广泛用于类UNIX主机之间的资 ......
6)Linux程序设计入门--消息管理
前言:Linux下的进程通信(IPC)
Linux下的进程通信(IPC)
POSIX无名信号量
System V信号量
System V消息队列
System V共享内存
1。POSIX无名信号量 如果你学习过操作系统,那么肯定熟悉PV操作了.PV操作是原子
操作.也就是操作是不可以中断的,在一定的时间内,只能够有一个进程的� ......
1、Linux 基础
安装Linux操作系统
Linux文件系统
Linux常用命令
Linux启动过程详解
熟悉Linux服务能够独立安装Linux操作系统
能够熟练使用Linux系统的基本命令
认识Linux系统的常用服务安装Linux操作系统
Linux基本命令实践
设置Linux环境变量
定制Linux的服务 Shell 编程基础使用vi编辑文件
使用Emac ......
Linux下获得系统时间的C语言的实现方法
#include<time.h> //C语言的头文件
#include<stdio.h> //C语言的I/O
void main()
{
time_t now; //实例化time_t结构
struct tm *timenow; //实例化tm结构指针
time(&now);
//time函数读取现在� ......
linux 下集成 svn 至 eclipse 全过程
因为 java 跨平台,而 eclipse 是个纯 java 开发项目,所以此集成安装过程同样适用于 windows 系统.
第一步:下载集成 svn 至 eclipse 所需的包 site-1.6.5.zip(可以去官网 http://subclipse.tigris.org/ 下载,也可以去作者的 csdn 资源里下载 site-1.6.5.zip 插件)
第二步:将 si ......