- added error messages

git-svn-id: http://moon:8086/svn/projects/HendiControl@179 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-03-30 15:41:56 +00:00
parent 79b5936707
commit 59f4881437
+48 -23
View File
@@ -212,31 +212,47 @@ int main(void)
else if (toupper(*pArgs) == 'R') else if (toupper(*pArgs) == 'R')
{ {
pArgs++; pArgs++;
if (!isdigit(*pArgs)) if ((*pArgs) == '?')
{ {
break; pArgs++;
PRINT_ANSWER("OK:%d", (int)(state_next == StateRemote));
} }
uint16_t arg = (uint16_t)strtol(pArgs, &pArgs, 10); else
if (arg == 1)
{ {
// Enter remote if (!isdigit(*pArgs))
if (state == StateNormal)
{ {
setPower(PowerLow); break;
setSwitch(SwitchOff);
state_next = StateRemote;
PRINT_ANSWER("OK");
} }
} uint16_t arg = (uint16_t)strtol(pArgs, &pArgs, 10);
else if (arg == 0) if (arg == 1)
{
// Exit remote
if (state == StateRemote)
{ {
setPower(PowerLow); // Enter remote
setSwitch(SwitchOff); if (state == StateNormal)
state_next = StateNormal; {
PRINT_ANSWER("OK"); setPower(PowerLow);
setSwitch(SwitchOff);
state_next = StateRemote;
PRINT_ANSWER("OK");
}
else
{
PRINT_ANSWER("INVALID STATE");
}
}
else if (arg == 0)
{
// Exit remote
if (state == StateRemote)
{
setPower(PowerLow);
setSwitch(SwitchOff);
state_next = StateNormal;
PRINT_ANSWER("OK");
}
else
{
PRINT_ANSWER("INVALID STATE");
}
} }
} }
} }
@@ -245,12 +261,20 @@ int main(void)
else if (toupper(*pArgs) == 'D') else if (toupper(*pArgs) == 'D')
{ {
pArgs++; pArgs++;
if (!isdigit(*pArgs)) if ((*pArgs) == '?')
{ {
break; pArgs++;
PRINT_ANSWER("OK:%d", (int)(state_next == StateRemote));
}
else
{
if (!isdigit(*pArgs))
{
break;
}
g_debug = (uint16_t)strtol(pArgs, &pArgs, 10);
PRINT_ANSWER("OK");
} }
g_debug = (uint16_t)strtol(pArgs, &pArgs, 10);
PRINT_ANSWER("OK");
} }
// SW identifier // SW identifier
@@ -291,6 +315,7 @@ int main(void)
else else
{ {
pArgs++; pArgs++;
PRINT_ANSWER("UNKNOWN COMMAND");
} }
} // while (*pArgs) } // while (*pArgs)