Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 2
0
 public override void setCANDevice(CANBusAdapter adapterType)
 {
     if (adapterType == CANBusAdapter.LAWICEL)
     {
         canUsbDevice = new CANUSBDevice();
     }
     else if (adapterType == CANBusAdapter.ELM327)
     {
         Sleeptime = SleepTime.ELM327;
         canUsbDevice = new CANELM327Device() { ForcedBaudrate = m_forcedBaudrate };
     }
     else if (adapterType == CANBusAdapter.JUST4TRIONIC)
     {
         canUsbDevice = new Just4TrionicDevice() { ForcedBaudrate = m_forcedBaudrate };
     }
     else if (adapterType == CANBusAdapter.COMBI)
     {
         canUsbDevice = new LPCCANDevice();
     }
     else if (adapterType == CANBusAdapter.KVASER)
     {
         canUsbDevice = new KvaserCANDevice();
     }
     else if (adapterType == CANBusAdapter.MXWIFI)
     {
         canUsbDevice = new CANMXWiFiDevice() { ForcedBaudrate = m_forcedBaudrate }; ;
     }
     canUsbDevice.UseOnlyPBus = m_OnlyPBus;
     canUsbDevice.DisableCanConnectionCheck = m_DisableCanConnectionCheck;
     canUsbDevice.TrionicECU = ECU.TRIONIC8;
     canUsbDevice.onReceivedAdditionalInformation += new ICANDevice.ReceivedAdditionalInformation(canUsbDevice_onReceivedAdditionalInformation);
     canUsbDevice.onReceivedAdditionalInformationFrame += new ICANDevice.ReceivedAdditionalInformationFrame(canUsbDevice_onReceivedAdditionalInformationFrame);
     if (m_canListener == null)
     {
         m_canListener = new CANListener();
     }
     canUsbDevice.addListener(m_canListener);
     canUsbDevice.AcceptOnlyMessageIds = new List<uint> { 0x645, 0x7E0, 0x7E8, 0x311, 0x5E8 };
 }