WorkerRemoveFilter(FilteringCriterion) Method

Removes a filtering criterion from the message filter of the default receive queue (index 0).

Definition

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
C#
public bool RemoveFilter(
	FilteringCriterion filter
)

Parameters

filter  FilteringCriterion
The filtering criterion to be removed.

Return Value

Boolean
true if the criterion is successfully removed; otherwise, false.

Example

The following example shows how to configure the message filter of the default receive queue (index 0) to receive only echo messages with extended ID 0x15. After this, the filtering criteria for the CAN identifier is removed, so that any echo message can be received.

In case of failure, an error messages is written to the console output using English as output language.

C#
// Create the object using the default configuration
//
Worker myWorker = new Worker();

// Set the filter of the default receive queue (index 0) to receive only echo messages with ID 0x15
//
FilteringCriterion criterion = new FilteringCriterion();
criterion.SetMessageType(MessageType.Echo, FilterBehavior.Include);
if (myWorker.AddFilter(criterion))
{
    criterion.SetSingleId(0x15, FilterMode.Extended);
    if (myWorker.AddFilter(criterion))
    {
        Console.WriteLine("Receiving only Echo messages with extended ID equals to 0x15...");
        // Remove the filter for ID 0x15, to receive echo messages with any ID
        //
        if(myWorker.RemoveFilter(criterion))
            Console.WriteLine("Receiving now any Echo message...");
        else
            Console.WriteLine("The specified criterion could not be found.");
    }
    else
        Console.WriteLine("The given filter is already registered.");
}
else
    Console.WriteLine("The given filter is already registered.");

See Also