public void OpenECUConnection()
        {
            if (m_RunInEmulationMode)
            {
                m_Engine.InitializeEngine();
                m_Engine.StartEngine();
                _opened = true;
            }
            if (!_opened)
            {
                _opened = true;
                //if (_sramDumpFile == string.Empty)
                //{
                if (_tcan == null)
                {
                    _tcan = new T5CANLib.T5CAN();
                    if (_canusbDevice == "Multiadapter" || _canusbDevice == "CombiAdapter")
                    {
                        _usbcandevice = new T5CANLib.CAN.LPCCANDevice_T5();
                    }
                    else if (_canusbDevice == "DIY")
                    {
                        _usbcandevice = new T5CANLib.CAN.MctCanDevice();
                    }
                    else if (_canusbDevice == "Just4Trionic")
                    {
                        _usbcandevice = new T5CANLib.CAN.Just4TrionicDevice();
                    }
                    else if (_canusbDevice == "Kvaser")
                    {
                        _usbcandevice = new T5CANLib.CAN.KvaserCANDevice();
                    }
                    else     // default = Lawicel
                    {
                        _usbcandevice = new T5CANLib.CAN.CANUSBDevice();
                    }

                    _tcan.onWriteProgress += new T5CANLib.T5CAN.WriteProgress(OnWriteProgress);
                    _tcan.onCanInfo       += new T5CANLib.T5CAN.CanInfo(_tcan_onCanInfo);
                    _tcan.onReadProgress  += new T5CANLib.T5CAN.ReadProgress(_tcan_onReadProgress);
                    _tcan.setCANDevice(_usbcandevice);
                }
                if (!_tcan.openDevice(out _swversion))
                {
                    _opened = false;
                }

                /*if (_opened) // if can adapter opened successfully, try to contact the ECU
                 * {
                 *  byte[] testbyte = _tcan.readRAM(0x1000, 2);
                 *  if (testbyte.Length != 2) _opened = false;
                 *  Console.WriteLine(testbyte.Length.ToString() + " as result");
                 * }*/
                Console.WriteLine("OpenECUConnection: " + _swversion);
                //}
            }
            _stallReading = false;
        }
Esempio n. 2
0
 private void Form1_Shown(object sender, EventArgs e)
 {
     //DeleteFile();
     //AddToLog("Wakeup started");
     _tcan = new T5CANLib.T5CAN();
     //AddToLog("T5CAN created");
     _usbcandevice = new T5CANLib.CAN.CANUSBDevice();
     //AddToLog("CANUSBDevice created");
     _tcan.setCANDevice(_usbcandevice);
     //AddToLog("CANUSBDevice set");
     _tcan.openDevice(out _swversion);
     //AddToLog("CANUSBDevice open device called, exiting");
     Environment.Exit(0);
 }
Esempio n. 3
0
 private void Form1_Shown(object sender, EventArgs e)
 {
     //DeleteFile();
     //AddToLog("Wakeup started");
     _tcan = new T5CANLib.T5CAN();
     //AddToLog("T5CAN created");
     _usbcandevice = new T5CANLib.CAN.CANUSBDevice();
     //AddToLog("CANUSBDevice created");
     _tcan.setCANDevice(_usbcandevice);
     //AddToLog("CANUSBDevice set");
     _tcan.openDevice(out _swversion);
     //AddToLog("CANUSBDevice open device called, exiting");
     Environment.Exit(0);
 }