|
@@ -145,7 +145,8 @@ bool IoMan::init() {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-/* loop to fetch data from the network, doing light preprocessing on it to be handled by responseMain */
|
|
|
|
|
|
+/* loop to fetch data from the network, doing light preprocessing on it to be
|
|
|
|
+ * handled by responseMain */
|
|
void IoMan::networkMain() {
|
|
void IoMan::networkMain() {
|
|
vector<Json::Value> toput;
|
|
vector<Json::Value> toput;
|
|
char *recvjson;
|
|
char *recvjson;
|
|
@@ -232,7 +233,8 @@ void IoMan::networkMain() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-/* loop to handle input from the user and responseMain, sending data via network if required */
|
|
|
|
|
|
+/* loop to handle input from the user and responseMain, sending data via network
|
|
|
|
+ * if required */
|
|
void IoMan::inputMain() {
|
|
void IoMan::inputMain() {
|
|
vector<string> toprocess;
|
|
vector<string> toprocess;
|
|
string command;
|
|
string command;
|
|
@@ -366,7 +368,8 @@ void IoMan::inputMain() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-/* loop to handle responses that have been fetched by netMain and possibly add new commands to be handled by inputMain */
|
|
|
|
|
|
+/* loop to handle responses that have been fetched by netMain and possibly add
|
|
|
|
+ * new commands to be handled by inputMain */
|
|
void IoMan::responseMain() {
|
|
void IoMan::responseMain() {
|
|
vector<Json::Value> toprocess;
|
|
vector<Json::Value> toprocess;
|
|
vector<string> toput;
|
|
vector<string> toput;
|
|
@@ -477,16 +480,16 @@ void IoMan::responseMain() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-/* this is the handler that readlines alternative interface will use to process user input */
|
|
|
|
-void ioman_readlineHandler(char* line) {
|
|
|
|
|
|
+/* this is the handler that readlines alternative interface will use to process
|
|
|
|
+ * user input */
|
|
|
|
+void ioman_readlineHandler(char *line) {
|
|
vector<string> tokens;
|
|
vector<string> tokens;
|
|
- if(!line){
|
|
|
|
|
|
+ if (!line) {
|
|
printf("\nNULLBURGER\n");
|
|
printf("\nNULLBURGER\n");
|
|
gIOMAN->mainmutex.lock();
|
|
gIOMAN->mainmutex.lock();
|
|
gIOMAN->runmain = 0;
|
|
gIOMAN->runmain = 0;
|
|
gIOMAN->mainmutex.unlock();
|
|
gIOMAN->mainmutex.unlock();
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
// split input line into tokens
|
|
// split input line into tokens
|
|
boost::algorithm::split(tokens, std::string(line),
|
|
boost::algorithm::split(tokens, std::string(line),
|
|
boost::algorithm::is_any_of(" "),
|
|
boost::algorithm::is_any_of(" "),
|
|
@@ -494,14 +497,16 @@ void ioman_readlineHandler(char* line) {
|
|
if (strlen(line) && tokens.size()) {
|
|
if (strlen(line) && tokens.size()) {
|
|
add_history(line);
|
|
add_history(line);
|
|
|
|
|
|
- gIOMAN->localmutex.lock();
|
|
|
|
- gIOMAN->printMessage(string(__PRETTY_FUNCTION__) + string(" get localmutex"),
|
|
|
|
- gIOMAN->debug);
|
|
|
|
- gIOMAN->localinput.push_back(line);
|
|
|
|
- gIOMAN->localmutex.unlock();
|
|
|
|
- gIOMAN->printMessage(string(__PRETTY_FUNCTION__) + string(" release localmutex"),
|
|
|
|
- gIOMAN->debug);
|
|
|
|
- gIOMAN->localcv.notify_all();
|
|
|
|
|
|
+ gIOMAN->localmutex.lock();
|
|
|
|
+ gIOMAN->printMessage(string(__PRETTY_FUNCTION__) +
|
|
|
|
+ string(" get localmutex"),
|
|
|
|
+ gIOMAN->debug);
|
|
|
|
+ gIOMAN->localinput.push_back(line);
|
|
|
|
+ gIOMAN->localmutex.unlock();
|
|
|
|
+ gIOMAN->printMessage(string(__PRETTY_FUNCTION__) +
|
|
|
|
+ string(" release localmutex"),
|
|
|
|
+ gIOMAN->debug);
|
|
|
|
+ gIOMAN->localcv.notify_all();
|
|
}
|
|
}
|
|
free(line);
|
|
free(line);
|
|
}
|
|
}
|
|
@@ -552,13 +557,14 @@ void IoMan::run() {
|
|
return;
|
|
return;
|
|
initmutex.unlock();
|
|
initmutex.unlock();
|
|
initcv.notify_all();
|
|
initcv.notify_all();
|
|
-
|
|
|
|
- rl_callback_handler_install(getCmdPrompt().c_str(), (rl_vcpfunc_t*) &ioman_readlineHandler);
|
|
|
|
|
|
+
|
|
|
|
+ rl_callback_handler_install(getCmdPrompt().c_str(),
|
|
|
|
+ (rl_vcpfunc_t *)&ioman_readlineHandler);
|
|
|
|
|
|
mainmutex.lock();
|
|
mainmutex.lock();
|
|
while (runmain) {
|
|
while (runmain) {
|
|
mainmutex.unlock();
|
|
mainmutex.unlock();
|
|
-
|
|
|
|
|
|
+
|
|
poll(&inPipeStatus, 1, 100);
|
|
poll(&inPipeStatus, 1, 100);
|
|
|
|
|
|
if (inPipeStatus.revents & POLLIN) {
|
|
if (inPipeStatus.revents & POLLIN) {
|
|
@@ -569,8 +575,7 @@ void IoMan::run() {
|
|
mainmutex.lock();
|
|
mainmutex.lock();
|
|
}
|
|
}
|
|
mainmutex.unlock();
|
|
mainmutex.unlock();
|
|
-
|
|
|
|
- // Remove the handler
|
|
|
|
- rl_callback_handler_remove();
|
|
|
|
|
|
|
|
|
|
+ // Remove the handler
|
|
|
|
+ rl_callback_handler_remove();
|
|
}
|
|
}
|