Пример #1
0
        private Loader()
        {
            AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            j2534library = new J2534Extended();

            var list = J2534Detect.ListDevices();

            j2534Device = list.FirstOrDefault(d => d.Name == Config.Instance.DeviceName);
            if (j2534Device == null)
            {
                if (list.Count == 1)
                {
                    j2534Device = list.Single();
                }
                else
                {
                    var sd = new SelectDevice();
                    if (sd.ShowDialog() == DialogResult.OK)
                    {
                        j2534Device = sd.Device;

                    }
                }
            }

            j2534library.LoadLibrary(j2534Device);
        }
Пример #2
0
        private Loader()
        {
            AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            j2534library = new J2534Extended();

            var list = J2534Detect.ListDevices();

            j2534Device = list.FirstOrDefault(d => d.Name == Config.Instance.DeviceName);
            if (j2534Device == null)
            {
                if (list.Count == 1)
                {
                    j2534Device = list.Single();
                }
                else
                {
                    var sd = new SelectDevice();
                    if (sd.ShowDialog() == DialogResult.OK)
                    {
                        j2534Device = sd.Device;
                    }
                }
            }

            j2534library.LoadLibrary(j2534Device);
        }
Пример #3
0
        private Loader()
        {
            AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            j2534library = new J2534Extended();

            var list = J2534Detect.ListDevices();

            if (list.Count == 1)
            {
                j2534Device = list.Single();
            }
            else
            {
                var sd = new SelectDevice();
                if (sd.ShowDialog() == DialogResult.OK)
                {
                    j2534Device = sd.Device;
                }
                else
                {
                    return;
                }
            }

            j2534library.LoadLibrary(j2534Device);
        }
Пример #4
0
 public Ford_SCP_Module(J2534Device Device)
 {
     device  = Device;
     session = new FordPWMSession(device);
     System.Random random = new System.Random();
     salt = (byte)random.Next(255);
 }
Пример #5
0
 public ISO15765_Session(J2534Device Device)
 {
     this.device = Device;
     channel     = device.ConstructChannel(J2534PROTOCOL.ISO15765, J2534BAUD.ISO15765, J2534CONNECTFLAG.NONE);
     if (channel.IsOpen)    //If channel is constructed successfully and is live
     {
         InitializeDefaultConfigs();
     }
 }
Пример #6
0
 public EsPassThruDevice(J2534Device j2534Device)
 {
     J2534Device       = j2534Device;
     PassThruInterface = new J2534Extended();
     if (!PassThruInterface.LoadLibrary(J2534Device))
     {
         throw new Exception($"Error load pass thru library: {J2534Device.FunctionLibrary}. Error: {new Win32Exception(Marshal.GetLastWin32Error()).Message}");
     }
 }
Пример #7
0
 public J1850PWM_Session(J2534Device Device)
 {
     this.device = Device;
     channel     = device.ConstructChannel(J2534PROTOCOL.J1850PWM, J2534BAUD.J1850PWM, J2534CONNECTFLAG.NONE);
     if (channel.IsOpen)    //If channel is constructed successfully and is open
     {
         SessionProtocol = J2534PROTOCOL.J1850PWM;
         InitializeDefaultConfigs();
     }
 }
Пример #8
0
 public FordPWMSession(J2534Device Device) : base(Device)
 {
 }
Пример #9
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     Device = (J2534Device)deviceList.SelectedItem;
     Close();
 }
Пример #10
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     Device = (J2534Device)deviceList.SelectedItem;
     Close();
 }
Пример #11
0
        public override void SetSelectedAdapter(string adapter)
        {
            J2534Device selected = availableJ2534Devices.Find(x => x.Name == adapter);

            passThru.LoadLibrary(selected);
        }
Пример #12
0
 public SAEChannelFactory(J2534Device Device)
 {
     device = Device;
 }
Пример #13
0
        bool LoadJ2534()
        {
            if (_passThru == null)
            {
                _passThru = new J2534Extended();
            }
            if (_passThru.IsLoaded)
            {
                return(true);
            }
            J2534Device j2534Device;

            // Find all of the installed J2534 passthru devices
            List <J2534Device> availableJ2534Devices = J2534Detect.ListDevices();

            if (availableJ2534Devices.Count == 0)
            {
                MessageBox.Show("Could not find any installed J2534 devices in the Windows registry, have you installed the device drivers for your cable?");
                _passThru.FreeLibrary();
                return(false);
            }

            if (autoDetectCheckBox.Checked)
            {
                foreach (var lib in availableJ2534Devices)
                {
                    if (Path.GetFileName(lib.FunctionLibrary).Contains("J2534DotNet.Logger.dll"))
                    {
                        continue;
                    }
                    try {
                        j2534Device = new J2534Device();
                        if (!_passThru.LoadLibrary(lib))
                        {
                            j2534Device = null;
                            continue;
                        }

                        _comm = new UDSFord(_passThru);
                        _comm.Connect();

                        //if we get this far then we have successfully connected
                        _comm.Disconnect();
                        return(true);
                    } catch {
                        j2534Device = null;
                        continue;
                    }
                }
                _passThru.FreeLibrary();
                return(false);
            }

            if (checkBoxLogJ2534.Checked)
            {
                j2534Device = new J2534Device();
                j2534Device.FunctionLibrary = System.IO.Directory.GetCurrentDirectory() + "\\" + "J2534DotNet.Logger.dll";
                Thread.Sleep(10);
                var loaded = _passThru.LoadLibrary(j2534Device);
                if (!loaded)
                {
                    _passThru.FreeLibrary();
                }
                return(loaded);
            }

            //If there is only one DLL to choose from then load it
            if (availableJ2534Devices.Count == 1)
            {
                return(_passThru.LoadLibrary(availableJ2534Devices[0]));
            }
            else
            {
                var sd = new SelectDevice();
                if (sd.ShowDialog() == DialogResult.OK)
                {
                    j2534Device = sd.Device;
                    var loaded = _passThru.LoadLibrary(j2534Device);
                    if (!loaded)
                    {
                        _passThru.FreeLibrary();
                    }
                    return(loaded);
                }
            }

            return(false);
        }