Skip to content

In/Out "External" port in C++


For an application, we are using the AXL_CAN_COMM_4 to receive CAN messages. The processing of the messages is done in a cpp Program. As we have more than 200 different message ids we can`t use the xReceiveMode in True.

We are using an input port to get the receivebuffer in to the cpp program

To prevent the buffer from filling, the processed messages need to be removed by setting the xUsed to false.

This does not work to clear the buffer as rxbuffer is only an Input port.

I don't see an option to make a port in cpp external / input-output port.


What is the best way to clear the buffer?

Comments

  • edited July 2022

    Dear Bram,

    At the moment, defining external/InOut ports in C++ is not possible. If you wish to clear the buffer, you should do this in PLCnext Engineer, such as a Structerd Text code. This does mean that you have to create a output boolean and integer in your C++ code to transfer the xUsed state and element number to the ST code after copying the message.

    I think the general workflow would be:

    1. In the C++ program, copy the buffer element to the processMsg variable as shown in your image.
    2. set xUsed to false in the C++ program.
    3. Transfer the state of xUsed and the element number which needs to be cleared to your ST code in PLCnext Engineer.
    4. Clear the element in the port variable which is connected to your C++ input port rxBuffer[ ]. This should also clear the rxBuffer element in your C++ code.


    With kind regards,

    Damian Bombeeck

  • Thanks for the response,

    I have started doing it with a similar method as the one that you suggested.

This discussion has been closed.