Exemple #1
0
        /// <summary>
        /// Removes the given message filter.
        /// </summary>
        /// <param name="filterID">Filter identifier returned from PassThruStartMsgFilter</param>
        public void StopMessageFilter(
            UInt32 filterId)
        {
            PassThruStatus status = this.implementation.PassThruStopMsgFilter(this.channelId, filterId);

            PassThruUtility.ThrowIfError(status);
        }
Exemple #2
0
        /// <summary>
        /// Stop the given periodic message.
        /// </summary>
        /// <param name="messageId">Periodic-message identifier returned by StartPeriodicMessage</param>
        public void StopPeriodicMessage(
            UInt32 messageId)
        {
            PassThruStatus status = this.implementation.PassThruStopPeriodicMsg(this.channelId, messageId);

            PassThruUtility.ThrowIfError(status);
        }
Exemple #3
0
        /// <summary>
        /// Open a J2534 device
        /// </summary>
        public void Open()
        {
            // Name is reserved, must be null.
            string name = null;

            PassThruStatus status = this.implementation.PassThruOpen(name, out this.deviceId);

            PassThruUtility.ThrowIfError(status);
        }
Exemple #4
0
        /// <summary>
        /// Send messages to the ECU.
        /// </summary>
        /// <remarks>
        /// This is a single-message hack to get around the marshaling problem w/ PassThruWriteMsgs.
        /// </remarks>
        /// <param name="messages">Pointer to message structures</param>
        /// <param name="timeout">Write timeout, in milliseconds.</param>
        public void WriteMessage(
            PassThruMsg message,
            TimeSpan timeout)
        {
            PassThruStatus status = this.implementation.PassThruWriteMsg(
                this.channelId,
                message,
                (UInt32)timeout.TotalMilliseconds);

            PassThruUtility.ThrowIfError(status);
        }
Exemple #5
0
        /// <summary>
        /// Read messages and indications from the receive buffer.
        /// </summary>
        /// <param name="message">Pointer to message structures</param>
        /// <param name="timeout">Read timeout, in milliseconds.</param>
        /// <returns>True if a message was read, false if not.</returns>
        public bool ReadMessage(
            PassThruMsg message,
            TimeSpan timeout)
        {
            PassThruStatus status = this.implementation.PassThruReadMsg(
                this.channelId,
                message,
                (UInt32)timeout.TotalMilliseconds);

            PassThruUtility.ThrowIfError(status);
            return(true);
        }
Exemple #6
0
        /// <summary>
        /// Retreive version strings from the PassThru DLL.
        /// </summary>
        /// <param name="DeviceID">Device identifier returned from PassThruOpen</param>
        /// <param name="firmwareVersion">Firmware version string.  Allocate at least 80 characters.</param>
        /// <param name="dllVersion">DLL version string.  Allocate at least 80 characters.</param>
        /// <param name="apiVersion">API version string.  Allocate at least 80 characters.</param>
        public void ReadVersion(
            out string firmwareVersion,
            out string dllVersion,
            out string apiVersion)
        {
            PassThruStatus status = this.implementation.PassThruReadVersion(
                this.deviceId,
                out firmwareVersion,
                out dllVersion,
                out apiVersion);

            PassThruUtility.ThrowIfError(status);
        }
Exemple #7
0
        /// <summary>
        /// Immediately queue the given message, and re-send at the specified interval.
        /// </summary>
        /// <param name="message">Pointer to a single message structure</param>
        /// <param name="interval">Interval between the start of successive transmissions, in milliseconds.  Valid range is 5-65535.</param>
        /// <returns>message ID</returns>
        public UInt32 StartPeriodicMessage(
            PassThruMsg message,
            TimeSpan interval)
        {
            UInt32         messageId;
            PassThruStatus status = this.implementation.PassThruStartPeriodicMsg(
                this.channelId,
                message,
                out messageId,
                (UInt32)interval.TotalMilliseconds);

            PassThruUtility.ThrowIfError(status);
            return(messageId);
        }
Exemple #8
0
        /// <summary>
        /// Opens a communication channel
        /// </summary>
        /// <param name="protocolId">See Protocol enumeration</param>
        /// <param name="Flags">See ConnectFlags enumeration</param>
        /// <param name="BaudRate">See BaudRate enumeration</param>
        /// <param name="pChannelID">Will be set to the id of the opened channel</param>
        /// <returns>See Status enumeration</returns>
        public PassThruChannel OpenChannel(
            PassThruProtocol protocolId,
            PassThruConnectFlags flags,
            PassThruBaudRate baudRate)
        {
            UInt32         channelId;
            PassThruStatus status = this.implementation.PassThruConnect(
                this.deviceId,
                protocolId,
                flags,
                baudRate,
                out channelId);

            PassThruUtility.ThrowIfError(status);
            return(PassThruChannel.GetInstance(this.implementation, channelId));
        }
Exemple #9
0
        /// <summary>
        /// Apply a flow-control filter to incoming messages.
        /// </summary>
        /// <param name="ChannelID">Channel identifier returned from PassThruConnect</param>
        /// <param name="FilterType">See FilterType enumeration</param>
        /// <param name="pMaskMsg">This message will be bitwise-ANDed with incoming messages to mask irrelevant bits.</param>
        /// <param name="pPatternMsg">This message will be compared with the masked messsage; if equal the FilterType operation will be applied.</param>
        /// <param name="pFlowControlMsg">Points to the CAN ID used for segmented sends and receives.</param>
        /// <param name="pFilterID">Upon return, will be set with an ID for the newly applied filter.</param>
        /// <returns>message filter ID</returns>
        public UInt32 StartFlowControlMessageFilter(
            PassThruMsg maskMessage,
            PassThruMsg patternMessage,
            PassThruMsg flowControlMessage)
        {
            UInt32         filterId;
            PassThruStatus status = this.implementation.PassThruStartMsgFilter(
                this.channelId,
                (UInt32)PassThruFilterType.FlowControl,
                maskMessage,
                patternMessage,
                flowControlMessage,
                out filterId);

            PassThruUtility.ThrowIfError(status);
            return(filterId);
        }
Exemple #10
0
        /// <summary>
        /// Send the right IoCtls to set up an SSM connection
        /// </summary>
        private void InitializeSsmIoCtl()
        {
            SetConfiguration P1Max    = new SetConfiguration(SetConfigurationParameter.P1Max, 2);
            SetConfiguration P3Min    = new SetConfiguration(SetConfigurationParameter.P3Min, 0);
            SetConfiguration P4Min    = new SetConfiguration(SetConfigurationParameter.P4Min, 0);
            SetConfiguration Loopback = new SetConfiguration(SetConfigurationParameter.Loopback, 1);

            SetConfiguration[] setConfigurationArray = new SetConfiguration[] { P1Max, P3Min, P4Min, Loopback };
            using (SetConfigurationList setConfigurationList = new SetConfigurationList(setConfigurationArray))
            {
                PassThruStatus status = this.implementation.PassThruIoctl(
                    this.channelId,
                    PassThruIOControl.SetConfig,
                    setConfigurationList.Pointer,
                    IntPtr.Zero);
                PassThruUtility.ThrowIfError(status);
            }
        }
Exemple #11
0
        /// <summary>
        /// Apply a pass/block filter to incoming messages.
        /// </summary>
        /// <param name="filterType">See FilterType enumeration</param>
        /// <param name="maskMessage">This message will be bitwise-ANDed with incoming messages to mask irrelevant bits.</param>
        /// <param name="patternMessage">This message will be compared with the masked messsage; if equal the FilterType operation will be applied.</param>
        /// <param name="pFilterID">Upon return, will be set with an ID for the newly applied filter.</param>
        /// <returns>message filter ID</returns>
        public UInt32 StartMessageFilter(
            PassThruFilterType filterType,
            PassThruMsg maskMessage,
            PassThruMsg patternMessage)
        {
            UInt32         filterId;
            PassThruMsg    flowControl = new PassThruMsg(PassThruProtocol.Iso9141);
            PassThruStatus status      = this.implementation.PassThruStartMsgFilter(
                this.channelId,
                (UInt32)filterType,
                maskMessage,
                patternMessage,
                flowControl,
                out filterId);

            PassThruUtility.ThrowIfError(status);
            return(filterId);
        }
Exemple #12
0
        /// <summary>
        /// Set up the filters for an SSM connection
        /// </summary>
        private void InitializeSsmFilter()
        {
            PassThruMsg maskMsg = new PassThruMsg();

            maskMsg.DataSize = 1;

            PassThruMsg patternMsg = new PassThruMsg();

            patternMsg.DataSize = 1;

            // Might need to make this a private member?
            UInt32 filterId;

            // ErrorInvalidMessage w/ OP20
            PassThruStatus status = this.implementation.PassThruStartMsgFilter(
                this.channelId,
                (UInt32)PassThruFilterType.Pass,
                maskMsg,
                patternMsg,
                null,
                out filterId);

            PassThruUtility.ThrowIfError(status);
        }
Exemple #13
0
        /// <summary>
        /// Close a J2534 device
        /// </summary>
        public void Close()
        {
            PassThruStatus status = this.implementation.PassThruClose(this.deviceId);

            PassThruUtility.ThrowIfError(status);
        }
Exemple #14
0
        /// <summary>
        /// Closes the communication channel
        /// </summary>
        public void Close()
        {
            PassThruStatus status = this.implementation.PassThruDisconnect(this.channelId);

            PassThruUtility.ThrowIfError(status);
        }