Skip to content

Commit

Permalink
change default modbus port to 502 from 5020
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Dec 4, 2024
1 parent ddab5d6 commit a7e1233
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions components/comm/include/maix_modbus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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.
Expand All @@ -177,15 +177,15 @@ 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__
*/
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();
Expand Down
2 changes: 1 addition & 1 deletion examples/maix_modbus/main/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t> data{0x22, 0x33, 0x44};
Expand Down
2 changes: 1 addition & 1 deletion examples/maix_modbus_loopback/main/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit a7e1233

Please sign in to comment.