sebi2k1 / node-can

NodeJS SocketCAN extension
222 stars 72 forks source link

setRxFilters - formatting the bit mask #114

Closed UltimateMP closed 1 year ago

UltimateMP commented 1 year ago

I am using the node-can library for parsing J1939 data. I am not quite sure how to format the setRxFilter. eg I have the following data frames.

can1 (emuccan0) 0CF00400   [8]  F0 7D 7D 00 00 FF FF FF
can1 (emuccan0) 0CFF8100   [8]  A1 FF DF 00 FC 00 FF FF
can1 (emuccan0) 0C000027   [8]  C1 50 14 FF FF FF FF FF
can1 (emuccan0) 0CFF8027   [8]  A1 00 00 0F FF 00 FF FF
can1 (emuccan0) 18FEF600   [8]  FF 00 40 FF FF FF FF FF
can1 (emuccan0) 0C000027   [8]  C1 50 14 FF FF FF FF FF
can1 (emuccan0) 0CF00400   [8]  F0 7D 7D 00 00 FF FF FF

How would I filter to only receive messgaes with Can ID of 0CF00400?

Additionally in this package is there an easy way to limit update rates of a certain Can Id to say 1hz or 2hz?

sebi2k1 commented 1 year ago

You can’t limit the message rate since socketcan doesn’t support it.

The filter is a wrapper around CAN_RAW_FILTER see https://www.kernel.org/doc/html/latest/networking/can.html