thiagoralves / OpenPLC_Editor

OpenPLC Editor - IDE capable of creating programs for the OpenPLC Runtime
GNU General Public License v2.0
385 stars 191 forks source link

Stm32 can bus block added & tested (WORKING) #115

Closed Aurentiaco35 closed 1 month ago

Aurentiaco35 commented 1 month ago

Hello Thiago,

We added the CAN blocks for STM32 family into the editor. We also did couple tests with different boards, it's completely functional. The usage scenario is implemented with an example FBD project inside the examples folder of editor.

Please review the pull request and turn back to us. We appreciate your help on this.

Best regards pcan setup toThiago

dogualpay commented 1 month ago

@thiagoralves Thanks for the help. After almost 2 years we did it ! 💯 💯 💯 💯 💯 @Aurentiaco35 Well done brother 🥇

thiagoralves commented 1 month ago

Thank you for your contribution @Aurentiaco35. I just have a few comments about this PR:

  1. Do we need the editor/arduino/examples/Baremetal/hal_conf_extra.h file? It only has one #define in it. If we need that define, consider moving it to editor/arduino/examples/Baremetal/arduino_libs.h inside the #ifdef USE_STM32CAN_BLOCK clause
  2. On editor/arduino/examples/Baremetal/modules/stm32can.c there are several Serial.print debug messages along with a Serial.begin call. Those calls must be removed or it will conflict with the OpenPLC Modbus serial task.
  3. The MatIEC library is simply called stm32 (stm32.h, stm32.txt, etc). Consider renaming those files to can (can.h, can.txt, etc). This is a library to add can support, where for now only STM32 boards are compatible. But in the future, other boards could be added to this library, so it makes no sense to call it stm32.
  4. Same thing with the XML library file editor/plcopen/STM32_Function_Blocks.xml. Rename the file and its contents (STM32 Function Blocks) to be related to CAN instead of STM32

Could you implement those changes on this PR please?

Aurentiaco35 commented 1 month ago
  1. We need that file for enable stm32 hal libraries. I tried to add it in your .py but unfortunately it is not working thats why I added like that.
  2. Done
  3. Done
  4. Done Could you check them again please
thiagoralves commented 1 month ago
  1. Have you tried adding it to editor/arduino/examples/Baremetal/arduino_libs.h like this:
    #ifdef USE_STM32CAN_BLOCK
    #define HAL_CAN_MODULE_ENABLED
    #include "modules/stm32can.c"
    #endif

    I don't see why it would be any different than including a separate file.

Aurentiaco35 commented 1 month ago

Yes I tried it and I got an error.

thiagoralves commented 1 month ago

Got it. Seems that there is a specific requirement to have the file named as it is then. I’ll go ahead and merge. Thanks!