Esempio n. 1
0
        public void ConnectISO15765()
        {
            Connect();

            byte[] value;
            J2534Status = J2534Interface.PassThruConnect(DeviceId, ProtocolID.ISO15765, ConnectFlag.NONE, BaudRate.ISO15765, ref ChannelId);
            if (J2534Err.STATUS_NOERROR != J2534Status)
            {
                throw new J2534Exception(J2534Status);
            }

            //List<SConfig> configBits = new List<SConfig>();
            //SConfig conf = new SConfig();
            //conf.Parameter = ConfigParameter.LOOPBACK;
            //conf.Value = 0;
            //SConfig conf1 = new SConfig();
            //conf1.Parameter = ConfigParameter.DATA_RATE;
            //conf1.Value = 0;

            //configBits.Add(conf);
            //configBits.Add(conf1);
            //m_status = m_j2534Interface.GetConfig(m_channelId, ref configBits);


            int filterId = 0;

            byte i;

            for (i = 0; i < 1; i++)
            {
                PassThruMsg maskMsg        = new PassThruMsg(ProtocolID.ISO15765, TxFlag.ISO15765_FRAME_PAD, new byte[] { 0xff, 0xff, 0xff, 0xff });
                PassThruMsg patternMsg     = new PassThruMsg(ProtocolID.ISO15765, TxFlag.ISO15765_FRAME_PAD, new byte[] { 0x00, 0x00, 0x07, (byte)(0xE8 + i) });
                PassThruMsg flowControlMsg = new PassThruMsg(ProtocolID.ISO15765, TxFlag.ISO15765_FRAME_PAD, new byte[] { 0x00, 0x00, 0x07, (byte)(0xE0 + i) });

                J2534Status = J2534Interface.PassThruStartMsgFilter(
                    ChannelId,
                    FilterType.FLOW_CONTROL_FILTER,
                    maskMsg.ToIntPtr(),
                    patternMsg.ToIntPtr(),
                    flowControlMsg.ToIntPtr(),
                    ref filterId);

                if (J2534Err.STATUS_NOERROR != J2534Status)
                {
                    J2534Interface.PassThruDisconnect(ChannelId);
                    throw new J2534Exception(J2534Status);
                }
            }

            //Check we can read some PIDs back
            ReadObdPid(OBDcmd.Mode.REQUEST_CURRENT_DATA, out value);
            if (value.Length <= 0)
            {
                //m_status = j2534Interface.PassThruDisconnect(channelId);
                //throw new OBDException(OBDcmd.Response.NEGATIVE_RESPONSE);
            }

            ProtocolId = ProtocolID.ISO15765;
        }
Esempio n. 2
0
        public bool ConnectIso15765()
        {
            List <byte> value = new List <byte>();

            m_status = m_j2534Interface.PassThruConnect(m_deviceId, ProtocolID.ISO15765, ConnectFlag.NONE, BaudRate.ISO15765, ref m_channelId);
            if (J2534Err.STATUS_NOERROR != m_status)
            {
                return(false);
            }

            int filterId = 0;

            byte i;

            for (i = 0; i < 1; i++)
            {
                PassThruMsg maskMsg        = new PassThruMsg(ProtocolID.ISO15765, TxFlag.ISO15765_FRAME_PAD, new byte[] { 0xff, 0xff, 0xff, 0xff });
                PassThruMsg patternMsg     = new PassThruMsg(ProtocolID.ISO15765, TxFlag.ISO15765_FRAME_PAD, new byte[] { 0x00, 0x00, 0x07, (byte)(0xE8 + i) });
                PassThruMsg flowControlMsg = new PassThruMsg(ProtocolID.ISO15765, TxFlag.ISO15765_FRAME_PAD, new byte[] { 0x00, 0x00, 0x07, (byte)(0xE0 + i) });

                m_status = m_j2534Interface.PassThruStartMsgFilter(
                    m_channelId,
                    FilterType.FLOW_CONTROL_FILTER,
                    maskMsg.ToIntPtr(),
                    patternMsg.ToIntPtr(),
                    flowControlMsg.ToIntPtr(),
                    ref filterId);

                if (J2534Err.STATUS_NOERROR != m_status)
                {
                    m_j2534Interface.PassThruDisconnect(m_channelId);
                    return(false);
                }
            }

            if (!ReadObdPid(0x01, 0x00, ProtocolID.ISO15765, ref value))
            {
                m_j2534Interface.PassThruDisconnect(m_channelId);
                return(false);
            }
            return(true);
        }