Skip to content

Commit 62bccf9

Browse files
committed
Code cleanup, remove debug code
Code intended for debugging was removed. Not useful anymore, limited abillities.
1 parent 808aa7a commit 62bccf9

File tree

4 files changed

+2
-44
lines changed

4 files changed

+2
-44
lines changed

arduino-modbus-rtu-tcp-gateway/01-interfaces.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ void startEthernet() {
8686
if (Ethernet.hardwareStatus() == EthernetW5100) {
8787
maxSockNum = 4; // W5100 chip never supports more than 4 sockets
8888
}
89-
dbg(F("[arduino] Server available at http://"));
90-
dbgln(Ethernet.localIP());
9189
}
9290

9391
void (*resetFunc)(void) = 0; //declare reset function at address 0

arduino-modbus-rtu-tcp-gateway/04-webserver.ino

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ enum post_key : byte {
8484
void recvWeb() {
8585
EthernetClient client = webServer.available();
8686
if (client) {
87-
dbg(F("[web in] Data from client "));
88-
8987
char uri[smallbuffersize]; // the requested page
9088
// char requestParameter[smallbuffersize]; // parameter appended to the URI after a ?
9189
// char postParameter[smallbuffersize] {'\0'}; // parameter transmitted in the body / by POST
@@ -102,34 +100,19 @@ void recvWeb() {
102100
status = REQUEST;
103101
while (client.available()) {
104102
char c = client.read();
105-
// dbg(c); // Debug print received characters to Serial monitor
106103
if (c == '\n') {
107104
if (status == REQUEST) // read the first line
108105
{
109-
dbg(F("[web in] webInBuffer="));
110-
dbgln(webInBuffer);
111106
// now split the input
112107
char *ptr;
113108
ptr = strtok(webInBuffer, " "); // strtok willdestroy the newRequest
114109
ptr = strtok(NULL, " ");
115110
strlcpy(uri, ptr, sizeof(uri)); // enthält noch evtl. parameter
116-
dbg(F("[web in] uri="));
117-
dbgln(uri);
118111
status = EMPTY_LINE; // jump to next status
119112
} else if (status > REQUEST && i < 2) // check if we have an empty line
120113
{
121114
status = BODY;
122115
}
123-
// else if (status == BODY)
124-
// {
125-
// dbg(F("[web] postParameter=")); dbgln(webInBuffer);
126-
// if (webInBuffer[0] != '\0') {
127-
// dbg(F("[web] Processing POST"));
128-
// processPost(webInBuffer);
129-
// }
130-
// // strlcpy(postParameter, webInBuffer, sizeof(postParameter));
131-
// break; // we have received one line payload and break out
132-
// }
133116
i = 0;
134117
memset(webInBuffer, 0, sizeof(webInBuffer));
135118
} else {
@@ -143,8 +126,6 @@ void recvWeb() {
143126
}
144127
if (status == BODY) // status 3 could end without linefeed, therefore we takeover here also
145128
{
146-
dbg(F("[web in] POST data="));
147-
dbgln(webInBuffer);
148129
if (webInBuffer[0] != '\0') {
149130
processPost(webInBuffer);
150131
}
@@ -350,7 +331,6 @@ void processPost(char postParameter[]) {
350331
// new parameter values received, save them to EEPROM
351332
EEPROM.put(configStart + 1, localConfig); // it is safe to call, only changed values are updated
352333
if (action == SERIAL_SOFT) { // can do it without "please wait" page
353-
dbgln(F("[serial] reload Serial"));
354334
Serial.flush();
355335
Serial.end();
356336
startSerial();

arduino-modbus-rtu-tcp-gateway/05-pages.ino

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const byte webOutBufferSize = 128; // size of web server write buffer (used by
2929
void sendPage(EthernetClient &client, byte reqPage) {
3030
char webOutBuffer[webOutBufferSize];
3131
ChunkedPrint chunked(client, webOutBuffer, sizeof(webOutBuffer)); // the StreamLib object to replace client print
32-
dbgln(F("[web out] 200 response send"));
3332
chunked.print(F("HTTP/1.1 200 OK\r\n"
3433
"Connection: close\r\n"
3534
"Content-Type: text/html\r\n"
@@ -629,15 +628,12 @@ void helperStats(ChunkedPrint &chunked, const byte stat) {
629628
}
630629

631630
void send404(EthernetClient &client) {
632-
dbgln(F("[web out] response 404 file not found"));
633631
client.println(F("HTTP/1.1 404 Not Found\r\n"
634632
"Content-Length: 0"));
635633
client.stop();
636634
}
637635

638-
639636
void send204(EthernetClient &client) {
640-
dbgln(F("[web out] response 204 no content"));
641637
client.println(F("HTTP/1.1 204 No content"));
642638
client.stop();
643639
}

arduino-modbus-rtu-tcp-gateway/arduino-modbus-rtu-tcp-gateway.ino

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const byte version[] = { 4, 0 };
5858

5959
/****** ADVANCED SETTINGS ******/
6060

61-
const byte maxQueueRequests = 10; // max number of TCP or UDP requests stored in a queue
61+
const byte maxQueueRequests = 10; // max number of TCP or UDP requests stored in a queue
6262
const int maxQueueData = 256; // total length of TCP or UDP requests stored in a queue (in bytes)
6363
const byte maxSlaves = 247; // max number of Modbus slaves (Modbus supports up to 247 slaves, the rest is for reserved addresses)
6464
const int modbusSize = 256; // size of a MODBUS RTU frame (determines size of serialInBuffer and tcpInBuffer)
@@ -148,13 +148,7 @@ const byte MAC_START[3] = { 0x90, 0xA2, 0xDA };
148148
EthernetUDP Udp;
149149
EthernetServer modbusServer(502);
150150
EthernetServer webServer(80);
151-
#ifdef DEBUG
152-
#define dbg(x...) debugSerial.print(x);
153-
#define dbgln(x...) debugSerial.println(x);
154-
#else /* DEBUG */
155-
#define dbg(x...) ;
156-
#define dbgln(x...) ;
157-
#endif /* DEBUG */
151+
158152
#define UDP_REQUEST 0xFF // We store these codes in "header.clientNum" in order to differentiate
159153
#define SCAN_REQUEST 0xFE // between TCP requests (their clientNum is nevew higher than 0x07), UDP requests and scan requests (triggered by scan button)
160154

@@ -251,14 +245,8 @@ void setup() {
251245
EEPROM.write(configStart, version[0]);
252246
EEPROM.put(configStart + 1, localConfig);
253247
}
254-
255-
#ifdef DEBUG
256-
debugSerial.begin(localConfig.baud); // same baud as RS485
257-
#endif /* DEBUG */
258-
259248
startSerial();
260249
startEthernet();
261-
dbgln(F("\n[arduino] Starting..."));
262250
}
263251

264252
/****** LOOP ******/
@@ -267,12 +255,8 @@ void loop() {
267255
recvUdp();
268256
recvTcp();
269257
processRequests();
270-
271-
#ifndef DEBUG
272258
sendSerial();
273259
recvSerial();
274-
#endif /* DEBUG */
275-
276260
recvWeb();
277261

278262
#ifdef ENABLE_DHCP

0 commit comments

Comments
 (0)