You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#defineRS485_CONTROL_PIN 6 // Arduino Pin for RS485 Direction control, disable if you have module with hardware flow control
10
+
constbyteMAX_QUEUE_REQUESTS=10; // max number of TCP or UDP requests stored in a queue
11
+
constintMAX_QUEUE_DATA=256; // total length of TCP or UDP requests stored in a queue (in bytes)
12
+
constbyteMAX_SLAVES=247; // max number of Modbus slaves (Modbus supports up to 247 slaves, the rest is for reserved addresses)
13
+
constintMODBUS_SIZE=256; // size of a MODBUS RTU frame (determines size of various buffers)
14
+
constbyteMAX_RESPONSE_LEN=16; // Max length (bytes) of the Modbus response shown in WebUI
15
+
constbyteSCAN_FUNCTION_FIRST=0x03; // Function code sent during Modbus RTU Scan request (first attempt)
16
+
constbyteSCAN_FUNCTION_SECOND=0x04; // Function code sent during Modbus RTU Scan request (second attempt)
17
+
constbyteSCAN_DATA_ADDRESS=0x01; // Data address sent during Modbus RTU Scan request (both attempts)
18
+
constunsigned intSCAN_TIMEOUT=200; // Timeout (ms) for Modbus scan requests
19
+
20
+
constbyteMAC_START[3] = { 0x90, 0xA2, 0xDA }; // MAC range for Gheo SA
21
+
constbyteETH_RESET_PIN=7; // Ethernet shield reset pin (deals with power on reset issue on low quality ethernet shields)
22
+
constunsigned intETH_RESET_DELAY=500; // Delay (ms) during Ethernet start, wait for Ethernet shield to start (reset issue on low quality ethernet shields)
23
+
constunsigned intWEB_IDLE_TIMEOUT=400; // Time (ms) from last client data after which webserver TCP socket could be disconnected, non-blocking.
24
+
constunsigned intTCP_DISCON_TIMEOUT=500; // Timeout (ms) for client DISCON socket command, non-blocking alternative to https://www.arduino.cc/reference/en/libraries/ethernet/client.setconnectiontimeout/
25
+
constunsigned intTCP_RETRANSMISSION_TIMEOUT=50; // Ethernet controller’s timeout (ms), blocking (see https://www.arduino.cc/reference/en/libraries/ethernet/ethernet.setretransmissiontimeout/)
26
+
constbyteTCP_RETRANSMISSION_COUNT=3; // Number of transmission attempts the Ethernet controller will make before giving up (see https://www.arduino.cc/reference/en/libraries/ethernet/ethernet.setretransmissioncount/)
27
+
constintFETCH_INTERVAL=2000; // Fetch API interval (ms) for the Modbus Status webpage to renew data from JSON served by Arduino
28
+
29
+
constintCONFIG_START=96; // Start address where config and counters are saved in EEPROM
30
+
constbyteEEPROM_INTERVAL=6; // Interval (hours) for saving Modbus statistics to EEPROM (in order to minimize writes to EEPROM)
31
+
32
+
/****** EXTRA FUNCTIONS ******/
33
+
34
+
// these do not fit into the limited flash memory of Arduino Uno/Nano, uncomment if you have a board with more memory
35
+
// #define ENABLE_DHCP // Enable DHCP (Auto IP settings)
36
+
// #define ENABLE_EXTRA_DIAG // Enable Ethernet and Serial byte counter.
37
+
// #define TEST_SOCKS // shows 1) port, 2) status and 3) age for all sockets in "Modbus Status" page. IP settings are not available.
38
+
39
+
/****** DEFAULT FACTORY SETTINGS ******/
40
+
41
+
/*
42
+
Please note that after boot, Arduino loads user settings stored in EEPROM, even if you flash new program to it!
43
+
Arduino loads factory defaults if:
44
+
1) User clicks "Load default settings" in WebUI (factory reset configuration, keeps MAC)
45
+
2) VERSION_MAJOR changes (factory reset configuration AND generates new MAC)
46
+
*/
47
+
constconfig_typeDEFAULT_CONFIG= {
48
+
{}, // MAC Address (last 3 bytes)
49
+
{ 192, 168, 1, 254 }, // Static IP
50
+
{ 255, 255, 255, 0 }, // Submask
51
+
{ 192, 168, 1, 1 }, // Gateway
52
+
{ 192, 168, 1, 1 }, // Dns (only used if ENABLE_DHCP)
53
+
false, // enableDhcp (only used if ENABLE_DHCP)
54
+
502, // Modbus TCP Port
55
+
502, // Modbus UDP Port
56
+
80, // WebUI Port
57
+
false, // Modbus Mode (enableRTU over TCP)
58
+
600, // Modbus TCP Idle Timeout
59
+
96, // Baud Rate / 100
60
+
SERIAL_8E1, // Serial Config (Data Bits, Parity, Stop bits), Modbus RTU default is 8E1, another frequently used option is 8N2
const byte TCP_RETRANSMISSION_COUNT = 3; // Number of transmission attempts the Ethernet controller will make before giving up (see https://www.arduino.cc/reference/en/libraries/ethernet/ethernet.setretransmissioncount/)
0 commit comments