46byte PDUlen; // lenght of PDU (func + data) stored in queuePDUs
47 IPAddress remIP; // remote IP for UDP client (UDP response is sent back to remote IP)
48unsignedint remPort; // remote port for UDP client (UDP response is sent back to remote port)
49byte clientNum; // TCP client who sent the request, UDP_REQUEST (0xFF) designates UDP client
50} header;
51
52
53
54constbyte reqQueueCount = 15; // max number of TCP or UDP requests stored in queue
55constint reqQueueSize = 256; // total length of TCP or UDP requests stored in queue (in bytes)
56constbyte maxSlaves = 247; // max number of Modbus slaves (Modbus supports up to 247 slaves, the rest is for reserved addresses)
57constint modbusSize = 256; // size of a MODBUS RTU frame (determines size of serialInBuffer and tcpInBuffer)
58
59#define mySerial modbusSerial // define serial port for RS485 interface, for Arduino Mega choose from Serial1, Serial2 or Serial3
60
61// #define DEBUG // Main Serial (USB) is used for printing some debug info, not for Modbus RTU. At the moment, only web server related debug messages are printed.
62//#define debugSerial Serial
63
64#ifdef MAX_SOCK_NUM //if the macro MAX_SOCK_NUM is defined
65// #undef MAX_SOCK_NUM //un-define it
66// #define MAX_SOCK_NUM 8 //redefine it with the new value
67#endif
68
69/****** ETHERNET AND SERIAL ******/
70
71#ifdef UDP_TX_PACKET_MAX_SIZE //if the macro MAX_SOCK_NUM is defined
72#undef UDP_TX_PACKET_MAX_SIZE //un-define it
73#define UDP_TX_PACKET_MAX_SIZE modbusSize //redefine it with the new value
74#endif
75
76
77
78
79//#ifdef DEBUG
80#define dbg(x...) debugSerial.print(x);
81#define dbgln(x...) debugSerial.println(x);
82//#else /* DEBUG */
83//#define dbg(x...) ;
84//#define dbgln(x...) ;
85//#endif /* DEBUG */
86
87#define UDP_REQUEST 0xFF // We store these codes in "header.clientNum" in order to differentiate
88#define SCAN_REQUEST 0xFE // between TCP requests (their clientNum is nevew higher than 0x07), UDP requests and scan requests (triggered by scan button)