Skip to content

Commit

Permalink
Code optimization, bugfix DHCP settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
budulinek committed Jan 28, 2022
1 parent ac49705 commit 5ee77b5
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 220 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Get the hardware (cheap clones from China are sufficient) and connect together:
Rx0 <-> RO<br>
Pin 6 <-> DE,RE


Here is my setup:
Terminal shield + Arduino Nano + W5500 eth shield (RobotDyn) + TTL to RS485 module (HW automatic flow control)
<img src="/pics/HW.jpg" alt="01" style="zoom:100%;" />
Expand Down Expand Up @@ -93,7 +94,7 @@ The code was tested on Arduino Nano, Uno and Mega, ethernet chips W5100 and W550

#### Ethernet socket

The default Ethernet.h library determines MAX_SOCK_NUM by microcontroller RAM (not by Ethernet chip type). So if you use W5500 (which has 8 sockets available) on Arduino Nano, only 4 sockets will be used. If you want to force the library to use 8 sockets, edit https://github.com/arduino-libraries/Ethernet/blob/master/src/Ethernet.h#L36
The default Ethernet.h library determines MAX_SOCK_NUM by microcontroller RAM (not by Ethernet chip type). So if you use W5500 (which has 8 sockets available) on Arduino Nano, only 4 sockets will be used. If you want to force the library to use 8 sockets, redefine MAX_SOCK_NUM in advanced settings in the sketch.

#### Memory

Expand Down
6 changes: 3 additions & 3 deletions arduino-modbus-rtu-tcp-gateway/04-webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ void processPost(char postParameter[]) {
char *sav2 = NULL; // for inner strtok_r
paramKey = strtok_r(point, "=", &sav2); // inner strtok_r, use sav2
paramValue = strtok_r(NULL, "=", &sav2);
if (!paramValue) continue;
point = strtok_r(NULL, "&", &sav1);
if (!paramValue)
continue; // do not process POST parameter if there is no parameter value
byte paramKeyByte = atoi(paramKey);
unsigned long paramValueUlong = atol(paramValue);

switch (paramKeyByte) {
case POST_NONE: // reserved, because atoi / atol returns NULL in case of error
break;
Expand Down Expand Up @@ -307,7 +308,6 @@ void processPost(char postParameter[]) {
default:
break;
}
point = strtok_r(NULL, "&", &sav1);
} // while (point != NULL)
switch (action) {
case FACTORY:
Expand Down
Loading

0 comments on commit 5ee77b5

Please sign in to comment.