Home/Support/Support Forum/How to prevent reading my own CAN messages with libdigiapix?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How to prevent reading my own CAN messages with libdigiapix?

0 votes
I'm writing a middleware for our custom board that uses a CC8M Nano to communicate with a lower level board via CAN interface. I'm using DEY 3.0 rev2 with some custom layers in both the CC8M Nano Development Kit board and our custom device. I've already tested that the apix-can-send and apix-can-recv examples work properly.
From those examples, I've created a program that manages both writing and reading the CAN interface.

Basically, I request the can interface, register cleanup method and signals, initialize it and finally register the reception callback:

canInterface = ldx_can_request_by_name(iface.c_str());
//... manage errors (removed for clarity)

ldx_can_set_bitrate(canInterface, bitrate);
canConfig.bitrate = bitrate;

//-- Register signals and exit cleanup function
atexit(cleanup);
register_signals();

//-- Initialize interface
int initCode = ldx_can_init(canInterface, &canConfig);
//... manage errors (removed for clarity)

//-- Use default filter
struct can_filter deffilter;
deffilter.can_id = 0;
deffilter.can_mask = 0;

cfilter = &deffilter;
int nfilters = 1;

int ret = ldx_can_register_rx_handler(canInterface,
can_rx_callback,
cfilter,
nfilters);

However, after this, whenever I send a message, the callback is called and I read my own message. I know in some cases this is desirable, but not in the custom protocol my colleagues and I have established. So, I've been trying to prevent this via configuration.

I've been digging in https://github.com/digi-embedded/libdigiapix/blob/dey-3.0/maint/src/can.c and can_netlink.c to see if, by any chance, the API switched on the CAN_RAW_RECV_OWN_MSGS option (as seen in https://www.kernel.org/doc/Documentation/networking/can.txt, section 4.1.4). However this is not the case...

The CAN API documentation (https://www.digi.com/resources/documentation/digidocs/embedded/dey/3.0/cc8mnano/yocto_r_apix-can) doesn't seem to give access to those flags or any similar configuration.

The only thing I can think of is to unregister the callback before sending a message and registering it again afterwards... but it doesn't seems like a clean or correct solution.

Am I missing something? How can I prevent reading my own CAN messages?
Thank you in advance for any help.
asked Dec 22, 2020 in Linux by sergiompopoli New to the Community (2 points)

Please log in or register to answer this question.

...