You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I apologize for using this communication path, but I don't feel comfortable doing a pull request.
I am using libj1939 a in an application and I am using filters. I ran into a problem and found a solution. It may be appropriate to include this solution in the library. The method in question is j1939_filter in linux_socketcan.c.
for (size_t i = 0; i < num_filters; i++) {
id = j1939_pgn2id(filter[i].pgn, filter[i].priority, filter[i].addr);
// all of the network messages have the CAN_EFF_FLAG bit cleared, so I don't
// understand why this is set here. The mask is zero, so this bit wouldn't
// be considered in the filter anyway
rfilter[i].can_id = id | CAN_EFF_FLAG;
// the filter mask didn't line up with the ID so I used the pgn2id macro to align it
// I didn't know what to do with the polarity bit, so I left it at 0
// I did not need to filter on the polarity
// original code - rfilter[i].can_mask = filter[i].pgn_mask;
rfilter[i].can_mask = j1939_pgn2id(filter[i].pgn_mask, 0, filter[i].addr_mask);
// test code to verify the id and mask
//printf("ID: %08x, Mask: %08x\n", rfilter[i].can_id, rfilter[i].can_mask);
}
setsockopt(cansock, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
return 0;
}
Thanks for your consideration.
Karl Kobel
BTW - we have a slight connection - I work for Wabtec (albeit in the bus division). I know we have done work for Alstom.
I apologize for using this communication path, but I don't feel comfortable doing a pull request.
I am using libj1939 a in an application and I am using filters. I ran into a problem and found a solution. It may be appropriate to include this solution in the library. The method in question is j1939_filter in linux_socketcan.c.
int j1939_filter(struct j1939_pgn_filter *filter, uint32_t num_filters)
{
struct can_filter rfilter[num_filters];
uint32_t id;
}
Thanks for your consideration.
Karl Kobel
BTW - we have a slight connection - I work for Wabtec (albeit in the bus division). I know we have done work for Alstom.
[email protected]
The text was updated successfully, but these errors were encountered: