资源简介
调试过了,可以用的,针对不同的模块自己修改下就好了。不懂可以咨询我

代码片段和文件信息
#include “pf_gps.h“
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef struct
{
char *dev_path;
pthread_t gps_thread;
int gps_fd;
int gps_client_fd;
int gps_server_fd;
void *user_param;
int user_param_len;
gps_call_back_fun call_back_fun;
//gps_data_t* back_gps_data;
}gps_classe;
#define FALSE 0
#define TRUE 1
#define MAX_GPS_CMD_BYTES 255
gps_classe tty_gps;
gps_data_t* back_gps_data;
/***@brief 设置串口通信速率
*@param fd 类型 int 打开串口的文件句柄
*@param speed 类型 int 串口速度
*@return void*/
static int speed_arr[] = {B500000 B460800 B230400 B115200 B57600 B38400 B19200 B9600 B4800 B2400 B1200 B300
B57600 B38400 B19200 B9600 B4800 B2400 B1200 B300 };
static int name_arr[] = {500000 460800 230400 115200 57600 38400 19200 9600 4800 2400 1200 300
57600 38400 19200 9600 4800 2400 1200 300 };
static void uart_set_speed(int fd int speed)//设置波特率
{
int i;
int status;
struct termios Opt;
tcgetattr(fd &Opt);
for( i= 0; i < sizeof(speed_arr) / sizeof(int); i++)
{
if(speed == name_arr[i])
{
tcflush(fd TCIOFLUSH);
cfsetispeed(&Opt speed_arr[i]);//输入波特率函数
cfsetospeed(&Opt speed_arr[i]);//输出波特率函数
status = tcsetattr(fd TCSANOW &Opt);//TCSANOW 不等数据传输完毕就立即改变属性。激活波特率的配置
if(status != 0)
perror(“tcsetattr fd1“);
return;
}
tcflush(fdTCIOFLUSH);
}
}
/**
*@breif 打开串口
*/
static int uart_open(char *Dev int open_flags)
{
struct termios opt;
printf(“open successful123\n“);
int fd = open(Dev open_flags); //
if (-1 == fd)
{
perror(“Can‘t Open Serial Port“);
return -1;
}
printf(“open successful\n“);
fflush(stdout);
tcgetattr (fd &opt);//tcgetattr函数用于获取与终端相关的参数
// opt.c_lflag &= ~(ICANON | ECHO | ISIG);
opt.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
/*
* No SIGINT on BREAK CR-to-NL off input parity
* check off don‘t strip 8th bit on input output
* flow control off.
*/
// opt.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
opt.c_iflag &= ~(BRKINT | ICRNL);
opt.c_oflag &= ~(OPOST);
tcsetattr (fd TCSANOW &opt);
tcflush(fd TCIOFLUSH);
return fd;
}
/**
*@brief 设置串口数据位,停止位和效验位
*@param fd 类型 int 打开的串口文件句柄*
*@param databits 类型 int 数据位 取值 为 7 或者8*
*@param stopbits 类型 int 停止位 取值为 1 或者2*
*@param parity 类型 int 效验类型 取值为NEOS
*/
static int uart_set_param(int fdint databitsint stopbitsint parity int flow int read_len)
{
struct termios options;
if( tcgetattr( fd&options) != 0)
{
perror(“SetupSerial 1“);
return
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 27743 2012-05-21 14:51 gps.c
文件 1368 2012-05-18 19:29 pf_gps.h
文件 5003 2012-05-15 14:40 pf_hi.h
相关资源
- 欧姆龙CP1系列单轴定位PLC程序.cxp
- 5G室内融合定位白皮书
- STM32蓝牙和串口程序
- LCD显示温度+串口接收温度.rar
- WPF USB 网络 串口 通信软件
- DELPHI与西门子200PLC的串口通信实例
- Verilog FPGA UART串口控制器
- USB转串口驱动,FT232R驱动程序,最新
- 武汉大学 科傻GPS 静态后处理软件
- PC -- 单片机的串口数据传输系统设计
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- PC 串口调试软件
- 51单片机读取温度数据存储到SD卡中并
- 单片机与PC机串口通讯仿真
- 串口调试助手V5.0
- 双串口调试助手 V4.0 _ 可同时调试两个
- 读取串口数据并画实时曲线的VC 程序
- 开源的nmealib
- 网络(UDP)转串口程序
- 串口绘制曲线 将收到的数据进行曲线
- 基于ARM蓝牙传输源程序
- JS操作本地网页串口源码
- 相干与非相干实现捕获与跟踪GPS
- AT89S ISP下载编程软件(串口)
- 串口操作类(justinio)
- 文本特征码定位器,无毒无副作用
- 天文钟GPS对时程序
- 《Visual Basic 串口通信与测控应用技术
- 耀华XK3190-A9地磅串口代码
评论
共有 条评论