Commit e7603605 authored by Leon Hiemstra's avatar Leon Hiemstra

added monitoring thread, added NA permission

parent 5967e9f1
......@@ -57,6 +57,7 @@ class RegisterMap {
uint32_t getValidAddr(const std::string name, const uint32_t offset, const uint32_t size);
bool getReadPermission(const std::string name);
bool getWritePermission(const std::string name);
void setPermission_NA(const std::string name) { reg[name].access = "NA"; }
std::vector<std::string> getRegnames(std::string prefix);
std::vector<std::string> getRegnames_full(std::string prefix);
......
......@@ -65,6 +65,24 @@ string print_termout(TermOutput& termout)
return s;
}
void monitor(void)
{
CMD Cmd;
string line;
string cmdname = "";
CMDstatus cmdstatus = {CMD_STATUS_OK, 0,0};
CMDstatus cmdstatusnew = cmdstatus;
TermOutput termout;
while(ServerRunning) {
usleep(1000000);
cmdstatusnew = Cmd.command("read /unb0/pn[0:2]/dev/system", termout, cmdname, &SD);
if(cmdstatusnew.status != CMD_EMPTY) cmdstatus = cmdstatusnew;
cout << "Monitor thread: " << print_termout(termout) << endl;
termout.clear();
}
}
void control_server(TCPSSocket *sock, const int clientId, std::atomic<size_t> *nthreads)
{
bool quit=false;
......@@ -202,6 +220,7 @@ int main (int argc, char* argv[])
std::atomic<size_t> ncthreads(0);
std::thread *control_server_thread[c_MAX_CONTROL_SERVERS];
std::thread *monitor_thread;
po::options_description desc("Allowed options");
desc.add_options()
......@@ -268,9 +287,12 @@ int main (int argc, char* argv[])
control_server_thread[c] = new std::thread(control_server, &sock, c, &ncthreads);
++ncthreads;
}
monitor_thread = new std::thread(monitor);
ua_server();
monitor_thread->join();
delete monitor_thread;
for(uint c=0; c<c_MAX_CONTROL_SERVERS; c++) { control_server_thread[c]->join(); }
for(uint c=0; c<c_MAX_CONTROL_SERVERS; c++) { delete control_server_thread[c]; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment