The PassThruStartMsgFilter function is used to setup
a network protocol filter that will selectively restrict
or limit network protocol messages received by the
PassThru device. The filter messages will flow from the
User Application to the PassThru device. There is a
limit of ten filter messages per network layer protocol.
The PassThru device will block all vehicle network
receive frames by default, when no filters
are defined.
The CLEAR_RX_BUFFER (PassThruIoctl function) command
must be used after establishing filters to ensure that the
receive queue only contains receive frames that adhere
to the filter criteria. The PassThruStartMsgFilter
function does not cause existing receive messages to be
removed from the PassThru device receive queue.
PASSTHRU_MSG MaskMsg, PatternMsg, FlowControlMsg;
PASSTHRU_MSG Msg[2];
unsigned long ChannelID;
unsigned long FilterID;
unsigned long NumMsgs;
PassThruOpen(NULL, &DeviceID);
PassThruConnect(DeviceID, ISO15765, Flags,
500000, &ChannelID);
MaskMsg.ProtocolID = ISO15765;
MaskMsg.Data = {0xFF, 0xFF, 0xFF, 0xFF};
MaskMsg.TxFlags = ISO15765_FRAME_PAD;
MaskMsg.DataSize = 4;
PatternMsg.ProtocolID = ISO15765;
PatternMsg.Data = {0x00, 0x00, 0x07, 0xE8};
PatternMsg.TxFlags = ISO15765_FRAME_PAD;
PatternMsg.DataSize = 4;
FlowControlMsg.ProtocolID = ISO15765;
FlowControlMsg.Data = {0x00, 0x00, 0x07, 0xE0};
FlowControlMsg.TxFlags = ISO15765_FRAME_PAD;
FlowControlMsg.DataSize = 4;
PassThruStartMsgFilter(ChannelID,
FLOW_CONTROL_FILTER, &MaskMsg, &PatternMsg, &FlowControlMsg,
&FilterID);
// Get rid of any messages received before the
filter started
PassThruIoctl(ChannelID, CLEAR_RX_BUFFER, NULL,
NULL);
// Read messages like normal
NumMsgs = 2;
PassThruReadMsgs(ChannelID, &Msg, &NumMsgs, 0);