From a7e1233a2375ccd98c29cd1a9de47729cfc2372c Mon Sep 17 00:00:00 2001 From: Neucrack Date: Wed, 4 Dec 2024 14:09:17 +0800 Subject: [PATCH] change default modbus port to 502 from 5020 --- components/comm/include/maix_modbus.hpp | 8 ++++---- examples/maix_modbus/main/src/main.cpp | 2 +- examples/maix_modbus_loopback/main/src/main.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/comm/include/maix_modbus.hpp b/components/comm/include/maix_modbus.hpp index d4839fc4..144c5da5 100644 --- a/components/comm/include/maix_modbus.hpp +++ b/components/comm/include/maix_modbus.hpp @@ -141,7 +141,7 @@ namespace maix::comm::modbus { * Default is 115200. Ensure that the selected baud rate * is supported by the underlying hardware and libmodbus. * @param rtu_slave The RTU slave address. Ignored in TCP mode. Default is 1. - * @param tcp_port The port used for TCP communication. Ignored in RTU mode. Default is 5020. + * @param tcp_port The port used for TCP communication. Ignored in RTU mode. Default is 502. * @param debug A boolean flag to enable or disable debug mode. Default is false. * * @maixpy maix.comm.modbus.Slave.__init__ @@ -152,7 +152,7 @@ namespace maix::comm::modbus { uint32_t holding_start=0, uint32_t holding_size=0, uint32_t input_start=0, uint32_t input_size=0, int rtu_baud=115200, uint8_t rtu_slave=1, - int tcp_port=5020, bool debug=false); + int tcp_port=502, bool debug=false); /** * @brief Constructor for creating a Modbus Slave instance with specified registers. @@ -177,7 +177,7 @@ namespace maix::comm::modbus { * Default is 115200. Ensure that the selected baud rate * is supported by the underlying hardware and libmodbus. * @param rtu_slave The RTU slave address. Ignored in TCP mode. Default is 1. - * @param tcp_port The port used for TCP communication. Ignored in RTU mode. Default is 5020. + * @param tcp_port The port used for TCP communication. Ignored in RTU mode. Default is 502. * @param debug A boolean flag to enable or disable debug mode. Default is false. * * @maixcdk maix.modbus.Slave.__init__ @@ -185,7 +185,7 @@ namespace maix::comm::modbus { Slave(maix::comm::modbus::Mode mode, const std::string& ip_or_device, const Registers& registers=Registers{}, int rtu_baud=115200, uint8_t rtu_slave=1, - int tcp_port=5020, bool debug=false); + int tcp_port=502, bool debug=false); ~Slave(); diff --git a/examples/maix_modbus/main/src/main.cpp b/examples/maix_modbus/main/src/main.cpp index 16d5e5fd..f18e6df4 100644 --- a/examples/maix_modbus/main/src/main.cpp +++ b/examples/maix_modbus/main/src/main.cpp @@ -28,7 +28,7 @@ int _main(int argc, char* argv[]) 0x00, 10, // input registers 0x00, 10, // holding registers 0, 1, // serial, ignore - 5020, // tcp port + 502, // tcp port false); // debug OFF std::vector data{0x22, 0x33, 0x44}; diff --git a/examples/maix_modbus_loopback/main/src/main.cpp b/examples/maix_modbus_loopback/main/src/main.cpp index 576a0b2f..fbf9a8a6 100644 --- a/examples/maix_modbus_loopback/main/src/main.cpp +++ b/examples/maix_modbus_loopback/main/src/main.cpp @@ -25,7 +25,7 @@ constexpr uint32_t RTU_SLAVE_ID = 1; constexpr int RTU_BAUDRATE = 115200; /* tcp cfg */ -constexpr int TCP_PORT = 5020; +constexpr int TCP_PORT = 502; int master_rtu_thread() {