示例#1
0
        /// <summary>
        ///     Read data from port
        /// </summary>
        /// <returns>Byte array with data</returns>
        public byte[] ReadBytes()
        {
            var data = new byte[BytesToRead];

            Read(data, 0, data.Length);
            return(ByteStuffer.Decode(data));
        }
示例#2
0
 /// <summary>
 ///     Write data to port
 /// </summary>
 /// <param name="dataBytes">Byte array with data</param>
 public void WriteData(byte[] dataBytes)
 {
     while (true)
     {
         if (BytesToRead == 0)
         {
             var temp = ByteStuffer.Encode(dataBytes);
             Write(temp, 0, temp.Length);
             Thread.Sleep(100);
             RtsEnable = false;
         }
         else
         {
             LostBytes = ReadBytes();
             continue;
         }
         break;
     }
 }