Esempio n. 1
0
 public void Run()
 {
     int inBufferCount;
     portManager = new SerialPortManager(socket, comPort, baudRate);
     try
     {
         portManager.OpenPort();
         while (true)
         {
             inBufferCount = socket.Receive(inBuffer);
             if (inBufferCount == 0) break;
             portManager.Send(inBuffer, inBufferCount);
         }
     }
     catch (Exception e)
     {
         Comm2IP.log.Error(e);
     }
     finally
     {
         if (portManager != null) portManager.ClosePort();
         try { socket.Close(); }
         catch { }
         try { portManager.ClosePort(); }
         catch { }
     }
 }
Esempio n. 2
0
        public void Run()
        {
            int inBufferCount;

            portManager = new SerialPortManager(socket, comPort, baudRate);
            try
            {
                portManager.OpenPort();
                while (true)
                {
                    inBufferCount = socket.Receive(inBuffer);
                    if (inBufferCount == 0)
                    {
                        break;
                    }
                    portManager.Send(inBuffer, inBufferCount);
                }
            }
            catch (Exception e)
            {
                Comm2IP.log.Error(e);
            }
            finally
            {
                if (portManager != null)
                {
                    portManager.ClosePort();
                }
                try { socket.Close(); }
                catch { }
                try { portManager.ClosePort(); }
                catch { }
            }
        }
Esempio n. 3
0
 public SocketManager(Socket socket, string comPort, int baudRate)
 {
     this.socket = socket;
     portManager = null;
     this.comPort = comPort;
     this.baudRate = baudRate;
 }
Esempio n. 4
0
 public SocketManager(Socket socket, string comPort, int baudRate)
 {
     this.socket   = socket;
     portManager   = null;
     this.comPort  = comPort;
     this.baudRate = baudRate;
 }