欢迎来到天天文库
浏览记录
ID:8802240
大小:204.00 KB
页数:14页
时间:2018-04-08
《用于mini2440与周立功非接触式ic卡模块的通信》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、一个在linux下的串口程序例子 用于mini2440与周立功非接触式ic卡模块的通信头文件#include#include#include#include#include#include#include#include#include#include#includeclassCardreader:publicQThread{ Q_OBJECTpublic:
2、 Cardreader(); intfd_port; intopen_port(intcomport); intset_opt(intfd,intnSpeed,intnBits,charnEvent,intnStop); intinitcardreader(intfd_port); unsignedintcheckcard(intfd_port); unsignedintreadcardid(intfd_port); intbeep(intfd_port); voidautorun(void); voidsendmessage(intda
3、ta);signals: voidmessage(QString);protected:private:};cpp文件#include"cardreader.h"Cardreader::Cardreader(){}intCardreader::open_port(intcomport){ /*打开端口成功返回文件描述符失败返回0*/ /*openCOMPort*/ /*comport=1openCOM1comport=2openCOM2comport=3openCOM3*/ //char*dev[]={"/dev/ttySAC0",
4、"/dev/ttySAC1","/dev/ttySAC2"}; long vdisable; intfd; if(comport==1) { fd=open("/dev/ttySAC0",O_RDWR
5、O_NOCTTY
6、O_NDELAY); if(0==fd) { emitmessage("Openporterror1"); return(0); }
7、 } elseif(comport==2) { fd=open("/dev/ttySAC1",O_RDWR
8、O_NOCTTY
9、O_NDELAY); if(0==fd) { emitmessage("Openporterror1"); return(0); } } elseif(comport==3) { fd=open
10、("/dev/ttySAC2",O_RDWR
11、O_NOCTTY
12、O_NDELAY); if(0==fd) { emitmessage("Openporterror1"); return(0); } } if(fcntl(fd,F_SETFL,0)<0) { emitmessage("Openporterror2"); re
13、turn(0); } if(isatty(STDIN_FILENO)==0) { emitmessage("Openporterror3"); //return(0); } returnfd;}intCardreader::set_opt(intfd,intnSpeed,intnB
此文档下载收益归作者所有