LowPowerLab Forum

Hardware support => General topics => Topic started by: gianmarko on May 11, 2015, 05:47:16 AM

Title: moteino coding question
Post by: gianmarko on May 11, 2015, 05:47:16 AM
hello gentlemen.
i have a question for the C experts here. i am only a C hobbyist and sometimes i see mysterious things happening, when using this esoteric language :)

so here is the code i am running on the base station of my house alarm system. i have a bunch of sensors sending a message of the type "DO01", "DO02"  etc, and the receiver is doing certain things depending on the type of alarm received

the code is here, see the comments in the code. the problem occurs only when a message MO01 is received. changing the MO01 in MO06 (and of course changing the code in the sending moteino) fixes the error, but for the life of me i cant figure out why

i know, the code sucks :-) but as i said im a hobbyist and the code was developed in the very little free time i have

thanks to anyone who would like to comment.

Title: Re: moteino coding question
Post by: Felix on May 11, 2015, 08:11:00 AM
Could you please insert the code in a [ code ] tag so we can read it instead of having to download it...
Title: Re: moteino coding question
Post by: gianmarko on May 12, 2015, 04:47:56 AM
oops

will do

gm

code is more than 5000 characters and will not let me post it...


here the snippet that gives the problem, but taken out of context not sure is of any use


if (strncmp(buffx,"DO05",4) == 0)
  strcpy(buff1,"Door Wintr2 ");

//======================================================== error occurs here
// here variable smsen is normally set to 0
//
if (strncmp(buffx,"MO01",4) == 0) {
// when the if condition is satisfied, smsen is now set to 32
// changing MO01 into MO06 in the if statement, the smsen variable is not corrupted...
//
//
  strcpy(buff1,"Motn Keller ");
  if (digitalRead(NIGHTMODEPIN) == HIGH)
     soundAlarm(); 
}
 




Quote from: Felix on May 11, 2015, 08:11:00 AM
Could you please insert the code in a [ code ] tag so we can read it instead of having to download it...
Title: Re: moteino coding question
Post by: Felix on May 12, 2015, 08:38:29 AM
Really sorry but from what I see I cannot tell what could be wrong.
Title: Re: moteino coding question
Post by: syrinxtech on June 19, 2015, 01:52:23 PM
Why not just attach the INO file?