Beispiel #1
0
        /// <summary>
        /// Cleans up connections and resources
        /// </summary>
        public override void Cleanup()
        {
            try
            {
                MM_EndPeriod(1);
                logger.Debug("Cleanup called in Trionic7");
                if (flash != null)
                {
                    flash.onStatusChanged -= flash_onStatusChanged;
                    flash.stopFlasher();
                    flash.cleanup();
                    flash = null;
                }
                if (kwpHandler != null)
                {
                    kwpHandler.EnableLog = false;
                    kwpHandler.closeDevice();
                }
                if (canUsbDevice != null)
                {
                    if (canUsbDevice is LPCCANDevice)
                    {
                        LPCCANDevice lpc = (LPCCANDevice)canUsbDevice;
                        lpc.disconnect();
                        canUsbDevice.close();
                        canUsbDevice = null;
                        logger.Debug("Closed LPCCANDevice in Trionic7");
                    }
                    else
                    {
                        canUsbDevice.close();
                        canUsbDevice = null;
                    }
                }
            }
            catch (Exception e)
            {
                logger.Debug(e.Message);
            }

            LogManager.Flush();
        }
Beispiel #2
0
        private void setFlasher()
        {
            KWPHandler.setKWPDevice(kwpDevice);
            kwpHandler = KWPHandler.getInstance();

            T7Flasher.setKWPHandler(kwpHandler);
            flash = new T7Flasher();
            flash.onStatusChanged += flash_onStatusChanged;
        }
Beispiel #3
0
 void flash_onStatusChanged(object sender, IFlasher.StatusEventArgs e)
 {
     CastInfoEvent(e.Info, ActivityType.ConvertingFile);
 }
Beispiel #4
0
        public bool openDevice()
        {
            bool opened = true;
            CastInfoEvent("Open called in Trionic7", ActivityType.ConvertingFile);
            MM_BeginPeriod(1);

            if (canUsbDevice is LPCCANDevice && m_UseFlasherOnDevice)
            {
                // connect to adapter
                LPCCANDevice lpc = (LPCCANDevice)canUsbDevice;

                if (lpc.connect())
                {
                    // get flasher object
                    flash = lpc.createFlasher();
                    logger.Debug("T7CombiFlasher object created");
                    CastInfoEvent("CombiAdapter ready", ActivityType.ConvertingFile);
                }
                else
                {
                    opened = false;
                }
            }
            else
            {
                if (kwpHandler.openDevice())
                {
                    CastInfoEvent("Canbus channel opened", ActivityType.ConvertingFile);

                    if (kwpHandler.startSession())
                    {
                        CastInfoEvent("Session started", ActivityType.ConvertingFile);
                    }
                    else
                    {
                        CastInfoEvent("Unable to start session. Wait for previous session to timeout (10 seconds) and try again!", ActivityType.ConvertingFile);
                        kwpHandler.closeDevice();
                        opened = false;
                    }
                }
                else
                {
                    CastInfoEvent("Unable to open canbus channel", ActivityType.ConvertingFile);
                    kwpHandler.closeDevice();
                    opened = false;
                }
            }

            if (!opened)
            {
                CastInfoEvent("Open failed in Trionic7", ActivityType.ConvertingFile);
                if (canUsbDevice != null)
                {
                    canUsbDevice.close();
                }
                MM_EndPeriod(1);
            }
            return opened;
        }
Beispiel #5
0
        public void setT7CANDevice(CANBusAdapter adapterType)
        {
            if (adapterType == CANBusAdapter.LAWICEL)
            {
                canUsbDevice = new CANUSBDevice();
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }
            else if (adapterType == CANBusAdapter.ELM327)
            {
                Sleeptime = SleepTime.ELM327;
                canUsbDevice = new CANELM327Device() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate, BaseBaudrate = BaseBaudrate };
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }
            else if (adapterType == CANBusAdapter.JUST4TRIONIC)
            {
                canUsbDevice = new Just4TrionicDevice() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate };
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                kwpHandler.ResumeAlivePolling();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }
            else if (adapterType == CANBusAdapter.COMBI)
            {
                canUsbDevice = new LPCCANDevice();
            }
            else if (adapterType == CANBusAdapter.LAWICEL_VCP)
            {
                canUsbDevice = new CANUSBDirectDevice() { ForcedComport = m_forcedComport, ForcedBaudrate = m_forcedBaudrate, BaseBaudrate = BaseBaudrate };
                kwpCanDevice = new KWPCANDevice();
                kwpCanDevice.setCANDevice(canUsbDevice);
                kwpCanDevice.EnableCanLog = m_EnableCanLog;
                KWPHandler.setKWPDevice(kwpCanDevice);
                if (m_EnableCanLog)
                {
                    KWPHandler.startLogging();
                }
                kwpHandler = KWPHandler.getInstance();
                try
                {
                    T7Flasher.setKWPHandler(kwpHandler);
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                    AddToCanTrace("Failed to set FLASHer object to KWPHandler");
                }
                flash = T7Flasher.getInstance();
                flash.onStatusChanged += flash_onStatusChanged;
                flash.EnableCanLog = m_EnableCanLog;
            }

            canUsbDevice.EnableCanLog = m_EnableCanLog;
            canUsbDevice.UseOnlyPBus = m_OnlyPBus;
            canUsbDevice.DisableCanConnectionCheck = m_DisableCanConnectionCheck;
            canUsbDevice.TrionicECU = ECU.TRIONIC7;
            canUsbDevice.onReceivedAdditionalInformation += new ICANDevice.ReceivedAdditionalInformation(canUsbDevice_onReceivedAdditionalInformation);
            //canUsbDevice.onReceivedAdditionalInformationFrame += new ICANDevice.ReceivedAdditionalInformationFrame(canUsbDevice_onReceivedAdditionalInformationFrame);
            //canUsbDevice.acceptOnlyMessageIds = new List<uint> { 0x258,0x238 }; //t7suite
        }
Beispiel #6
0
        /// <summary>
        /// Cleans up connections and resources in use by the TrionicCAN DLL
        /// </summary>
        public void Cleanup()
        {
            try
            {
                tmr.Stop();
                MM_EndPeriod(1);
                Console.WriteLine("Cleanup called in TrionicCAN");
                //m_canDevice.removeListener(m_canListener);
                if (m_canListener != null)
                {
                    m_canListener.FlushQueue();
                }
                if (flash != null)
                {
                    flash.onStatusChanged -= flash_onStatusChanged;
                    flash = null;
                }
                KWPHandler.stopLogging();
                if (kwpHandler != null)
                {
                    kwpHandler.SuspendAlivePolling();
                    kwpHandler.closeDevice();
                }
                if (canUsbDevice != null)
                {
                    if (canUsbDevice is LPCCANDevice)
                    {
                        LPCCANDevice lpc = (LPCCANDevice)canUsbDevice;
                        lpc.disconnect();
                        canUsbDevice.close();
                        canUsbDevice = null;
                        Console.WriteLine("Closed m_canDevice in TrionicCAN");
                    }
                    else
                    {
                        canUsbDevice.close();
                        canUsbDevice = null;
                    }
                }
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }

            TrionicCANLib.Log.LogHelper.Flush();
        }
Beispiel #7
0
        public bool openT7Device()
        {
            bool opened = true;
            CastInfoEvent("Open called in T7CAN", ActivityType.ConvertingFile);
            MM_BeginPeriod(1);

            if (canUsbDevice is LPCCANDevice)
            {
                // connect to adapter
                LPCCANDevice lpc = (LPCCANDevice)canUsbDevice;

                if (lpc.connect())
                {
                    // get flasher object
                    flash = lpc.createFlasher();
                    flash.EnableCanLog = m_EnableCanLog;

                    AddToCanTrace("T7CombiFlasher object created");
                    CastInfoEvent("CombiAdapter ready", ActivityType.ConvertingFile);
                }
                else
                {
                    opened = false;
                }

            }
            else if (canUsbDevice is CANUSBDevice || canUsbDevice is Just4TrionicDevice || canUsbDevice is CANELM327Device || canUsbDevice is CANUSBDirectDevice)
            {
                if (kwpHandler.openDevice())
                {
                    CastInfoEvent("Canbus channel opened", ActivityType.ConvertingFile);
                }
                else
                {
                    CastInfoEvent("Unable to open canbus channel", ActivityType.ConvertingFile);
                    kwpHandler.closeDevice();
                    opened = false;
                }

                if (kwpHandler.startSession())
                {
                    CastInfoEvent("Session started", ActivityType.ConvertingFile);
                }
                else
                {
                    CastInfoEvent("Unable to start session", ActivityType.ConvertingFile);
                    kwpHandler.closeDevice();
                    opened = false;
                }
            }

            if (!opened)
            {
                CastInfoEvent("Open failed in T7CAN", ActivityType.ConvertingFile);
                canUsbDevice.close();
                MM_EndPeriod(1);
            }
            return opened;
        }