亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C#實(shí)現(xiàn)把指定數(shù)據(jù)寫(xiě)入串口

 更新時(shí)間:2015年06月16日 11:34:37   投稿:junjie  
這篇文章主要介紹了C#實(shí)現(xiàn)把指定數(shù)據(jù)寫(xiě)入串口,直接給出示例代碼,需要的朋友可以參考下
    public static bool WriteToSerialPort(byte[]byteArr)
    {
      SerialPort Com = newSerialPort();
      try
      {
        Com.ReadTimeout = 5000;
        Com.WriteTimeout = 5000;
        Com.PortName = "Com1";
        Com.BaudRate = 9600;
        Com.StopBits = StopBits.One;
        Com.Parity = Parity.None;
        Com.Open();
        Com.Write(byteArr, 0,byteArr.Length);
        return true;
      }
      catch(Exception ex)
      {
        return false;
      }
      finally
      {
        Com.Close();
      }      
    }

本例使用的是方法Write(Byte[]buffer, Int32 offset, Int32 count)。該方法使用緩沖區(qū)的數(shù)據(jù)將指定數(shù)量的字節(jié)寫(xiě)入串行端口。buffer為緩沖區(qū),offset表示從此處開(kāi)始將字節(jié)復(fù)制到端口,count表示要寫(xiě)入的字節(jié)數(shù)。

相關(guān)文章

最新評(píng)論