//-----------------------------------------------------------------------
//
// 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.Protocol
{
using global::SharedObjects.Api;
using global::SharedObjects.Protocol.OBD;
///
/// Definition of methods that each protocol handler shall implement.
///
/// Notice: This is still under development.
///
///
public interface IProtocolHandler
{
///
/// Gets source address value.
///
uint srcAddr { get; }
///
/// Gets Current protocol.
///
Protocols protocol { get; }
///
/// Initialize the protocol if necessary.
///
/// TX Flags for any messages that are created during initialization.
void init(int txFlags);
///
/// Start protocol services if necessary.
///
void start();
///
/// Stop any running protocol services.
///
void stopProtocol();
///
/// Send a probe message.
///
/// Source address (address of tester).
/// TX Flags.
/// Payload data.
void sendProbeMessage(uint srcAddr, int txFlags, byte[] payload);
///
/// Compose according to protocol and send one message.
///
/// 'Our' address, used in some cases.
/// Target address.
/// Flags to add to message.
/// The data to send.
/// Error text if there was an error.
string sendMessage(
uint senderAddrValue,
uint receiverAddrValue,
int txFlags,
byte[] payload);
///
/// Set address on message according to protocol rules.
///
/// Notice that not all protocols uses both from and to address.
///
///
/// Message to set address on.
/// From address to set.
/// To address to set.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Justification = "Reviewed, intentional.")]
void setAddress(ref IPassThruMsg msg, uint fromAddress, uint toAddress);
///
/// Set the address(es) of the message.
///
/// This is a fully composed address, usually used by filters.
///
///
/// Message to set data in.
/// Combined Address.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Justification = "Reviewed, intentional.")]
void setAddress(ref IPassThruMsg txmsg, uint address);
///
/// Set additional header data.
///
/// Notice that not all protocols supports this.
/// If the protocol doesn't support this no modifications shall
/// occur of the message and the function shall return silently.
///
///
/// Message to set data on.
/// Size to set.
/// 'true' if functional addressing is used. (depends on protocol)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "0#", Justification = "Reviewed, intentional.")]
void setHeader(ref IPassThruMsg msg, uint size, bool functionalTargetAddressing);
///
/// Add a mode parser.
///
/// Parser instance to add.
void addModeParser(IModeParser modeParser);
///
/// Remove a mode parser.
///
/// Parser instance to remove.
void removeModeParser(IModeParser modeParser);
///
/// Check if protocol supports 29 bit addressing.
///
/// 'true' if protocol supports 29 bit addressing.
bool is29bit();
}
}