Skip to content

Commit

Permalink
No changes
Browse files Browse the repository at this point in the history
No changes. Re-syncing the Master branch as I used it to do some research on the uip.c code and then removed the debug instrumentation.
  • Loading branch information
nielsonm236 committed Oct 16, 2022
1 parent b3cae86 commit b1bf39a
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 7 deletions.
Binary file modified Network Module Manual - Code Rev 20221009 2141.docx
Binary file not shown.
2 changes: 1 addition & 1 deletion NetworkModule/.Idea_Groups/Vector_File.grp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Group File Created by IDEA
# Project: <NetworkModule>
# Sun Oct 09 18:40:27 2022
# Sat Oct 15 06:37:27 2022
#
"networkmodule_vector.o"
8 changes: 6 additions & 2 deletions NetworkModule/.Idea_Temp/IDEA.ERR
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ uip.o:
uip_arp.o:
uip_tcpapphub.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libisl0.sm8)memcmp.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libisl0.sm8)memmov.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libisl0.sm8)strcat0.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libisl0.sm8)strcmp0.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libisl0.sm8)strlen0.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libisl0.sm8)strncm.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)fctcpy.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)bmulx.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)eeprom.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)imul.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)itolx.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)itoly.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)ladc.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)ladd.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lcmp.o:
Expand All @@ -70,13 +72,15 @@ uip_tcpapphub.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lgor.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lgsbc.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lgsub.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lgursh.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lneg.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lreg.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)ltor.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)ludiv.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lumod.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)lzmp.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)rtol.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)sdivx.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)smul.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)utolx.o:
(C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\lib\libm0.sm8)xreg.o:
Expand Down
2 changes: 1 addition & 1 deletion NetworkModule/.Idea_Temp/IDEABLD.BAT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REM COMMAND FILE BUILT BY IDEA
REM Sun Oct 09 18:40:23 2022
REM Sat Oct 15 06:37:23 2022
REM
cxstm8 -v -l +strict +debug +modsl0 +split +warn "networkmodule_vector.c"
cxstm8 -v -l +strict +debug +modsl0 +split +warn "ds18b20.c" "enc28j60.c" "gpio.c" "httpd.c" "i2c.c" "main.c" "mqtt.c" "mqtt_pal.c" "spi.c" "timer.c" "uart.c" "uip.c" "uip_arp.c" "uip_tcpapphub.c"
Expand Down
5 changes: 5 additions & 0 deletions NetworkModule/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,11 @@ int main(void)
// payload.
if (((struct uip_eth_hdr *) & uip_buf[0])->type == htons(UIP_ETHTYPE_IP)) {
// UARTPrintf("Detected uip_len > 0 UIP_ETHTYPE_IP\r\n");
// UARTPrintf("uip_len = ");
// emb_itoa(uip_len, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");

uip_input(); // Calls uip_process(UIP_DATA) to process a received
// packet.
// If the above process resulted in data that should be sent out on
Expand Down
13 changes: 12 additions & 1 deletion NetworkModule/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3678,7 +3678,8 @@ void init_tHttpD_struct(struct tHttpD* pSocket, int i) {
// that does not call out a specific page.

#if BUILD_SUPPORT == BROWSER_ONLY_BUILD || BUILD_SUPPORT == MQTT_BUILD
pSocket->current_webpage = WEBPAGE_IOCONTROL;
// pSocket->current_webpage = WEBPAGE_IOCONTROL;
pSocket->current_webpage = WEBPAGE_NULL;
// pSocket->structID = i; // TEMPORARY DEBUG MARKER
#endif // BUILD_SUPPORT == BROWSER_ONLY_BUILD || BUILD_SUPPORT == MQTT_BUILD

Expand Down Expand Up @@ -3721,14 +3722,20 @@ void HttpDCall(uint8_t* pBuffer, uint16_t nBytes, struct tHttpD* pSocket)
// UARTPrintf("HttpDCall: current_webpage = ");
// emb_itoa(pSocket->current_webpage, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
// UARTPrintf(" listening port = ");
// emb_itoa(uip_conn->lport, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
// UARTPrintf(" structID = ");
// emb_itoa(pSocket->structID, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");


if (uip_connected()) {
//Initialize this connection

// UARTPrintf("HttpDCall: uip_connected\r\n");

// UARTPrintf("HttpDCall: uip_connected current_webpage = ");
// emb_itoa(pSocket->current_webpage, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
Expand Down Expand Up @@ -3830,6 +3837,8 @@ void HttpDCall(uint8_t* pBuffer, uint16_t nBytes, struct tHttpD* pSocket)

else if (uip_acked()) {

// UARTPrintf("HttpDCall: uip_acked\r\n");

// UARTPrintf("HttpDCall: uip_acked current_webpage = ");
// emb_itoa(pSocket->current_webpage, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
Expand All @@ -3848,6 +3857,8 @@ void HttpDCall(uint8_t* pBuffer, uint16_t nBytes, struct tHttpD* pSocket)

else if (uip_newdata()) {

// UARTPrintf("HttpDCall: uip_newdata\r\n");

// UARTPrintf("HttpDCall: uip_newdata current_webpage = ");
// emb_itoa(pSocket->current_webpage, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
Expand Down
32 changes: 31 additions & 1 deletion NetworkModule/uip.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@
#include "uipopt.h"
#include "uip_arch.h"
#include "main.h"
#include "uart.h"

#include <string.h>

//---------------------------------------------------------------------------//
/* Variable definitions. */

extern uint8_t OctetArray[11]; // Used only in debug operations

/* The IP address of this host */
uip_ipaddr_t uip_hostaddr;
/* The IP address of the default router (aka gateway) */
Expand Down Expand Up @@ -479,6 +482,7 @@ void uip_process(uint8_t flag)
// present, so uip_len should be zero when it occurs.
if (flag == UIP_POLL_REQUEST) {
if ((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED && !uip_outstanding(uip_connr)) {
// UARTPrintf(" uip.c: APPCALL due to POLL REQUEST\r\n");
uip_flags = UIP_POLL;
UIP_APPCALL(); // Check for any data to be sent
goto appsend;
Expand Down Expand Up @@ -526,6 +530,7 @@ void uip_process(uint8_t flag)
// We call UIP_APPCALL() with uip_flags set to UIP_TIMEDOUT to
// inform the application that the connection has timed out.
uip_flags = UIP_TIMEDOUT;
// UARTPrintf(" uip.c: APPCALL due to Timeout\r\n");
UIP_APPCALL(); // Timeout call. uip_len was cleared above.

// We also send a reset packet to the remote host.
Expand Down Expand Up @@ -561,6 +566,7 @@ void uip_process(uint8_t flag)
// the actual retransmit after which we jump into the code for
// sending out the packet (the apprexmit label).
uip_flags = UIP_REXMIT;
// UARTPrintf(" uip.c: APPCALL due to ESTABLISHED\r\n");
UIP_APPCALL(); // Call to get old data for retransmit. uip_len
// was cleared above.
goto apprexmit;
Expand All @@ -586,6 +592,12 @@ void uip_process(uint8_t flag)
goto drop;
}

// UARTPrintf(" uip_input: listening port = ");
// emb_itoa(uip_conn->lport, OctetArray, 10, 5);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");



//---------------------------------------------------------------------------//
// This is where the input processing starts. We fall through to this point
Expand All @@ -597,6 +609,7 @@ void uip_process(uint8_t flag)
if (BUF->vhl != 0x45) { // IP version and header length.
UIP_STAT(++uip_stat.ip.drop);
UIP_STAT(++uip_stat.ip.vhlerr);
// UARTPrintf(" uip.c: drop invlaid header\r\n");
goto drop;
}

Expand All @@ -610,12 +623,16 @@ void uip_process(uint8_t flag)
if ((BUF->len[0] << 8) + BUF->len[1] <= uip_len) {
uip_len = (BUF->len[0] << 8) + BUF->len[1];
}
else goto drop;
else {
// UARTPrintf(" uip.c: drop invalid length\r\n");
goto drop;
}

// Check the fragment flag.
if ((BUF->ipoffset[0] & 0x3f) != 0 || BUF->ipoffset[1] != 0) {
UIP_STAT(++uip_stat.ip.drop);
UIP_STAT(++uip_stat.ip.fragerr);
// UARTPrintf(" uip.c: fragerr\r\n");
goto drop;
}

Expand All @@ -624,12 +641,14 @@ void uip_process(uint8_t flag)
// address FF:FF:FF:FF)
if (!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr)) {
UIP_STAT(++uip_stat.ip.drop);
// UARTPrintf(" uip.c: drop not our IP address\r\n");
goto drop;
}

if (uip_ipchksum() != 0xffff) { /* Compute and check the IP header checksum. */
UIP_STAT(++uip_stat.ip.drop);
UIP_STAT(++uip_stat.ip.chkerr);
// UARTPrintf(" uip.c: drop checksum error\r\n");
goto drop;
}

Expand All @@ -646,6 +665,8 @@ void uip_process(uint8_t flag)
goto drop;
}

// UARTPrintf(" uip.c: ICMP\r\n");

UIP_STAT(++uip_stat.icmp.recv);

// ICMP echo (i.e., ping) processing. This is simple, we only change the
Expand Down Expand Up @@ -902,6 +923,7 @@ void uip_process(uint8_t flag)
// apps do not check for UIP_CLOSED or UIP_ABORT.
// If this call is left here it seems we should force uip_len = 0
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// UARTPrintf(" uip.c: APPCALL due to RESET\r\n");
UIP_APPCALL(); // ????
goto drop;
}
Expand Down Expand Up @@ -993,6 +1015,7 @@ void uip_process(uint8_t flag)
uip_add_rcv_nxt(uip_len);
}
uip_slen = 0;
// UARTPrintf(" uip.c: APPCALL due to SYN_RCVD\r\n");
UIP_APPCALL(); // We may have received data with the SYN
goto appsend;
}
Expand Down Expand Up @@ -1054,6 +1077,7 @@ void uip_process(uint8_t flag)
uip_connr->len = 0;
uip_len = 0;
uip_slen = 0;
// UARTPrintf(" uip.c: APPCALL due to SYN_SENT\r\n");
UIP_APPCALL(); // This checks to see if there is any data to send with
// the ACK. Don't call it if you want to send a pure ACK.
// Note that uip_len is set to zero before the call.
Expand All @@ -1064,6 +1088,7 @@ void uip_process(uint8_t flag)
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// In this case the applications don't do anything with this information.
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// UARTPrintf(" uip.c: APPCALL due to ABORT\r\n");
UIP_APPCALL(); // ???
// The connection is closed after we send the RST
uip_conn->tcpstateflags = UIP_CLOSED;
Expand All @@ -1090,6 +1115,7 @@ void uip_process(uint8_t flag)
if (uip_len > 0) {
uip_flags |= UIP_NEWDATA;
}
// UARTPrintf(" uip.c: APPCALL due to UIP_ESTABLISHED\r\n");
UIP_APPCALL(); // This processes any receive data and sets up any
// transmit data to send with the the ACK.
uip_connr->len = 1;
Expand Down Expand Up @@ -1151,6 +1177,7 @@ void uip_process(uint8_t flag)
// uip_len must be set to 0.
if (uip_flags & (UIP_NEWDATA | UIP_ACKDATA)) {
uip_slen = 0;
// UARTPrintf(" uip.c: APPCALL due to read data from browser\r\n");
UIP_APPCALL(); // Here is where the application will read data that
// arrived from the client/browser and then the
// application will fill the uip_buf with new data to
Expand Down Expand Up @@ -1243,6 +1270,7 @@ void uip_process(uint8_t flag)
// Not sure why there is an APPCALL here as we are closing the
// connection.
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// UARTPrintf(" uip.c: APPCALL due to UIP_LAST_ACK\r\n");
UIP_APPCALL(); // ???
}
break;
Expand All @@ -1269,6 +1297,7 @@ void uip_process(uint8_t flag)
// Not sure why there is an APPCALL here as we are closing the
// connection.
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// UARTPrintf(" uip.c: APPCALL due to FIN_WAIT\r\n");
UIP_APPCALL(); // ???
goto tcp_send_ack;
}
Expand All @@ -1295,6 +1324,7 @@ void uip_process(uint8_t flag)
// Not sure why there is an APPCALL here as we are closing the
// connection.
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// UARTPrintf(" uip.c: APPCALL due to FIN_WAIT2\r\n");
UIP_APPCALL(); // ???
goto tcp_send_ack;
}
Expand Down
2 changes: 1 addition & 1 deletion NetworkModule/uipopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
// USAGE: Provides the most run time error data and UART display.
// * Specific debug data: Reset Status Register counters, TXERIF counter,
// RXERIF counter, Stack Overflow bit, and ENC28J60 revision level.
#define DEBUG_SUPPORT 11
#define DEBUG_SUPPORT 15


// IWDG_ENABLE
Expand Down

0 comments on commit b1bf39a

Please sign in to comment.