GetLastError() public method

public GetLastError ( ) : J2534Err
return J2534Err
コード例 #1
1
ファイル: Form1.cs プロジェクト: GeorgyPorgy/VMPT
        private void CmdReadVinClick(object sender, EventArgs e)
        {
            J2534 passThru = new J2534();
            string vin = "";

            // 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.");
                return;
            }

            // We will always choose the first J2534 device in the list, if there are multiple devices
            //   installed, you should do something more intelligent.
            passThru.LoadLibrary(availableJ2534Devices[0]);

            ObdComm comm = new ObdComm(passThru);
            if (!comm.DetectProtocol())
            {
                MessageBox.Show(String.Format("Error connecting to device. Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            if (!comm.GetVin(ref vin))
            {
                MessageBox.Show(String.Format("Error reading VIN.  Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            comm.Disconnect();

            // When we are done with the device, we can free the library.
            passThru.FreeLibrary();
            txtReadVin.Text = vin;
        }
コード例 #2
0
        /*
         *
         *  Use the J2534 protocol to read voltage
         *
         */
        private void CmdReadVoltageClick(object sender, EventArgs e)
        {
            J2534Extended passThru = null;// = Loader.Lib;
            double        voltage  = 0;

            // 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.");
                return;
            }

            ObdComm comm = new ObdComm(passThru);

            if (!comm.DetectProtocol())
            {
                MessageBox.Show(String.Format("Error connecting to device. Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            if (!comm.GetBatteryVoltage(ref voltage))
            {
                MessageBox.Show(String.Format("Error reading voltage.  Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            comm.Disconnect();

            // When we are done with the device, we can free the library.
            passThru.FreeLibrary();
            txtVoltage.Text = voltage + @" V";
        }
コード例 #3
0
        private void CmdReadVinClick(object sender, EventArgs e)
        {
            J2534Extended passThru = new J2534Extended();
            string        vin      = "";

            // 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.");
                return;
            }

            // We will always choose the first J2534 device in the list, if there are multiple devices
            //   installed, you should do something more intelligent.
            passThru.LoadLibrary(availableJ2534Devices[0]);

            ObdComm comm = new ObdComm(passThru);

            if (!comm.DetectProtocol())
            {
                MessageBox.Show(String.Format("Error connecting to device. Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            if (!comm.GetVin(ref vin))
            {
                MessageBox.Show(String.Format("Error reading VIN.  Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            comm.Disconnect();

            // When we are done with the device, we can free the library.
            passThru.FreeLibrary();
            txtReadVin.Text = vin;
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: mkelly/J2534DotNet
        /*
         *
         *  Use the J2534 protocol to read voltage
         *
         */
        private void CmdReadVoltageClick(object sender, EventArgs e)
        {
            J2534Extended passThru = null;// = Loader.Lib;
            double voltage = 0;

            // 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.");
                return;
            }

            ObdComm comm = new ObdComm(passThru);
            if (!comm.DetectProtocol())
            {
                MessageBox.Show(String.Format("Error connecting to device. Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            if (!comm.GetBatteryVoltage(ref voltage))
            {
                MessageBox.Show(String.Format("Error reading voltage.  Error: {0}", comm.GetLastError()));
                comm.Disconnect();
                return;
            }
            comm.Disconnect();

            // When we are done with the device, we can free the library.
            passThru.FreeLibrary();
            txtVoltage.Text = voltage + @" V";
        }