예제 #1
0
파일: ITrionic.cs 프로젝트: herfemp/Trionic
        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;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Open the CAN device.
        /// </summary>
        /// <returns>True if the device was opened, otherwise false.</returns>
        public bool open()
        {
            Console.WriteLine("******* KWPCANDevice: Opening KWPCANDevice");

            bool retVal = false;

            Console.WriteLine("Opening m_canDevice");
            lock (m_lockObject)
            {
                Console.WriteLine("Lock passed: Opening m_canDevice");
                if (m_canDevice.open() == OpenResult.OK)
                {
                    Console.WriteLine("Adding listener");
                    m_canDevice.addListener(m_kwpCanListener);
                    retVal = true;
                }
                else
                {
                    retVal = false;
                }
            }
            Console.WriteLine("return value = " + retVal.ToString());
            return(retVal);
        }
예제 #3
0
        /// <summary>
        /// Open the CAN device.
        /// </summary>
        /// <returns>True if the device was opened, otherwise false.</returns>
        public override bool open()
        {
            logger.Debug("******* KWPCANDevice: Opening KWPCANDevice");

            bool retVal = false;

            logger.Debug("Opening m_canDevice");
            lock (m_lockObject)
            {
                logger.Debug("Lock passed: Opening m_canDevice");
                if (m_canDevice.open() == OpenResult.OK)
                {
                    logger.Debug("Adding listener");
                    m_canDevice.addListener(m_kwpCanListener);
                    retVal = true;
                }
                else
                {
                    retVal = false;
                }
            }
            logger.Debug("return value = " + retVal.ToString());
            return(retVal);
        }