S3C2440 GPS串口配置以及数据读写

S3C2440 GPS串口配置以及数据读写
参考文章:http://www.cnblogs.com/jason-lu/articles/3173988.html
      http://www.cnblogs.com/chengmin/p/3818133.html
      



gps模块用串口线与S3C2440的ttyS1串口连接

串口操作需要的头文件:
<span style="font-size:18px;">#include     <stdio.h>      /*标准输入输出定义*/
#include     <stdlib.h>     /*标准函数库定义*/
#include     <unistd.h>     /*Unix 标准函数定义*/
#include     <sys/types.h>  
#include     <sys/stat.h>   
#include     <fcntl.h>      /*文件控制定义*/
#include     <termios.h>    /*PPSIX 终端控制定义*/
#include     <errno.h>      /*错误号定义*/</span>
打开串口的方式:
<span style="font-size:18px;">int fd;
/*以读写方式打开串口*/
fd = open( "/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (-1 == fd){ 
/* 不能打开串口一*/ 
perror(" 提示错误!"); 
}</span>
设置串口参数:

串口参数使用termios结构体保存
struct termios
c_cflag 控制选项
c_lflag 行选项
c_iflag 输入选项
c_oflag 输出选项
c_cc 控制字符
c_ispeed 输入波特率(NEW)
c_ospeed
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值