如何用labview做个串口调试助手(LabwindowsCVI练习串口调试助手1)
如何用labview做个串口调试助手(LabwindowsCVI练习串口调试助手1)GetCtrlVal (panelHandle PANEL_RING_4 &dataBits);GetCtrlVal (panelHandle PANEL_RING_3 &parity);本来想实现的功能还有运行灯,但是添加定时器后,运行特别缓慢,需要再查。GetCtrlVal (panelHandle PANEL_RING &portNum);GetCtrlVal (panelHandle PANEL_RING_2 &baudRate);
最近一直在忙其他事情,没有跟着教程学习,从昨天开始晚上有时间自己练习一下,一直想着自己做一个串口助手,只有把通信建立起来才能从板卡上读取数据,重复了很多遍才把界面做成下面的样子
串口调试助手主界面
现在能够实现的功能是,点击“打开端口”如果打开串口成功则部分控件自动隐藏,显示关闭端口;如果打开端口不成功,则在对应位置显示错误代码。
串口打开成功
本来想实现的功能还有运行灯,但是添加定时器后,运行特别缓慢,需要再查。
GetCtrlVal (panelHandle PANEL_RING &portNum);
GetCtrlVal (panelHandle PANEL_RING_2 &baudRate);
GetCtrlVal (panelHandle PANEL_RING_3 &parity);
GetCtrlVal (panelHandle PANEL_RING_4 &dataBits);
GetCtrlVal (panelHandle PANEL_RING_5 &stopBits);
ret = OpenComConfig(portNum "" baudRate parity dataBits stopBits 512 512);
if(ret < 0)
{
portOpenFlag = 0;
// printf("%s\r\n" GetRS232ErrorString(ret));
status_open = GetRS232ErrorString(ret);
SetCtrlVal(panelHandle PANEL_TEXTMSG status_open);
SetCtrlAttribute (panelHandle PANEL_TEXTMSG ATTR_VISIBLE 1);//显示控件
}
else
{
SetCtrlAttribute (panelHandle PANEL_RING ATTR_DIMMED 1);
SetCtrlAttribute (panelHandle PANEL_RING_2 ATTR_DIMMED 1);
SetCtrlAttribute (panelHandle PANEL_RING_3 ATTR_DIMMED 1);
SetCtrlAttribute (panelHandle PANEL_RING_4 ATTR_DIMMED 1);
SetCtrlAttribute (panelHandle PANEL_RING_5 ATTR_DIMMED 1);
// SetCtrlAttribute (panelHandle PANEL_opencom ATTR_DIMMED 1);
SetCtrlAttribute (panelHandle PANEL_opencom ATTR_VISIBLE 0);//隐藏控件
SetCtrlAttribute (panelHandle PANEL_closecom ATTR_DIMMED 0);
status_open = GetRS232ErrorString(ret);
SetCtrlVal(panelHandle PANEL_TEXTMSG status_open);
portOpenFlag = 1;
}