コード例 #1
0
 private void ReadThread()
 {
     byte[] oneByte = new byte[1];
     while (true)
     {
         try
         {
             int count = _stream.Read(oneByte);
             if (count == 1)
             {
                 this.DataReceived(this, oneByte);
             }
             else if (count == -1)
             {
                 throw new Exception("need to restart the port");
             }
         }
         catch
         {
             _port.Deactivate();
             Thread.Sleep(300);
             _port = new Cdc();
             Controller.ActiveDevice = _port;
             _stream = _port.Stream;
         }
     }
 }
コード例 #2
0
 private void ReadThread()
 {
     byte[] oneByte = new byte[1];
     while (true)
     {
         try
         {
             int count = _stream.Read(oneByte);
             if (count == 1)
                 this.DataReceived(this, oneByte);
             else if (count == -1)
                 throw new Exception("need to restart the port");
         }
         catch
         {
             _port.Deactivate();
             Thread.Sleep(300);
             _port = new Cdc();
             Controller.ActiveDevice = _port;
             _stream = _port.Stream;
         }
     }
 }
コード例 #3
0
 public UsbCommunicationChannel(Cdc port)
 {
     _port = port;
     _stream = _port.Stream;
     new Thread(ReadThread).Start();
 }
コード例 #4
0
 public UsbCommunicationChannel(Cdc port)
 {
     _port   = port;
     _stream = _port.Stream;
     new Thread(ReadThread).Start();
 }