电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

串口通信代码VIP免费

串口通信代码_第1页
串口通信代码_第2页
串口通信代码_第3页
#include#include#include#include#include#include#include"串口通信.h"#definetext_length2048staticintconfig_handle;config_flag;portindex;port_open;RS232Error;comport;baudrate;parity;databits;stopbits;inputq;outputq;xmode;ctsmode;type;stringsize;bytes_sent;send_byte;send_mode;read_cnt;bytes_read;chardevicename[30];charsend_data[text_length];charread_data[text_length];chartbox_read_data[text_length];doubletimeout;staticvoid*callbackdata;staticintpanelHandle,graphpanel,config;voidComCallback(intCOMport,inteventMask,void*callbackdata);voidSetConfigParms();voidGetConfigParms();voidEnablePanelControls(int);voidSendAscii(void);voidSendByte(void);voidDisplayRS232Error(void);voidSetConfigParms(){SetCtrlVal(config_handle,CONFIG_COMPORT,comport);SetCtrlVal(config_handle,CONFIG_BAUDRATE,baudrate);SetCtrlVal(config_handle,CONFIG_PARITY,parity);SetCtrlVal(config_handle,CONFIG_DATABITS,databits);SetCtrlVal(config_handle,CONFIG_STOPBITS,stopbits);SetCtrlVal(config_handle,CONFIG_INPUTQ,inputq);SetCtrlVal(config_handle,CONFIG_OUTPUTQ,outputq);SetCtrlVal(config_handle,CONFIG_CTSMODE,ctsmode);SetCtrlVal(config_handle,CONFIG_XMODE,xmode);SetCtrlIndex(config_handle,CONFIG_COMPORT,portindex);}voidGetConfigParms(){GetCtrlVal(config_handle,CONFIG_COMPORT,&comport);GetCtrlVal(config_handle,CONFIG_BAUDRATE,&baudrate);GetCtrlVal(config_handle,CONFIG_PARITY,&parity);GetCtrlVal(config_handle,CONFIG_DATABITS,&databits);GetCtrlVal(config_handle,CONFIG_STOPBITS,&stopbits);GetCtrlVal(config_handle,CONFIG_INPUTQ,&inputq);GetCtrlVal(config_handle,CONFIG_OUTPUTQ,&outputq);GetCtrlVal(config_handle,CONFIG_CTSMODE,&ctsmode);GetCtrlVal(config_handle,CONFIG_XMODE,&xmode);GetCtrlVal(config_handle,CONFIG_TIMEOUT,&timeout);GetCtrlIndex(config_handle,CONFIG_COMPORT,&portindex);#ifdef_NI_unix_devicename[0]=0;#elseGetLabelFromIndex(config_handle,CONFIG_COMPORT,portindex,devicename);#endif}voidEnablePanelControls(intenable){SetCtrlAttribute(panelHandle,PANEL_SENDMODE,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_SENDDATA,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_SENDNUMBER,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_RECEIVENUMBER,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_RECEIVEDATA,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_STOPRECEIVE,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_CHECKDATA,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_CHECKGRAPH,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_FLUSHINPUT,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_FLUSHOUTPUT,ATTR_DIMMED,enable);SetCtrlAttribute(panelHandle,PANEL_DATA,ATTR_DIMMED,enable);}intmain(intargc,char*argv[]){if(InitCVIRTE(0,argv,0)==0)return-1;/*outofmemory*/if((panelHandle=LoadPanel(0,"串口通信.uir",PANEL))<0)return-1;DisplayPanel(panelHandle);RunUserInterface();DiscardPanel(panelHandle);return0;}intCVICALLBACKconfigcallback(intpanel,intcontrol,intevent,void*callbackData,inteventData1,inteventData2){switch(event){caseEVENT_COMMIT:config_handle=LoadPanel(panelHandle,"串口通信.uir",CONFIG);InstallPopup(config_handle);if(config_flag)/*Configurationdoneatleastonce.*/SetConfigParms();elseconfig_flag=1;break;}return0;}intCVICALLBACKsendmodecallback(intpanel,intcontrol,intevent,void*callbackData,inteventData1,in...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

文章天下+ 关注
实名认证
内容提供者

各种文档应有尽有

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部