Skip to content

Commit

Permalink
Merge pull request #92 from nielsonm236/Code-fixes
Browse files Browse the repository at this point in the history
Code fixes
  • Loading branch information
nielsonm236 authored Feb 5, 2022
2 parents c0def8e + 1fd4ed9 commit bee2212
Show file tree
Hide file tree
Showing 14 changed files with 529 additions and 351 deletions.
Binary file not shown.
Binary file not shown.
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>
# Sat Aug 21 09:49:07 2021
# Sat Feb 05 11:12:49 2022
#
"networkmodule_vector.o"
487 changes: 244 additions & 243 deletions NetworkModule/.Idea_Temp/COBJ.TMP

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions NetworkModule/.Idea_Temp/IDEA.ERR
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ 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 @@ -71,15 +70,13 @@ 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 Sat Aug 21 09:49:03 2021
REM Sat Feb 05 11:12:45 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
81 changes: 68 additions & 13 deletions NetworkModule/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
//---------------------------------------------------------------------------//
//---------------------------------------------------------------------------//
//---------------------------------------------------------------------------//
const char code_revision[] = "20210821 1541"; // Normal Release Revision
const char code_revision[] = "20220205 1645"; // Normal Release Revision
// const char code_revision[] = "20210529 1999"; // Browser Only test build
// const char code_revision[] = "20210529 2999"; // MQTT test build
// const char code_revision[] = "20210531 CU01"; // Code Uploader test build
Expand Down Expand Up @@ -477,9 +477,10 @@ int main(void)
upgrade_EEPROM(); // Check for down revision EEPROM and upgrade if
// needed.

check_eeprom_settings(); // Check the EEPROM for previously stored Address
// and IO settings. Use defaults (if nothing
// stored) or restore previously stored settings.
check_eeprom_settings(); // Apply settings stored in EEPROM such as IP
// Address, Gateway Address, Netmask, Port number,
// etc. If there are no previously stored settings
// in the EEPROM then use defaults.
// This must occur before gpio_init() because
// gpio_init() uses settings in the EEPROM and we
// need to make sure it is up to date.
Expand Down Expand Up @@ -812,6 +813,12 @@ int main(void)
// an ARP request, and on a future cycle through this routine the
// SYN will be sent IF the ARP request was successful.
//
// Note: From time to time I see a lot of re-xmit attempts with the
// Browser interface. This doesn't seem to hurt anything so far, but
// it does slow down painting of a Browser page. I suspect the
// timeout for uip_periodic() may be too short. On the otherhand,
// shorter is better for servicing MQTT. So, it is a compromise but
// might need examination in the future it it become problematic.
if (uip_len > 0) {
uip_arp_out(); // Verifies arp entry in the ARP table and builds
// the LLH
Expand Down Expand Up @@ -3665,9 +3672,16 @@ void check_runtime_changes(void)
}
#endif BUILD_SUPPORT == BROWSER_ONLY_BUILD

if (parse_complete || mqtt_parse_complete) {

// UARTPrintf("parse_complete = ");
// emb_itoa(parse_complete, OctetArray, 10, 1);
// UARTPrintf(OctetArray);
// UARTPrintf(" mqtt_parse_complete = ");
// emb_itoa(mqtt_parse_complete, OctetArray, 10, 1);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");

if (parse_complete || mqtt_parse_complete) {
// Check for changes from the user via the GUI, MQTT, or REST commands.
// If parse_complete == 1 all TCP Fragments have been received during
// HTML POST processing, OR a REST command was processed.
Expand Down Expand Up @@ -3708,7 +3722,18 @@ void check_runtime_changes(void)
{
int i;
for (i=0; i<16; i++) {


// UARTPrintf("pin_control");
// emb_itoa(i, OctetArray, 10, 2);
// UARTPrintf(OctetArray);
// UARTPrintf(" ");
// emb_itoa(pin_control[i], OctetArray, 2, 8);
// UARTPrintf(OctetArray);
// UARTPrintf(" Pending_pin_control ");
// emb_itoa(Pending_pin_control[i], OctetArray, 2, 8);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");

if (pin_control[i] != Pending_pin_control[i]) {
// Something changed - sort it out

Expand Down Expand Up @@ -3776,6 +3801,11 @@ void check_runtime_changes(void)
pin_control[i] &= 0x80;
pin_control[i] |= (uint8_t)(Pending_pin_control[i] & 0x7f);
}

// UARTPrintf("Updated pin_control ");
// emb_itoa(pin_control[i], OctetArray, 2, 8);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");

if (update_EEPROM) {
// Update the stored_pin_control[] variables
Expand Down Expand Up @@ -3848,7 +3878,10 @@ void check_runtime_changes(void)
if (stored_port != Pending_port) {
// Write the new Port number to the EEPROM
stored_port = Pending_port;
// A firmware restart will occur to cause this change to take effect
// A firmware restart will occur to cause this change to take effect.
// The restart process will call uip_init() which will zero out all
// entries in the uip_listenports table, and will then put the new
// listenport number in the table.
restart_request = 1;
}

Expand Down Expand Up @@ -3936,6 +3969,17 @@ void check_runtime_changes(void)
user_reboot_request = 0;
reboot_request = 1;
}

// UARTPrintf("Restart Request ");
// emb_itoa(restart_request, OctetArray, 10, 1);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");

// UARTPrintf("Reboot Request ");
// emb_itoa(reboot_request, OctetArray, 10, 1);
// UARTPrintf(OctetArray);
// UARTPrintf("\r\n");

}


Expand All @@ -3944,7 +3988,9 @@ void check_runtime_changes(void)
// will be called. This is done this way because we need to let
// uip_periodic() handle the closing of connections.

parse_complete = 0; // Reset parse_complete for future changes
// Reset parse_complete for future changes
parse_complete = 0;
mqtt_parse_complete = 0;

// Periodic check of the stack overflow guardband
if (stack_limit1 != 0xaa || stack_limit2 != 0x55) {
Expand Down Expand Up @@ -4167,11 +4213,20 @@ void restart(void)

spi_init(); // Initialize the SPI bit bang interface to the
// ENC28J60 and perform hardware reset on ENC28J60
check_eeprom_settings(); // Verify EEPROM up to date
Enc28j60Init(); // Initialize the ENC28J60 ethernet interface
uip_arp_init(); // Initialize the ARP module
uip_init(); // Initialize uIP
HttpDInit(); // Initialize httpd; sets up listening ports
check_eeprom_settings(); // Apply settings stored in EEPROM such as IP
// Address, Gateway Address, Netmask, Port number,
// etc. Needed in a restart to make sure all
// changes made on the Configuration page are
// applied.
Enc28j60Init(); // Initialize the ENC28J60 ethernet interface.
// Needed in a restart to make sure the ENC20J60
// is updated with the correct MAC address.
uip_arp_init(); // Initialize the ARP module. The only thing this
// does is clear the IP addresses in the ARP table.
uip_init(); // Initialize uIP. This function call sets all
// connections to "CLOSED" and clears out the
// uip_listenports table.
HttpDInit(); // Initialize httpd and set up listening port

LEDcontrol(1); // Turn LED on
// From here we return to the main loop and should start running with new
Expand Down
Binary file added NetworkModule/NetworkModule.zip
Binary file not shown.
Loading

0 comments on commit bee2212

Please sign in to comment.