nonecesario 0 Posted May 13, 2015 Share Posted May 13, 2015 I want to make a connection Modbus TCP slave. For this I use a Arduino libraries.I am using the EK-TM4C1294XL KitThe could enter and take the example they have in the library, the example compiles correctly.Board is connected to a switch and a PC is connected also has disabled the Windows firewall. I use a Modbus TCP client program on the PC to read the records of the kit through Modbus.I can not read the values, tells me it can not connect to the target computer, the connection was denied.If I make ping the IP of the plate answer me well. Someone can help me solve the problemThe code is as follows: #include <SPI.h> #include <Ethernet.h> #include "MgsModbus.h" MgsModbus Mb; int inByte = 0; // incoming serial byte // Ethernet settings (depending on MAC and Local network) byte mac[] = {0x90, 0xA2, 0xDA, 0x0E, 0x94, 0xB5 }; IPAddress ip(192, 168, 100, 109); IPAddress gateway(192, 168, 100, 1); IPAddress subnet(255, 255, 255, 0); void setup() { // serial setup delay(5000); Serial.begin(9600); Serial.println("Serial interface started"); // initialize the ethernet device Ethernet.begin(mac, ip, gateway, subnet); // start etehrnet interface Serial.println("Ethernet interface started"); // print your local IP address: Serial.print("My IP address: "); for (byte thisByte = 0; thisByte < 4; thisByte++) { // print the value of each byte of the IP address: Serial.print(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println(); // Fill MbData // Mb.SetBit(0,false); Mb.MbData[0] = 0; Mb.MbData[1] = 0; Mb.MbData[2] = 0; Mb.MbData[3] = 0; Mb.MbData[4] = 0; Mb.MbData[5] = 0; Mb.MbData[6] = 0; Mb.MbData[7] = 0; Mb.MbData[8] = 0; Mb.MbData[9] = 0; Mb.MbData[10] = 0; Mb.MbData[11] = 0; // print MbData for (int i=0;i<12;i++) { Serial.print("address: "); Serial.print(i); Serial.print("Data: "); Serial.println(Mb.MbData[i]); } // print menu Serial.println("0 - print the first 12 words of the MbData space"); Serial.println("1 - fill MbData with 0x0000 hex"); Serial.println("2 - fill MbData with 0xFFFF hex"); Serial.println("3 - fill MbData with 0x5555 hex"); Serial.println("4 - fill MbData with 0xAAAA hex"); } void loop() { if (Serial.available() > 0) { // get incoming byte: inByte = Serial.read(); if (inByte == '0') { // print MbData for (int i=0;i<12;i++) { Serial.print("address: "); Serial.print(i); Serial.print("Data: "); Serial.println(Mb.MbData[i]); } } if (inByte == '1') {for (int i=0;i<12;i++) {Mb.MbData[i] = 0x0000;}} if (inByte == '2') {for (int i=0;i<12;i++) {Mb.MbData[i] = 0xFFFF;}} if (inByte == '3') {for (int i=0;i<12;i++) {Mb.MbData[i] = 0x5555;}} if (inByte == '4') {for (int i=0;i<12;i++) {Mb.MbData[i] = 0xAAAA;}} } // Mb.MbmRun(); Mb.MbsRun(); } The files are: modbus_slave.rarThe ModbusTCP Client PC program is:EasyModbusClient.rar modbus_slave.rar EasyModbusClient.rar Quote Link to post Share on other sites
bluehash 1,581 Posted May 13, 2015 Share Posted May 13, 2015 @@nonecesario Welcome! Cannot help you much here. @@energia may have some input. Quote Link to post Share on other sites
khm 0 Posted February 9, 2018 Share Posted February 9, 2018 @nonecesario Were you successful with Modbus RTU over TCP/IP using TIVA launchpad and energia? We are trying the same project and have stuck up at the same point with above problems. Can you please help us? Thanks, KHM Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.