//-----------------------------------------------------------------------
//
// 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
{
///
/// Constants for PassThru interface.
///
public sealed class PassThruConstants
{
///
/// Max size of the Data field.
///
public const int MAX_DATA_SIZE = 4128;
///
/// Default message at success.
///
public const string SUCCESS = "Success";
///
/// Prevents a default instance of the class from being created.
///
private PassThruConstants()
{
}
///
/// J2534 result codes plus internal codes.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Reviewed, intentional.")]
public enum resultCode
{
///
/// Function completed successfully.
///
ERR_SUCCESS = 0x00,
///
/// Function option is not supported.
///
ERR_NOT_SUPPORTED = 0x01,
///
/// Channel Identifier or handle is not recognized.
///
ERR_INVALID_CHANNEL_ID = 0x02,
///
/// Protocol Identifier is not recognized.
///
ERR_INVALID_PROTOCOL_ID = 0x03,
///
/// NULL pointer presented as a function parameter, NULL is an invalid address.
///
ERR_NULL_PARAMETER = 0x04,
///
/// Ioctl GET_CONFIG/SET_CONFIG parameter value is not recognized.
///
ERR_INVALID_IOCTL_VALUE = 0x05,
///
/// Flags bit field(s) contain(s) an invalid value.
///
ERR_INVALID_FLAGS = 0x06,
///
/// Unspecified error, use PassThruGetLastError for obtaining error text string.
///
ERR_FAILED = 0x07,
///
/// PassThru device is not connected to the PC.
///
ERR_DEVICE_NOT_CONNECTED = 0x08,
///
/// Timeout violation. PassThru device is unable to read specified number of messages from the vehicle network.
/// The actual number of messages returned is in NumMsgs.
///
ERR_TIMEOUT = 0x09,
///
/// Message contained a min/max length, ExtraData support or J1850PWM specific source address conflict violation.
///
ERR_INVALID_MSG = 0x0A,
///
/// The time interval value is outside the specified range.
///
ERR_INVALID_TIME_INTERVAL = 0x0B,
///
/// The limit(ten) of filter/periodic messages has been exceeded for the protocol associated the communications channel.
///
ERR_EXCEEDED_LIMIT = 0x0C,
///
/// The message identifier or handle is not recognized.
///
ERR_INVALID_MSG_ID = 0x0D,
///
/// The specified PassThru device is already in use.
///
ERR_DEVICE_IN_USE = 0x0E,
///
/// Ioctl identifier is not recognized.
///
ERR_INVALID_IOCTL_ID = 0x0F,
///
/// PassThru device could not read any messages from the vehicle network.
///
ERR_BUFFER_EMPTY = 0x10,
///
/// PassThru device could not queue any more transmit messages destined for the vehicle network.
///
ERR_BUFFER_FULL = 0x11,
///
/// PassThru device experienced a buffer overflow and receive messages were lost.
///
ERR_BUFFER_OVERFLOW = 0x12,
///
/// Unknown pin number specified for the J1962 connector.
///
ERR_PIN_INVALID = 0x13,
///
/// An existing communications channel is currently using the specified network protocol.
///
ERR_CHANNEL_IN_USE = 0x14,
///
/// The specified protocol type within the message structure is different from the protocol associated with
/// the communications channel when it was opened.
///
ERR_MSG_PROTOCOL_ID = 0x15,
///
/// Filter identifier is not recognized.
///
ERR_INVALID_FILTER_ID = 0x16,
///
/// No ISO15765 flow control filter is set, or no filter matches the header of an outgoing message.
///
ERR_NO_FLOW_CONTROL = 0x17,
///
/// An existing filter already matches this header or node identifier.
///
ERR_NOT_UNIQUE = 0x18,
///
/// Unable to honor requested Baud rate within required tolerances.
///
ERR_INVALID_BAUDRATE = 0x19,
///
/// PassThru device identifier is not recognized.
///
ERR_INVALID_DEVICE_ID = 0x1A,
///
/// Internal code for this application indicating that there is no channel configured.
///
NO_CHANNEL = -767,
///
/// Internal code for this application indicating that there was a failure reading data.
///
READ_FAIL = -757,
}
///
/// Class declaring connection flags.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Intentional for use with DLL API")]
public class connflags
{
///
/// Flag CAN_29BIT_ID.
///
public const int CAN_29BIT_ID = 0x00000100;
///
/// Flag ISO9141_NO_CHECKSUM.
///
public const int ISO9141_NO_CHECKSUM = 0x00000200;
///
/// Flag CAN_ID_BOTH.
///
public const int CAN_ID_BOTH = 0x00000800;
///
/// Flag ISO9141_K_LINE_ONLY.
///
public const int ISO9141_K_LINE_ONLY = 0x00001000;
/* The following are vendor specific */
///
/// Tactrix specific Flag SNIFF_MODE.
///
public const int SNIFF_MODE = 0x10000000;
///
/// Tactrix specific Flag ISO9141_FORD_HEADER.
///
public const int ISO9141_FORD_HEADER = 0x20000000;
///
/// Tactrix specific Flag ISO9141_NO_CHECKSUM_DT.
///
public const int ISO9141_NO_CHECKSUM_DT = 0x40000000;
///
/// Array of supported flags.
///
public static readonly connflags[] flags =
{
new connflags(CAN_29BIT_ID, "CAN_29BIT_ID"),
new connflags(ISO9141_NO_CHECKSUM, "ISO9141_NO_CHECKSUM"),
new connflags(CAN_ID_BOTH, "CAN_ID_BOTH"),
new connflags(ISO9141_K_LINE_ONLY, "ISO9141_K_LINE_ONLY"),
new connflags(SNIFF_MODE, "SNIFF_MODE"),
new connflags(ISO9141_FORD_HEADER, "ISO9141_FORD_HEADER"),
new connflags(ISO9141_NO_CHECKSUM_DT, "ISO9141_NO_CHECKSUM_DT"),
};
///
/// Gets value of the flag.
/// It is a bit masked field that may be 'or':ed with other flags.
///
public int flag { get; private set; }
///
/// Gets The name of the flag.
///
public string name { get; private set; }
///
/// Initializes a new instance of the class.
///
/// ID of flag.
/// Name of flag.
private connflags(int flag, string name)
{
this.flag = flag;
this.name = name;
}
}
///
/// Class declaring tx message flags.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Intentional for use with DLL API")]
public class txflags
{
///
/// Flag ISO15765_FRAME_PAD.
///
public const int ISO15765_FRAME_PAD = 0x00000040;
///
/// Flag ISO15765_ADDR_TYPE.
///
public const int ISO15765_ADDR_TYPE = 0x00000080;
///
/// Flag CAN_29BIT_ID.
///
public const int CAN_29BIT_ID = 0x00000100;
///
/// Flag WAIT_P3_MIN_ONLY.
///
public const int WAIT_P3_MIN_ONLY = 0x00000200;
///
/// Flag SCI_MODE.
///
public const int SCI_MODE = 0x00400000;
///
/// Flag SCI_TX_VOLTAGE.
///
public const int SCI_TX_VOLTAGE = 0x00800000;
///
/// Array of supported flags.
///
public static readonly txflags[] flags =
{
new txflags(ISO15765_FRAME_PAD, "ISO15765_FRAME_PAD"),
new txflags(ISO15765_ADDR_TYPE, "ISO15765_ADDR_TYPE"),
new txflags(CAN_29BIT_ID, "CAN_29BIT_ID"),
new txflags(WAIT_P3_MIN_ONLY, "WAIT_P3_MIN_ONLY"),
new txflags(SCI_MODE, "SCI_MODE"),
new txflags(SCI_TX_VOLTAGE, "SCI_TX_VOLTAGE"),
};
///
/// Gets value of the flag.
/// It is a bit masked field that may be 'or':ed with other flags.
///
public int flag { get; private set; }
///
/// Gets The name of the flag.
///
public string name { get; private set; }
///
/// Initializes a new instance of the class.
///
/// ID of flag.
/// Name of flag.
private txflags(int flag, string name)
{
this.flag = flag;
this.name = name;
}
}
///
/// Class declaring rx message status flags.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Intentional for use with DLL API")]
public class rxflags
{
///
/// Flag TX_MSG_TYPE.
///
public const int TX_MSG_TYPE = 0x00000001;
///
/// Flag START_OF_MESSAGE.
///
public const int START_OF_MESSAGE = 0x00000002;
///
/// Flag RX_BREAK.
///
public const int RX_BREAK = 0x00000004;
///
/// Flag TX_DONE.
///
public const int TX_DONE = 0x00000008;
///
/// Flag ISO15765_PADDING_ERROR.
///
public const int ISO15765_PADDING_ERROR = 0x00000010;
///
/// Flag ISO15765_ADDR_TYPE.
///
public const int ISO15765_ADDR_TYPE = 0x00000080;
///
/// Array of supported flags.
///
public static readonly rxflags[] flags =
{
new rxflags(TX_MSG_TYPE, "TX_MSG_TYPE"),
new rxflags(START_OF_MESSAGE, "START_OF_MESSAGE"),
new rxflags(RX_BREAK, "RX_BREAK"),
new rxflags(TX_DONE, "TX_DONE"),
new rxflags(ISO15765_PADDING_ERROR, "ISO15765_PADDING_ERROR"),
new rxflags(ISO15765_ADDR_TYPE, "ISO15765_ADDR_TYPE"),
};
///
/// Gets value of the flag.
/// It is a bit masked field that may be 'or':ed with other flags.
///
public int flag { get; private set; }
///
/// Gets The name of the flag.
///
public string name { get; private set; }
///
/// Initializes a new instance of the class.
///
/// ID of flag.
/// Name of flag.
private rxflags(int flag, string name)
{
this.flag = flag;
this.name = name;
}
}
///
/// Class declaring Filter types.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Justification = "Intentional for use with DLL API")]
public class filters
{
///
/// Filter type PASS_FILTER.
///
public const int PASS_FILTER = 0x00000001;
///
/// Filter type BLOCK_FILTER.
///
public const int BLOCK_FILTER = 0x00000002;
///
/// Filter type FLOW_CONTROL_FILTER.
///
public const int FLOW_CONTROL_FILTER = 0x00000003;
///
/// Array of supported filters.
///
public static readonly filters[] filterlist =
{
new filters(PASS_FILTER, "PASS_FILTER"),
new filters(BLOCK_FILTER, "BLOCK_FILTER"),
new filters(FLOW_CONTROL_FILTER, "FLOW_CONTROL_FILTER"),
};
///
/// Gets value of the filter id.
///
public int id { get; private set; }
///
/// Gets The name of the filter type.
///
public string name { get; private set; }
///
/// Initializes a new instance of the class.
///
/// ID of filter.
/// Name of filter.
private filters(int id, string name)
{
this.id = id;
this.name = name;
}
}
}
}