-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TCP/IP connection issue #298
Comments
I've make it to work -use example RTU to TCP -i had to made some modification to start working..., but i also want to make bridge work transparently and simultanopusly with program initiated read/write ;) examples/Bridge/TCP-to-RTU-Simulator/TCP-to-RTU-Simulator.ino This is my changes to example: if (transRunning) { // Note that we can't process new requests from TCP-side while waiting for responce from RTU-side. if (!result_MB_RTU_trans) { //i've added this to reset transrunning and slaverunning to 0 Rest is the same as in example and it works in MODBUS TCP to MODBUS_RTU -all IDs ;) |
Hi, @rysiulg. Could you please explain how/where should |
Hi.
Ill try to make a bridge for RTU to TCP but when i use the modbus poll, to check the Modbus TCP, i cant connect with modbus TCP, only with UDP. And i really lost in the port selection, because the modbus poll need this in modbus tcp (or udp). The modbus poll in UDP, always says "timeout error"
`#ifdef ESP8266
#include <ESP8266WiFi.h>
#else ESP32
#include <WiFi.h>
#endif
#include <ModbusIP_ESP8266.h>
#include <ModbusRTU.h>
#define tcp_preg 4
#define tcp_flame 1
#define tcp_rst 1
#define rtu_preg 2
#define rtu_flame 5
#define rtu_rst 0
#define ciclonik_slave 10
ModbusRTU mb;
ModbusIP mbtcp;
bool cb(Modbus::ResultCode event, uint16_t transactionId, void* data) { // Callback to monitor errors
if (event != Modbus::EX_SUCCESS) {
Serial.print("Request result: 0x");
Serial.print(event, HEX);
}
return true;
}
void setup() {
Serial.begin(115200);
pinMode(8,OUTPUT);
Serial1.begin(19200,8E1,18,17);
WiFi.begin("SSID", "PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
mb.begin(&Serial1,8);
mb.client();
mbtcp.server();
mbtcp.addHreg(tcp_preg);
mbtcp.addIsts(tcp_flame);
mbtcp.addCoil(tcp_rst);
}
void loop() {
if (!mb.slave()) {
mb.pullHreg(ciclonik_slave, rtu_preg, tcp_preg); //(slave id, del registro, hacia el registro)
mb.pullIsts(ciclonik_slave, rtu_flame, tcp_flame);
mb.pullCoil(ciclonik_slave, rtu_rst, tcp_rst);
}
mb.task();
mbtcp.task();
}
`
The text was updated successfully, but these errors were encountered: