Quantex GmbH
DE RU EN

PassThru StartMsgFilter Setting a message filter

Description

Before receiving or sending messages, you must set message filters. If no filters are set, all messages are blocked. Only one type of filter, FLOW_CONTROL_FILTER, is available for the ISO 15765 protocol. It cannot be installed for other protocols. For each ChannelID, up to 64 filters FLOW_CONTROL_FILTER and up to 10 PASS_FILTER or BLOCK_FILTER can be created. For each filter type selected, filter parameters must be specified. Three parameters pMaskMsg, pPatternMsg, pFlowControlMsg are specified for FLOW_CONTROL_FILTER. For PASS_FILTER or BLOCK_FILTER, two parameters pMaskMsg and pPatternMsg are specified. The length of the parameters can be from 1 to 12 bytes.

long PassThruStartMsgFilter(unsigned long ChannelID, unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *FilterID)

Options

There is a standard and extended message in the ISO 15765 protocol. The standard message uses 4 bytes for the header for an extended 5 bytes. An extended header is used, for example, in Toyota BCM or in the BMW control unit.

Returned error codes

Definition Description
STATUS_NOERROR Function completed successfully
ERR_DEVICE_NOT_CONNECTED No connection to adapter. Possible reasons: The adapter is turned off, there is no network, or the IP address is not set correctly.
ERR_INVALID_DEVICE_ID Set a non-existent adapter ID DeviceID
ERR_INVALID_MSG Invalid message structure specified in pMaskMsg, pPatternMsg, or pFlowControlMsg
ERR_INVALID_CHANNEL_ID Set a non-existent channel identifier ChannelID
ERR_NULL_PARAMETER No pointer to pMaskMsg or pPatternMsg
ERR_NOT_UNIQUE CAN ID in pPatternMsg or pFlowControlMsg corresponds to any ID in an existing FLOW_CONTROL_FILTER
ERR_MSG_PROTOCOL_ID The protocol specified in the filter parameters does not match the protocol specified in ChannelID
ERR_EXCEEDED_LIMIT The number of installed filters has been exceeded.
ERR_FAILED Defined by the J2534 standard. In the adapter, it is not used for this function.

Example

Протокол ISO15765

#include "j2534_lib.hpp"

PASSTHRU_MSG MaskMsg, PatternMsg, FlowControlMsg;

unsigned long ChannelID;
unsigned long FilterID;

static const uint8_t cMaskMsg[] = { 0xFF, 0xFF, 0xFF, 0xFF};
static const uint8_t cPatternMsg[] = { 0x00, 0x00, 0x07, 0xE8};
static const uint8_t cFlowControlMsg[] = { 0x00, 0x00, 0x07, 0xE0};


PassThruOpen("192.168.1.3", &DeviceID);
PassThruConnect(DeviceID, ISO15765, 0, 500000, &ChannelID);


MaskMsg.ProtocolID = ISO15765;
MaskMsg.TxFlags = FL_ISO15765_FRAME_PAD;
memcpy(MaskMsg.Data, cMaskMsg, sizeof(cMaskMsg));
MaskMsg.DataSize = sizeof(cMaskMsg);

PatternMsg.ProtocolID = ISO15765;
PatternMsg.TxFlags = FL_ISO15765_FRAME_PAD;
memcpy(PatternMsg.Data, cPatternMsg, sizeof(cPatternMsg));
PatternMsg.DataSize = sizeof(cPatternMsg);

FlowControlMsg.ProtocolID = ISO15765;
FlowControlMsg.TxFlags = FL_ISO15765_FRAME_PAD;
memcpy(FlowControlMsg.Data, cFlowControlMsg, sizeof(cFlowControlMsg));
FlowControlMsg.DataSize = sizeof(cFlowControlMsg);


Ret = PassThruStartMsgFilter(ChannelID, FLOW_CONTROL_FILTER, &MaskMsg, &PatternMsg, &FlowControlMsg, &FilterID);
if (Ret != STATUS_NOERROR)
{	// Error handling
}

Протокол ISO14230

#include "j2534_lib.hpp"

PASSTHRU_MSG MaskMsg, PatternMsg, FlowControlMsg;

unsigned long ChannelID;
unsigned long FilterID;

static const uint8_t cMaskMsg[] = {0x80};
static const uint8_t cPatternMsg[] = {0x80};

PassThruOpen("192.168.1.3", &DeviceID);
PassThruConnect(DeviceID, ISO14230, 0, 10400, &ChannelID);


MaskMsg.ProtocolID = ISO14230;
MaskMsg.TxFlags = 0;
memcpy(MaskMsg.Data, cMaskMsg, sizeof(cMaskMsg));
MaskMsg.DataSize = sizeof(cMaskMsg);

PatternMsg.ProtocolID = ISO14230;
PatternMsg.TxFlags = 0;
memcpy(PatternMsg.Data, cPatternMsg, sizeof(cPatternMsg));
PatternMsg.DataSize = sizeof(cPatternMsg);

Ret = PassThruStartMsgFilter(ChannelID, PASS_FILTER, &MaskMsg, &PatternMsg, NULL, &FilterID);
if (Ret != STATUS_NOERROR)
{	// Error handling
}