我想获得串口的数据
该怎么做?但串口数据中包含特定字符串时,如出现 "游戏" 字符串时
能提醒用户

解决方案 »

  1.   

    监控串口数据内容呗,读取串口数据控件spcomm等
      

  2.   

    参考代码,未使用控件,定时读取串口数据。
       
      ClearCommError(com.vg_hcomm,dwError,@cs);
      if cs.cbInQue=0 then
        exit;
      if cs.cbInQue>sizeof(buf) then
        purgecomm(com.vg_hcomm,PURGE_RXCLEAR)
      else
      begin
        readfile(com.vg_hcomm,buf,cs.cbInQue,nbytesread,nil);
        s:='';
        for i:=0 to nbytesread-1 do
          s:=s+buf[i];
        if pos('游戏',s)>0 then
          //提醒用户
      end;