//----------------------------------------------------------------------- // // 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 System.IO; using System.Linq; using global::DynamicApiLoading.Api.Dynamic; using global::DynamicApiLoading.Api.Dynamic.J2534; using global::SharedObjects.Api; using global::SharedObjects.Protocol; /// /// Dynamic J2534 PassThru interface. /// public class DynPassthru : DynamicLoader, IPassThru { /// /// Supported connection flags by the device. /// private static CanFlags[] connFlags = new CanFlags[] { new CanFlags(PassThruConstants.connflags.SNIFF_MODE, "SNIFF_MODE", true), new CanFlags(PassThruConstants.connflags.CAN_ID_BOTH, "CAN_ID_BOTH", true), new CanFlags(PassThruConstants.connflags.CAN_29BIT_ID, "CAN_29BIT_ID", false), new CanFlags(PassThruConstants.connflags.ISO9141_K_LINE_ONLY, "ISO9141_K_LINE_ONLY", false), new CanFlags(PassThruConstants.connflags.ISO9141_NO_CHECKSUM, "ISO9141_NO_CHECKSUM", false), new CanFlags(PassThruConstants.connflags.ISO9141_NO_CHECKSUM_DT, "ISO9141_NO_CHECKSUM_DT", false), new CanFlags(PassThruConstants.connflags.ISO9141_FORD_HEADER, "ISO9141_FORD_HEADER", false), }; /// /// Supported filter flags by the device. /// private static CanFlags[] messageFlags = new CanFlags[] { new CanFlags(PassThruConstants.txflags.CAN_29BIT_ID, "CAN_29BIT_ID", false), new CanFlags(PassThruConstants.txflags.ISO15765_ADDR_TYPE, "ISO15765_ADDR_TYPE", false), new CanFlags(PassThruConstants.txflags.ISO15765_FRAME_PAD, "ISO15765_FRAME_PAD", true), new CanFlags(PassThruConstants.txflags.WAIT_P3_MIN_ONLY, "WAIT_P3_MIN_ONLY", false), new CanFlags(PassThruConstants.txflags.SCI_MODE, "SCI_MODE", false), new CanFlags(PassThruConstants.txflags.SCI_TX_VOLTAGE, "SCI_TX_VOLTAGE", false), }; /// /// Gets the name of the interface. /// public string name { get { string name = string.Empty; if (!string.IsNullOrEmpty(this.dynamicAdapter.Vendor)) { name = this.dynamicAdapter.Vendor + " "; } name += this.dynamicAdapter.Name; return name; } } /// /// Gets the code name of the interface. /// /// For dynamic interfaces this is the same as the DLL filename without extension. /// /// public string code { get { return Path.GetFileNameWithoutExtension(this.dynamicAdapter.FunctionLibrary); } } /// /// Initializes a new instance of the class. /// /// Dynamic Adapter instance. public DynPassthru(DynamicAdapter dynamicAdapter) : base(dynamicAdapter) { } /// /// Get the available connection flags for the device. /// /// Array of flags. public CanFlags[] getConnFlags() { return connFlags; } /// /// Get the available message flags for the device. /// /// Array of flags. public CanFlags[] getMessageFlags() { return messageFlags; } /// /// Get flag indicating if device has disconnect bug. /// /// Flag indicating disconnect bug. public bool disconnectBug() { return false; } /// /// Indicate if the interface is a serial device. /// /// Notice that this also applies to Serial on USB devices. /// /// /// 'true' if serial device. public bool isSerial() { return false; } /// /// Get list of supported protocols. /// /// Array of supported protocols by the device. public Protocols[] getProtocols() { List protocolList = new List(); foreach (string protocolName in this.dynamicAdapter.protocols) { Protocols prot = Protocols.getProtocolByName(protocolName); if (prot != null) { protocolList.Add(prot); } } return protocolList.ToArray(); } } }