예제 #1
0
 private void ThrowIfError(J2534Err status)
 {
     if (status != J2534Err.STATUS_NOERROR)
     {
         throw PassThruInterface.GetPassThruException();
     }
 }
예제 #2
0
        public int ReadBatteryVoltage()
        {
            int voltage = 0;
            var status  = PassThruInterface.ReadBatteryVoltage(DeviceId, ref voltage);

            return(voltage);
        }
예제 #3
0
        public void Disconnect()
        {
            if (Connected)
            {
                PassThruInterface.PassThruDisconnect(ChannelId);
            }

            Connected = false;
        }
예제 #4
0
        public void ClearRxBuffer()
        {
            if (!Connected)
            {
                throw new Exception("Pass thru device not connected");
            }

            PassThruInterface.ClearRxBuffer(channelId);
        }
예제 #5
0
        public unsafe void WriteMsgs(int timeout, params PassThruMsg[] msgs)
        {
            int numMsgs = 1;

            fixed(void *ptr = &msgs[0])
            {
                var status = PassThruInterface.PassThruWriteMsgs(channelId, new IntPtr(ptr), ref numMsgs, timeout);

                ThrowIfError(status);
            }
        }
예제 #6
0
        public void Connect()
        {
            if (!Opened)
            {
                throw new Exception("Pass thru device not opened");
            }
            var status = PassThruInterface.PassThruConnect(DeviceId, protocolID, ConnectFlag.CAN_29BIT_ID, BaudRate.CAN_500000, ref channelId);

            ThrowIfError(status);

            Connected = true;
        }
예제 #7
0
        public unsafe PassThruMsg[] ReadMsgs(int timeout, int numMsgs)
        {
            var msgs = new PassThruMsg[numMsgs];

            fixed(void *ptr = &msgs[0])
            {
                var status = PassThruInterface.PassThruReadMsgs(channelId, new IntPtr(ptr), ref numMsgs, timeout);

                ThrowIfError(status);
            }

            return(msgs);
        }
예제 #8
0
        public void Close()
        {
            if (Connected)
            {
                Disconnect();
            }

            if (Opened)
            {
                PassThruInterface.PassThruClose(DeviceId);
            }

            Opened = false;
        }
예제 #9
0
        public void Open()
        {
            var name = J2534Device.Name;
            var ptr  = Marshal.AllocHGlobal(name.Length);

            try
            {
                var status = PassThruInterface.PassThruOpen(J2534Device.Name, ref deviceId);

                ThrowIfError(status);

                Opened = true;
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
예제 #10
0
        public void ReadInfo()
        {
            if (!Connected)
            {
                throw new Exception("Pass thru device not connected");
            }

            var firmwareVersion = new StringBuilder(80);
            var dllVersion      = new StringBuilder(80);
            var apiVersion      = new StringBuilder(80);

            var status = PassThruInterface.PassThruReadVersion(DeviceId, firmwareVersion, dllVersion, apiVersion);

            FirmwareVersion = firmwareVersion.ToString();
            DllVersion      = dllVersion.ToString();
            ApiVersion      = apiVersion.ToString();

            ThrowIfError(status);
        }