How can I change the acceptance filter with CAN_FilterAdd
Posted: Tue 17. Mar 2020, 11:03
I am planning to use the Router FD as a ID-selectable Router that performs to receive and transfer
the CAN message between CAN1/BUS1 and CAN2/BUS2 excluding the ID specified via RS-232 interface.
I am using, PCAN-Router FD IPEH-002214 #05185 with PCAN-USB FDx2, and PCAN-Explorer6,PCAN-Flash.
I could specify the ID for the masking via RS-232. *it is achieved by modifying CAN_TO_SER_ASCII example.
When the router receives the code via RS-232, the router program calls CAN_FilterAdd API to change the Acceptance
filter for masking the specified code.
It works fine, the first calling CAN_FilterAdd after PowerON reset.
But, it doesn’t work, the second or later calling during the PowerON.
It seems the range of acceptance filter is overwritten.
for example:
- After PowerON reset, the router set up the filter to exclude 0x650. *hard coding
in the CAN_UserIniti (void)
- Then I send the code:0x611(11bit) to change the masked code 0x650 to 0x611.
- After I send the message(0x000~0x7FF) to CAN1, the router could routing the message to CAN2 excluding 0x650
- Then, I send the 0x611 via RS-232 to change the masked code 0x650 to 0x611.
Then the router forwards all CAN messages CAN1 to CAN2....
*I expected the filter was cleared when I call CAN_UnInitialize or CAN_Initialize API, and change the masked code 0x650 to 0x611
*above filter change calling sequence is performed in the big while-loop like as in ROUTING example.
*in case of exchange 0x611:hard coding, 0x650 specify via RS-232, the router could mask the 0x610 until the filter change like above,
but after call CAN_FilterAdd, the router forward all CAN messages.
Is there any way that I can change the filter without PowerON reset?
Please tell me if there is any solution to this matter.
Thanks.
the CAN message between CAN1/BUS1 and CAN2/BUS2 excluding the ID specified via RS-232 interface.
I am using, PCAN-Router FD IPEH-002214 #05185 with PCAN-USB FDx2, and PCAN-Explorer6,PCAN-Flash.
I could specify the ID for the masking via RS-232. *it is achieved by modifying CAN_TO_SER_ASCII example.
When the router receives the code via RS-232, the router program calls CAN_FilterAdd API to change the Acceptance
filter for masking the specified code.
It works fine, the first calling CAN_FilterAdd after PowerON reset.
But, it doesn’t work, the second or later calling during the PowerON.
It seems the range of acceptance filter is overwritten.
for example:
- After PowerON reset, the router set up the filter to exclude 0x650. *hard coding
in the CAN_UserIniti (void)
Code: Select all
// Init CAN1
CAN_Initialize ( CAN_BUS1, &Timing_CANx[CAN_BUS1]);
// set acceptance area excluding 0x650
CAN_FilterAdd ( CAN_BUS1, CAN_MSGTYPE_STANDARD, 0x000, 0x64F);
CAN_FilterAdd ( CAN_BUS1, CAN_MSGTYPE_STANDARD, 0x651, 0x7FF);
// init CAN2
CAN_Initialize ( CAN_BUS2, &Timing_CANx[CAN_BUS2]);
// receive all 11 bit standard CAN-IDs
CAN_FilterAdd ( CAN_BUS2, CAN_MSGTYPE_STANDARD, 0x000, 0x7FF);
- After I send the message(0x000~0x7FF) to CAN1, the router could routing the message to CAN2 excluding 0x650
- Then, I send the 0x611 via RS-232 to change the masked code 0x650 to 0x611.
Code: Select all
:
CAN_UnInitialize( CAN_BUS1 ) * I think that it does not need to call just first calling after PowerON reset.
CAN_Initialize( CAN_BUS1, &Timing_CANx[CAN_BUS1] )
CAN_FilterAdd( CANBUS_1, CAN_MSGTYPE_STANDARD, 0x000, 0x610 )
CAN_FilterAdd( CANBUS_1, CAN_MSGTYPE_STANDARD, 0x612, 0x7FF )
:
*I expected the filter was cleared when I call CAN_UnInitialize or CAN_Initialize API, and change the masked code 0x650 to 0x611
*above filter change calling sequence is performed in the big while-loop like as in ROUTING example.
*in case of exchange 0x611:hard coding, 0x650 specify via RS-232, the router could mask the 0x610 until the filter change like above,
but after call CAN_FilterAdd, the router forward all CAN messages.
Is there any way that I can change the filter without PowerON reset?
Please tell me if there is any solution to this matter.
Thanks.