//----------------------------------------------------------------------- // // 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 DeviceApi.J2534 { using System.Collections.Generic; using global::SharedObjects.Protocol; /// /// Definition of PassThru IOCTL functions. /// public class IoctlFunction { /// /// IOCTL operation GET_CONFIG. /// public const int GET_CONFIG = 0x01; /// /// IOCTL operation SET_CONFIG. /// public const int SET_CONFIG = 0x02; /// /// IOCTL operation READ_VBATT. /// public const int READ_VBATT = 0x03; /// /// IOCTL operation FIVE_BAUD_INIT. /// public const int FIVE_BAUD_INIT = 0x04; /// /// IOCTL operation FAST_INIT. /// public const int FAST_INIT = 0x05; /// /// IOCTL operation CLEAR_TX_BUFFER. /// public const int CLEAR_TX_BUFFER = 0x07; /// /// IOCTL operation CLEAR_RX_BUFFER. /// public const int CLEAR_RX_BUFFER = 0x08; /// /// IOCTL operation CLEAR_PERIODIC_MSGS. /// public const int CLEAR_PERIODIC_MSGS = 0x09; /// /// IOCTL operation CLEAR_MSG_FILTERS. /// public const int CLEAR_MSG_FILTERS = 0x0a; /// /// IOCTL operation CLEAR_FUNCT_MSG_LOOKUP_TABLE. /// public const int CLEAR_FUNCT_MSG_LOOKUP_TABLE = 0x0b; /// /// IOCTL operation ADD_TO_FUNCT_MSG_LOOKUP_TABLE. /// public const int ADD_TO_FUNCT_MSG_LOOKUP_TABLE = 0x0c; /// /// IOCTL operation DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE. /// public const int DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE = 0x0d; /// /// IOCTL operation READ_PROG_VOLTAGE. /// public const int READ_PROG_VOLTAGE = 0x0e; /******************* Pointer Types. **********************/ /// /// NULL pointer type. /// public const int PTR_TYPE_NULL = 0x00; /// /// Pointer to SCONFIG_LIST. /// public const int PTR_TYPE_SCONFIG_LIST = 0x01; /// /// Pointer to SBYTE_ARRAY. /// public const int PTR_TYPE_SBYTE_ARRAY = 0x02; /// /// Pointer to PASSTHRU_MSG. /// public const int PTR_TYPE_PASSTHRU_MSG = 0x03; /// /// Pointer to ULONG (C# uint). /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "ulong", Justification = "The constant is used to describe a value type.")] public const int PTR_TYPE_ULONG_PTR = 0x04; // Should be unsigned 32-bit. /// /// Array of supported IOCTL functions. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1010:OpeningSquareBracketsMustBeSpacedCorrectly", Justification = "Reviewed.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1011:ClosingSquareBracketsMustBeSpacedCorrectly", Justification = "Reviewed.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1012:OpeningCurlyBracketsMustBeSpacedCorrectly", Justification = "Reviewed.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1013:ClosingCurlyBracketsMustBeSpacedCorrectly", Justification = "Reviewed.")] public static readonly IoctlFunction[] functions = { new IoctlFunction("GET_CONFIG", GET_CONFIG, PTR_TYPE_SCONFIG_LIST, PTR_TYPE_NULL), new IoctlFunction("SET_CONFIG", SET_CONFIG, PTR_TYPE_SCONFIG_LIST, PTR_TYPE_NULL), new IoctlFunction("READ_VBATT", READ_VBATT, PTR_TYPE_NULL, PTR_TYPE_ULONG_PTR), new IoctlFunction("FIVE_BAUD_INIT", FIVE_BAUD_INIT, PTR_TYPE_SBYTE_ARRAY, PTR_TYPE_SBYTE_ARRAY, new int []{Protocols.ISO9141, Protocols.ISO14230}), new IoctlFunction("FAST_INIT", FAST_INIT, PTR_TYPE_PASSTHRU_MSG, PTR_TYPE_PASSTHRU_MSG, new int []{Protocols.ISO9141, Protocols.ISO14230}), new IoctlFunction("CLEAR_TX_BUFFER", CLEAR_TX_BUFFER, PTR_TYPE_NULL, PTR_TYPE_NULL), new IoctlFunction("CLEAR_RX_BUFFER", CLEAR_RX_BUFFER, PTR_TYPE_NULL, PTR_TYPE_NULL), new IoctlFunction("CLEAR_PERIODIC_MSGS", CLEAR_PERIODIC_MSGS, PTR_TYPE_NULL, PTR_TYPE_NULL), new IoctlFunction("CLEAR_MSG_FILTERS", CLEAR_MSG_FILTERS, PTR_TYPE_NULL, PTR_TYPE_NULL), new IoctlFunction("CLEAR_FUNCT_MSG_LOOKUP_TABLE", CLEAR_FUNCT_MSG_LOOKUP_TABLE, PTR_TYPE_NULL, PTR_TYPE_NULL, new int []{Protocols.J1850PWM}), new IoctlFunction("ADD_TO_FUNCT_MSG_LOOKUP_TABLE", ADD_TO_FUNCT_MSG_LOOKUP_TABLE, PTR_TYPE_SBYTE_ARRAY, PTR_TYPE_NULL, new int []{Protocols.J1850PWM}), new IoctlFunction("DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE", DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE, PTR_TYPE_SBYTE_ARRAY, PTR_TYPE_NULL, new int []{Protocols.J1850PWM}), new IoctlFunction("READ_PROG_VOLTAGE", READ_PROG_VOLTAGE, PTR_TYPE_NULL, PTR_TYPE_ULONG_PTR), }; /// /// Gets Name of IOCTL operation. /// public string name { get; private set; } /// /// Gets The IOCTL function code. /// public int function { get; private set; } /// /// Gets Type of the input data to the IOCTL operation. /// public int invalue { get; private set; } /// /// Gets Type of the output data from the IOCTL function. /// public int outvalue { get; private set; } /// /// Gets array of protocols that the IOCTL function applies to. /// Empty list means that it applies to all protocols. /// private List protos = new List(); /// /// Gets list of protocols that the IOCTL function applies to. /// Empty list means that it applies to all protocols. /// public IList protocols { get { return new List(this.protos); } } /// /// Initializes a new instance of the class. /// /// Name of function. /// ID value for function. /// Type of in value. /// Type of out value. /// Supported protocols by function, may be 'null' private IoctlFunction(string name, int function, int invalue, int outvalue, int[] protocols) { this.name = name; this.function = function; this.invalue = invalue; this.outvalue = outvalue; this.protos = new List(protocols); } /// /// Initializes a new instance of the class. /// /// Name of function. /// ID value for function. /// Type of in value. /// Type of out value. private IoctlFunction(string name, int function, int invalue, int outvalue) { this.name = name; this.function = function; this.invalue = invalue; this.outvalue = outvalue; this.protos = new List(); } } }