AppBridge.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * @filename AppBridge.cpp
  3. *
  4. * @date Mar 05, 2025
  5. * @author: juraj
  6. */
  7. #include <NbusSlave.h>
  8. #include "AppBridge.h"
  9. #include "dataframe.h"
  10. #include "NbusBridge.h"
  11. #include "NbusCommunicator.h"
  12. void app(UART_HandleTypeDef *uartNbus, UART_HandleTypeDef *uartMaster){
  13. NbusCommunicator *nc = new NbusCommunicator(uartNbus, uartMaster);
  14. // NbusSlave *slave1 = new NbusSlave(5, nc);
  15. // NbusSlave *slave2 = new NbusSlave(6, nc);
  16. // bridge->addSlave(slave1);
  17. // bridge->addSlave(slave2);
  18. NbusBridge *bridge = new NbusBridge(nc);
  19. bridge->scan();
  20. DataFrame *frameTX;
  21. while(1){
  22. for(int i=0; i<bridge->getNumSlaves() ; i++){
  23. frameTX = bridge->getSlave(i)->nbus_echo();
  24. bridge->sendResponseToMaster(frameTX);
  25. frameTX = bridge->getSlave(i)->nbus_module_info();
  26. bridge->sendResponseToMaster(frameTX);
  27. // if(!frameTX->IsEmpty()) {
  28. // HAL_UART_Transmit_DMA(uartMaster, frameTX->GetFrame(), frameTX->GetLength());
  29. // }
  30. }
  31. HAL_Delay(1);
  32. /*
  33. for(int i=0;i<256;i++){
  34. HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
  35. HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
  36. }
  37. */
  38. }
  39. }