//----------------------------------------------------------------------- // // Copyright © 2012 Nils Hammar. All rights reserved. // //----------------------------------------------------------------------- /* * Software to access vehicle information via the OBD-II connector. * * Copyright © 2012 Nils Hammar * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Alternative licensing is possible, see the licensing document. * * The above text may not be removed or modified. */ namespace SharedObjects.Api { /// /// Interface for handling one connection to the J2534 API. /// Notice: It is possible to have multiple connections, however only one per protocol family. /// public interface IPassThruConnection { /// /// Gets a string containing the last encountered error. /// string lastError { get; } /// /// Gets the Instance of the PassThruDevice that this PassThruConnection is applicable for. /// IPassThruDevice passThruDevice { get; } /// /// Get the flag indicating that the device has a disconnect bug in the API. /// /// 'true' if disconnect bug exists. bool disconnectBug(); /// /// Get array of possible connection flags for this connection. /// /// Array of flags. CanFlags[] getConnFlags(); /// /// Get array of possible message flags for this connection. /// /// Array of flags. CanFlags[] getMessageFlags(); /// /// Perform a connection. /// /// ID of protocol to use. /// Connection flags. /// Baudrate to connect with. /// Result status, 0=success. PassThruConstants.resultCode Gl_PassThruConnect(int ProtocolID, uint Flags, uint Baudrate); /// /// Disconnect the current connection. /// /// Result status, 0=success. PassThruConstants.resultCode Gl_PassThruDisconnect(); /// /// Perform IOCTL operation on connection. /// /// IOCTL operation. /// Pointer to out data to IOCTL. /// Pointer to result data from IOCTL. /// Result status, 0=success. unsafe PassThruConstants.resultCode Gl_PassThruIoctl(int IoctlID, void* pInput, void* pOutput); /// /// Read messages from the connection on the device. /// /// ID of protocol. /// Received message (out data). /// Number of messages to read and returns actual number of messages read. /// Timeout waiting for message. /// Result status, 0=success. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "2#", Justification = "Reviewed, intentional.")] PassThruConstants.resultCode Gl_PassThruReadMsgs(int protocolId, out IPassThruMsg msg, ref int numMsgs, int Timeout); /// /// Add a message filter. /// /// Type of filter. /// Mask message. /// Pattern message. /// Flow control message. /// ID of filter added. (out value) /// Result status, 0=success. PassThruConstants.resultCode Gl_PassThruStartMsgFilter(uint FilterType, IPassThruMsg maskMsg, IPassThruMsg patternMsg, IPassThruMsg flowControlMsg, out int msgId); /// /// Start sending of a periodic message. /// /// Message to send. /// ID of message (out value) /// Interval between transmissions. /// Result status, 0=success. PassThruConstants.resultCode Gl_PassThruStartPeriodicMsg(IPassThruMsg msg, out int msgID, int TimeInterval); /// /// Remove message filter. /// /// ID of filter to remove. /// Result status, 0=success. PassThruConstants.resultCode Gl_PassThruStopMsgFilter(int msgId); /// /// Stop sending a periodic message. /// /// ID of message. /// Result status, 0=success. PassThruConstants.resultCode Gl_PassThruStopPeriodicMsg(int MsgID); /// /// Write a message on the connection to the device. /// /// Message to write /// Number of messages. /// Timeout waiting to write message. /// Result status, 0=success. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "1#", Justification = "Reviewed, intentional.")] PassThruConstants.resultCode Gl_PassThruWriteMsgs(IPassThruMsg msg, ref int numMsgs, int Timeout); /// /// Add to message lookup table. /// /// Address to add. /// Result status, 0=success. PassThruConstants.resultCode IoctlAddToFunctMsgLookupTable(uint address); /// /// Clear message lookup table. /// /// Result status, 0=success. PassThruConstants.resultCode IoctlClearFunctMsgLookupTable(); /// /// Clear all filters. /// /// Result status, 0=success. PassThruConstants.resultCode IoctlClearMsgFilters(); /// /// Clear all periodic messages. /// /// Result status, 0=success. PassThruConstants.resultCode IoctlClearPeriodicMsgs(); /// /// Clear the RX buffer of the interface. /// /// Result status, 0=success. PassThruConstants.resultCode IoctlClearRxBuffer(); /// /// Clear the TX buffer of the interface. /// /// Result status, 0=success. PassThruConstants.resultCode IoctlClearTxBuffer(); /// /// Remove from message lookup table. /// /// Address to remove. /// Result status, 0=success. PassThruConstants.resultCode IoctlDeleteFromFunctMsgLookupTable(uint address); /// /// Perform a Fast Init. This is for protocol KWP2000. /// /// Protocol ID /// Source address to use. /// Result message from init. /// Result status, 0=success. PassThruConstants.resultCode IoctlFastInit(int protocol, uint srcaddress, out IPassThruMsg result); /// /// Perform a five baud init, used by ISO9141 and KWP2000 protocol. /// The returned keywords identifies which protocol it is. /// /// Target address. /// Number of received bytes. /// Keyword 1. /// Keyword 2. /// Result status, 0=success. PassThruConstants.resultCode IoctlFiveBaudInit(uint target, out uint outBytes, out uint keyword1, out uint keyword2); /// /// Get parameter using IOCTL. /// /// Parameter to get. /// Value of parameter. (out value) /// Result status, 0=success. PassThruConstants.resultCode IoctlGetParameter(uint parameter, out uint value); /// /// Read the programming voltage. /// /// Programming voltage. (out data) /// Result status, 0=success. PassThruConstants.resultCode IoctlReadProgVoltage(out uint value); /// /// Read battery voltage on interface. /// /// Battery voltage. (out parameter) /// Result status, 0=success. PassThruConstants.resultCode IoctlReadVbatt(out uint value); /// /// Specific IOCTL call to set data rate. /// /// Data rate to set. /// Result status, 0=success. PassThruConstants.resultCode IoctlSetDataRate(uint value); /// /// Set loopback flag on connection. /// /// 'true' if sent messages shall be looped back to sender. /// Result status, 0=success. PassThruConstants.resultCode IoctlSetLoopback(bool state); /// /// Set network line on interface. /// /// Network line to set. /// Result status, 0=success. PassThruConstants.resultCode IoctlSetNetworkLine(uint value); /// /// Set address of this node on the interface. /// /// Address to set. /// Result status, 0=success. PassThruConstants.resultCode IoctlSetNodeAddress(uint value); /// /// Set parameter using IOCTL. /// /// ID of parameter to set. /// Value of parameter to set. /// Result status, 0=success. PassThruConstants.resultCode IoctlSetParameter(uint parameter, uint value); } }