- 浏览: 318784 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (299)
- 私人 (3)
- linux (22)
- web service (1)
- java applet (1)
- java (41)
- c# (1)
- socket (1)
- android (10)
- htc (1)
- root (1)
- ftp (3)
- 系统备份 (0)
- jquery (3)
- 图表 (1)
- 实用 (4)
- web (9)
- css (3)
- java applet mplayer (1)
- mplayer (4)
- javascript (8)
- eclipse (1)
- 正则表达式 (1)
- jmf (1)
- tomcat (6)
- 驱动 (1)
- 嵌入式 (1)
- usb (3)
- ffmpeg (1)
- player (1)
- encode (1)
- ajax (1)
- 单纯形复法 (1)
- rom (1)
- ndk (1)
- 打印 (1)
- vs2010 (2)
- myeclipse注册机 (1)
- c++ (5)
- capture (0)
- 串口 (1)
- windows (2)
- mingw (1)
- 网卡 (1)
- 绿色版 (1)
- cywin (1)
- x264 (1)
- 恢复文件 (1)
- servlet init 连数据库 (1)
- 51 单片机 (1)
- 操作系统 (1)
- vlc (3)
- 网线 (1)
- CListBox (1)
- mfc (1)
- setTimer (1)
- 分屏 (1)
- 供求信息 (1)
- 导航 (1)
- 批处理 (1)
- dos (1)
- mysql (5)
- MySQL新建用户 (1)
- demo (1)
- vc (1)
- webservice (1)
- 书签 (1)
- 浏览器 (1)
- spring mvc (1)
- excel (1)
- VPN (0)
- sql (1)
- pdf (3)
- arp (1)
- jsp (2)
- IE (1)
- html (1)
- test (3)
- httpclient (1)
- spring mvc 上传 (1)
- easyui (1)
- mybatis (1)
- spring (1)
- 微信 (1)
- weixin (2)
- pay (2)
- maven (2)
- fastdfs (2)
- ELK (2)
- logstash (1)
- rocketMQ (0)
- jmeter (0)
- 测试 (0)
- softether (0)
- util (0)
最新评论
-
ice24:
ftp client applet -
wuzijingaip:
<div class="quote_title ...
ftp client applet -
zxcv193188:
感谢楼主
java JMF的使用 -
499700647:
你好,看了您的文章《ftp client aplet》很受启发 ...
ftp client applet -
JoeBaby_:
非常感谢,看文档的时候觉得JMF好难的样子,但是看过代码后思路 ...
java JMF的使用
#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> /*错误号定义*/ /***@brief 设置串口通信速率 *@param fd 类型 int 打开串口的文件句柄 *@param speed 类型 int 串口速度 *@return void*/ int speed_arr[] = { B38400, B19200, B9600, B4800, B2400, B1200, B300, B38400, B19200, B9600, B4800, B2400, B1200, B300, }; int name_arr[] = {38400, 19200, 9600, 4800, 2400, 1200, 300, 38400, 19200, 9600, 4800, 2400, 1200, 300, }; void 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); if (status != 0) perror("tcsetattr fd1"); return; } tcflush(fd,TCIOFLUSH); } } /** *@brief 设置串口数据位,停止位和效验位 *@param fd 类型 int 打开的串口文件句柄* *@param databits 类型 int 数据位 取值 为 7 或者8* *@param stopbits 类型 int 停止位 取值为 1 或者2* *@param parity 类型 int 效验类型 取值为N,E,O,,S */ int set_Parity(int fd,int databits,int stopbits,int parity) { struct termios options; if ( tcgetattr( fd,&options) != 0) { perror("SetupSerial 1"); return(FALSE); } options.c_cflag &= ~CSIZE; switch (databits) /*设置数据位数*/ { case 7: options.c_cflag |= CS7; break; case 8: options.c_cflag |= CS8; break; default: fprintf(stderr,"Unsupported data size\n"); return (FALSE); } switch (parity) { case 'n': case 'N': options.c_cflag &= ~PARENB; /* Clear parity enable */ options.c_iflag &= ~INPCK; /* Enable parity checking */ break; case 'o': case 'O': options.c_cflag |= (PARODD | PARENB); /* 设置为奇效验*/ options.c_iflag |= INPCK; /* Disnable parity checking */ break; case 'e': case 'E': options.c_cflag |= PARENB; /* Enable parity */ options.c_cflag &= ~PARODD; /* 转换为偶效验*/ options.c_iflag |= INPCK; /* Disnable parity checking */ break; case 'S': case 's': /*as no parity*/ options.c_cflag &= ~PARENB; options.c_cflag &= ~CSTOPB; break; default: fprintf(stderr,"Unsupported parity\n"); return (FALSE); } /* 设置停止位*/ switch (stopbits) { case 1: options.c_cflag &= ~CSTOPB; break; case 2: options.c_cflag |= CSTOPB; break; default: fprintf(stderr,"Unsupported stop bits\n"); return (FALSE); } /* Set input parity option */ if (parity != 'n') options.c_iflag |= INPCK; options.c_cc[VTIME] = 150; // 15 seconds options.c_cc[VMIN] = 0; tcflush(fd,TCIFLUSH); /* Update the options and do it NOW */ if (tcsetattr(fd,TCSANOW,&options) != 0) { perror("SetupSerial 3"); return (FALSE); } return (TRUE); } /** *@breif 打开串口 */ int OpenDev(char *Dev) { int fd = open( Dev, O_RDWR | O_NOCTTY | O_NDELAY); if (-1 == fd) { /*设置数据位数*/ perror("Can't Open Serial Port"); return -1; } else return fd; } /** *@breif main() */ int main(int argc, char **argv) { int fd; int nread; char buff[512]; char *dev ="/dev/ttyS1"; fd = OpenDev(dev); if (fd>0) set_speed(fd,19200); else { printf("Can't Open Serial Port!\n"); exit(0); } if (set_Parity(fd,8,1,'N')== FALSE) { printf("Set Parity Error\n"); exit(1); } while(1) { while((nread = read(fd,buff,512))>0) { printf("\nLen %d\n",nread); buff[nread+1]='\0'; printf("\n%s",buff); } } //close(fd); //exit(0); }
发表评论
-
在CentOS Linux系统的VPS中架设VPN图解教程
2014-03-28 17:10 440转自:http://www.laoyao.cc/post ... -
Mysql 启动服务
2014-03-21 18:37 578chkconfig --add mysqld chkc ... -
centos linux 服务器安全
2014-03-21 18:34 701转自:http://www.dedecms.com/knowl ... -
linux 修改ssh端口
2014-03-21 18:30 543首先修改配置文件 vi /etc/ssh/sshd_con ... -
linux下JAVA环境变量的设置
2014-03-21 14:05 495在终端中输入命令 vi /etc/profile.d/j ... -
linux安装JDK设置环境变量
2014-02-28 11:48 532配置JDK环境: 可以在/etc/profile 文件中添加 ... -
mysql-proxy 集群
2013-04-17 18:04 5本文转自网上,自己稍 ... -
mysql 主从同步(Master / Slave)
2013-04-17 12:06 3转自:[url] http: ... -
linux 分屏
2013-02-02 11:26 1019# nvidia-settings: X config ... -
linux 恢复误删除文件
2012-11-27 10:23 1067如果你不小心误删除了一个重要的文件,如rm -rf kkk , ... -
Linux双网卡绑定
2012-11-06 17:27 580Linux双网卡绑定实现就 ... -
linux 查找字符
2012-06-21 18:07 451grep who /use/local -r g ... -
linux alsa 声卡驱动
2012-05-09 17:53 803linux alsa 声卡驱动 -
vsftp 添加用户 简单步骤
2011-09-14 11:11 8401、rpm -i ftp包 (在安装盘中有) 2、启动 /sb ... -
Linux下用find查找并复制指定文件到指定目录下
2011-09-09 15:40 1612查找当前目录下的所有*.doc文件并将所有结果复制到 /tmp ... -
linux 自动登录
2011-08-24 17:08 818linux 自动登录 注意备份相应文件,此方法会有窗口无边框 ... -
usb linux copy
2011-05-24 11:51 216In order to boot from a USB d ... -
linux ssh tool
2011-05-17 10:58 625下载:http://www.onlinedown.net/so ... -
linux mount
2010-07-27 09:43 3379Linux系统在使用光盘、软盘或U盘时,必须先执行挂载(mou ... -
linux 系统 考贝
2010-07-27 09:25 770转自http://www.lpfrx.com/archives ...
相关推荐
linux串口编程:Linux环境下串口通信的编程
嵌入式 linux 串口编程 熟悉了解linux下的串口编程
Linux串口编程,结合ESP8266WIFI模块,实现开发板之间的wifi通信。本工程使用c语言对串口进行编程,运用read,write函数对串口进行AT指令发送以及数据传输。同时,也包含了对termios结构体的运用。
Linux串口编程详解,详细介绍了串口通讯类型,协议 相关api的使用
linux串口编程(中嵌教育-嵌入式linux开发课件)
linux串口编程 非阻塞read 打包write 设备打开 串口配置
Linux 串口编程详解(cn)
linux串口编程示例3
Linux串口编程分析--Linux串口编程分析--Linux串口编程分析
linux串编程实例源码,实现串口的基本配置和通过配置文件修改串口配置,在工程中稍微修改即可使用,去掉重复工作代码.
Linux串口编程分析 这个话题,大家可能再熟悉不过了,网上资料很多,因为这是linux下编程比较重要的一个方面,懂这方面的人很多;这里我只是想给初学者简单的介绍下这方面的知识: 串口编程其实说白了,是拿根串口线...
linux串口应用开发 1.串口概述 2.串口设置 3.串口使用详解
linux串口编程发送数据,C语言编写,gcc编译通过
内容包括: Serial-HOWTO.pdf serialportinfo.pdf SerialProgrammingInPosixOSs.pdf serialportinfo.pdf
linux 串口编程教程
linux串口编程,是关于串口房门的详细使用,可以参照使用