-1

My question is connected with the issue as linked: Is there any good working MODBUS TCP master library available for Arduino?

An example of Modbus TCP master library as suggested in the post above. A part of ModbusTCP.h file:

#ifndef Modbus_TCPIP_h
#define Modbus_TCPIP_h

#ifndef WIZNET_W5100
#define WIZNET_W5100  0       /**< define 1 if  WIZNET W5100 IC is used, otherwise 0 */
#ifndef ENC28J60
#define ENC28J60      1       /**< define 1 if  ENC28J60 IC is used, otherwise 0     */
#ifndef ESP8266
#define ESP8266       0

//...The entire code of the header

#endif // Just a single one occurence of the #endif in the last line of the header code! 8-|

When I've run the compilation of it in my Arduino IDE, I've got an error as follows: unterminated #ifndef. Mentioned error has a four ocurrences in the error log and it is linked to: Modbus_TCPIP_h, WIZNET_W5100 and ENC28J60.

What should be modified in the header file?

  • These of course each need to be matched by an ending, as they are fully independent. Are you confusing this with else clauses? – Chris Stratton Jun 6 '18 at 21:33
  • It's a bug in the library. Someone submitted a PR: github.com/goddland16/Modbus-TCP/pull/2 and the library owner merged it. Apparently neither of them bothered to test the code or even give it a quick look. That doesn't give me much confidence in the quality of their work. My advice is to look for an alternative library of higher quality. – per1234 Jun 6 '18 at 22:25
  • you might have figured it out yourself if you asked why is ESP8266 not getting an error – jsotola Jun 6 '18 at 23:16
  • Dear All. As per per1234 suggestion I would place the main question ones again: Is there any good working and also tested and proven MODBUS TCP master library available for Arduino? – dskorupinski Jun 7 '18 at 19:22
0

The code is missing "#endif". Should look something like this:

#ifndef WIZNET_W5100
#define WIZNET_W5100  0       /**< define 1 if  WIZNET W5100 IC is used, otherwise 0 */
#endif
#ifndef ENC28J60
#define ENC28J60      1       /**< define 1 if  ENC28J60 IC is used, otherwise 0     */
#endif
#ifndef ESP8266
#define ESP8266       0
#endif

Cheers!

| improve this answer | |
  • A new error available:modbusTCPlib_enc28j60:23: error: token "=" is not valid in preprocessor expressions #define ENC28J60 = 1 – dskorupinski Jun 8 '18 at 19:03
  • Did you accept the answer above? And now adding a new question. Fun! – Mikael Patel Jun 8 '18 at 19:57
  • I'm trying fix the bugs in the code. In the moment nothing works. All trails brings nothing. So I would ask ones again. Is there any good working and also tested and proven and error free MODBUS TCP master library available for Arduino? Thank you in advance. – dskorupinski Jun 8 '18 at 22:17
  • Have you read how to use this site? arduino.stackexchange.com/tour I recommend that you follow this procedure. It will give you more answers and friends. – Mikael Patel Jun 9 '18 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.