using the wifly and the mbed i encounter yet another odd problem. The problem is that the 2nd time function "Mod" was call , the scanf was unable to accept any input value ... the code is as follow
#include "mbed.h"
Serial wifi(p28, p27);
int //the list is a bit long but all varaible are declared as integer
void Mod()
{
int Confirm; //use to confirm if it is the desired input
Confirm=0;
do
{
fflush(stdin);
FHz = 0;
wifi.printf("\r\nFertilizing frequency in hrs?\r\n");
while(FHz == 0)
{
fflush(stdin);
wifi.scanf("%d", &FHz);
wifi.getc();
if(FHz == 0)
{ wifi.printf("\r\nPlease enter the frequency again\r\n");
}
}
wifi.printf("\r\nThe fertilizer frequency is %d hrs? If not enter 1, if yes enter 0\r\n", FHz);
wifi.scanf("%d", &Confirm);
wifi.getc();
Min1=FHz*60;
}while(Confirm==1);
Confirm=0;
// the exact same thing is repeated for 3 otherr variable and ended with the following code
...
wifi.printf("\r\nTo make any changes to the value input the word mod into tera term\r\n");
mod2=0;
void Menu()//below is a portion of the menu function that deal with mod function
{
char Text[100];
wifi.scanf("%s", &Text);
wifi.getc();
char Mod[4] ="Mod";
if (strcasecmp(Mod,Text) == 0)
{
if(Process==0)
{
mod2=1;
}
else
{
wifi.printf("System is in operation, change of variable is locked . Please try again later.\r\n");
}
}
//following is the main prorgam
int main()
{
// Main program
//Intialization State
PHY_PowerDown();//Ethernet powerdown
result = semihost_powerdown();//USB power down (Note need new firmware)
set_time(NULL);
Close.fall(&ULS);
//insert code for drawing of data
char start[100];
char Boot[5] = "Boot";
while(1)
{ fflush(stdin);
void flush();
wifi.scanf("%s", &start);
wifi.getc();
if (strcasecmp(Boot,start) == 0)
{
wifi.printf("\r\nBooting System, please standby\r\n");
// wait(3);
wifi.printf("All system green\r\n");
wifi.printf("Please input the following variables\r\n");
Mod();
Ready=2;
}
while(Ready==2)
{
if (Prevent==0)
{
FT.attach(Fert,180);
MT.attach(Moist,1200);
wifi.attach(&Menu);
Prevent=1;
}
if(mod2==1)
{
fflush(stdin);
Mod();
}
Sleep();
}
}
}
the error is that when I type in mod after the first call of mod , it is able to bring up the function . however any input I type will either yield A)no respond or B)
print "Please enter the frequency again"
i trying to fflush(stdin) to see if it will resolve it but it dint seem to work ~ could anyone advice me on what is wrong ?
P.S : if it lacking detail do let me know thanks again for your help
using the wifly and the mbed i encounter yet another odd problem. The problem is that the 2nd time function "Mod" was call , the scanf was unable to accept any input value ... the code is as follow
the error is that when I type in mod after the first call of mod , it is able to bring up the function . however any input I type will either yield A)no respond or B) print "Please enter the frequency again"
i trying to fflush(stdin) to see if it will resolve it but it dint seem to work ~ could anyone advice me on what is wrong ?
P.S : if it lacking detail do let me know thanks again for your help