Exemple #1
0
        public void LogCANData(object sender, DoWorkEventArgs workEvent)
        {
            BackgroundWorker bw = sender as BackgroundWorker;

            if (!canUsbDevice.isOpen())
            {
                return;
            }

            if (m_canLogListener == null)
            {
                m_canLogListener = new CANListener();
            }
            canUsbDevice.AcceptOnlyMessageIds = null;
            canUsbDevice.addListener(m_canLogListener);

            while (true)
            {
                m_canLogListener.waitMessage(1000);

                if (bw.CancellationPending)
                {
                    canUsbDevice.removeListener(m_canLogListener);
                    m_canLogListener = null;
                    workEvent.Cancel = true;
                    return;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Close the CAN device.
        /// </summary>
        /// <returns>True if the device was closed, otherwise false.</returns>
        public bool close()
        {
            Console.WriteLine("******* KWPCANDevice: Closing KWPCANDevice");

            bool retVal = false;

            lock (m_lockObject)
            {
                if (m_canDevice.close() == CloseResult.OK)
                {
                    retVal = true;
                }
                else
                {
                    retVal = false;
                }
                m_canDevice.removeListener(m_kwpCanListener);
            }
            return(retVal);
        }
Exemple #3
0
        /// <summary>
        /// Close the CAN device.
        /// </summary>
        /// <returns>True if the device was closed, otherwise false.</returns>
        public override bool close()
        {
            logger.Debug("******* KWPCANDevice: Closing KWPCANDevice");

            bool retVal = false;

            lock (m_lockObject)
            {
                if (m_canDevice.close() == CloseResult.OK)
                {
                    retVal = true;
                }
                else
                {
                    retVal = false;
                }
                m_canDevice.removeListener(m_kwpCanListener);
            }
            return(retVal);
        }