Ejemplo n.º 1
0
        public void Close()
        {
            //
            // Time to go...
            //

            runFlag = false;

            while (tncChannelList.Count > 0)
            {
                TNCChannel tmpC = tncChannelList[0];
                tmpC.Close();
                Thread.Sleep(200);   // Give Close a chance to finish.  W4PHS 23-Jan-2015
                tncChannelList.Remove(tmpC);
            }

            //
            // Close down any outbound queues.  Any threads waiting on those queues will be signaled
            //

            for (Int32 i = 0; i < 16; i++)
            {
                if (recvQs[i] != null)
                {
                    recvQs[i].enabled = false;
                    recvQs[i]         = null;
                }
            }

            if (!loopBackMode && !TCPMode) // We don't use the serial port in loopback mode
            {
                // Remove the event handler
                port.DataReceived -= comHandler;
            }

            receivePortDataQueue.enabled = false;
            sendQ.enabled = false;

            if (TCPMode && client != null)                     // (JNW Feb15)
            {
                // Close TCP Connection

                netStream.Dispose();
                client.Close();
                Thread.Sleep(200);
            }

            if (!loopBackMode && !TCPMode) // We don't use the serial port in loopback mode
            {
                Thread.Sleep(200);
                port.DiscardInBuffer();
                port.DiscardOutBuffer();

                port.Close();
                Thread.Sleep(200);  // Give Close a chance to finish.  W4PHS 23-Jan-2015
                port.Dispose();

                Thread.Sleep(200);  // Give Close a chance to finish.  W4PHS 23-Jan-2015
            }
        }
Ejemplo n.º 2
0
        //
        // Constructor
        //

        public TNCChannelInterface(COMPort kissComPort, Int32 tncChannelNumber)
        {
            //
            // Create the object for communicating to the TNC via the specified TNC channel
            //

            channel        = new TNCChannel(kissComPort, tncChannelNumber);
            LinkRecvThread = new Thread(RecvFromPort);
            LinkRecvThread.Start();
        }
Ejemplo n.º 3
0
        public TNCChannel CreateChannel(Int32 channelNumber)
        {
            TNCChannel tmpChannel;

            //
            // Create a TNC channel on top of this com port
            //
            if (channelNumber < 0 || channelNumber > 15)
            {
                throw new Exception("Channel number must be between 0 and 15 inclusive");
            }
            tmpChannel = new TNCChannel(this, channelNumber);
            tncChannelList.Add(tmpChannel);
            recvQs[channelNumber] = new BlockingQueue(MAXQUEUESIZE);    // One receive queue for each channel
            return(tmpChannel);
        }
Ejemplo n.º 4
0
        //
        // Constructor
        //
        public DataLinkProvider(String callSign, TNCChannel channel)
        {
            _localTncChannel     = channel;
            _localStationAddress = new StationAddress(callSign);

            timerSegmenterHandler = new ElapsedEventHandler(timerSegmenter_Elapsed);
            timerSegmenter        = new Timer(timerSegmenterHandler, "UI Segmenter - " + _localStationAddress.stationIDString);

            timerSegmenter.SetTime(1000 * 60 * 10);     // 10 munite segmenter timeout

            timerTestCommandTimeoutHandler = new ElapsedEventHandler(timerTestCommandTimeout_Elapsed);
            timerTestCommandTimeout        = new Timer(timerTestCommandTimeoutHandler, "TestCommandTimeout - " + _localStationAddress.stationIDString);

            timerBeaconHandler = new ElapsedEventHandler(timerBeacon_Elapsed);
            timerBeacon        = new Timer(timerBeaconHandler, "Beacon for - " + _localStationAddress.stationIDString);
            //
            // Start processing
            //
            DataLinkThread      = new Thread(ProcessDLPackets);
            DataLinkThread.Name = "DataLinkProvider Packet Processing Thread for Station: " + _localStationAddress.stationIDString;
            DataLinkThread.Start();
        }