GetVin() public method

public GetVin ( string &vin ) : bool
vin string
return bool
Example #1
1
        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;
        }
Example #2
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;
        }