diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000000000000000000000000000000000..4e060b1f2b0e5dd05e99f2ae93287ff3c3cdde4a --- /dev/null +++ b/NOTICE @@ -0,0 +1,9 @@ +Citation Notice version 1.0 +This Citation Notice is part of the LOFAR software suite. +Parties that use ASTRON Software resulting in papers and/or publications are requested to +refer to the DOI(s) that correspond(s) to the version(s) of the ASTRON Software used: +<List of DOIs> +Parties that use ASTRON Software for purposes that do not result in publications (e.g. +commercial parties) are asked to inform ASTRON about their use of ASTRON Software, by +sending an email to including the DOIs mentioned above in the message. + diff --git a/README.md b/README.md index a4b3d63bb3227b7632e362df900dd86c53b96dca..e887356462283a3113359d930328482c26543484 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +If you use (part of) this software please attribute the use to ASTRON as indicated in the +file NOTICE in the root of the source code repository. + + + + # In brief: in case of missing automake/ autoconf: diff --git a/src/cmd.cpp b/src/cmd.cpp index 27bb54c9e1c1a9905596750e2f8839ba50fbbbcf..fe986963221ab66a4986f828a0c28c4c7cb38353 100644 --- a/src/cmd.cpp +++ b/src/cmd.cpp @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ #include <stdlib.h> #include <unistd.h> @@ -46,26 +61,26 @@ CMDstatus CMD::command(string line, TermOutput& termout, string& cmdname, Server pos = line.find("\r"); if (pos!=string::npos) line.erase (pos); - if(line.size()==0) return {CMD_EMPTY,0,0}; + if(line.size() == 0) return {CMD_EMPTY,0,0}; - std::vector<string> args=po::split_unix(line); - char **argv=new char* [args.size()+1]; - uint argc=args.size(); + std::vector<string> args = po::split_unix(line); + char **argv = new char* [args.size()+1]; + uint argc = args.size(); uint ai; - for(ai=0;ai<args.size();ai++) { + for(ai = 0; ai < args.size(); ai++) { argv[ai] = new char[args[ai].size()+1]; // +1: include '\0' char - strcpy(argv[ai],args[ai].c_str()); + strcpy(argv[ai], args[ai].c_str()); } argv[ai]=(char *)0; // terminate with NULL - string cmd=args[0]; - CMDstatus req_ret={CMD_STATUS_ERROR,0,0}; + string cmd = args[0]; + CMDstatus req_ret = {CMD_STATUS_ERROR,0,0}; if(!supported_cmd(cmd)) { termout.strerr << "Command not exist" << endl; } - cmdname=cmd; + cmdname = cmd; try { /* * vvvvv parse user command vvvvv @@ -84,13 +99,13 @@ CMDstatus CMD::command(string line, TermOutput& termout, string& cmdname, Server } else if(cmd == HELP) { req_ret.status=CMD_STATUS_OK; termout.strout << "Available commands:" << endl; - for(uint i=0;i<supported_cmds.size();i++) { + for(uint i=0; i < supported_cmds.size(); i++) { termout.strout << i << ". " << supported_cmds[i] << endl; } termout.strout << endl << "Server also supports '>' and '>>' and '|' operators like the Bash shell" << endl; termout.strout << endl << "Syntax help: use option -h for each command" << endl; } else if(cmd == QUIT) { - req_ret.status=CMD_REQUEST_QUIT; + req_ret.status = CMD_REQUEST_QUIT; } /* @@ -98,25 +113,25 @@ CMDstatus CMD::command(string line, TermOutput& termout, string& cmdname, Server */ string fname=""; ofstream fd; - string pipecmd=""; - char **pipeargv=NULL; - for(uint i=0;i<argc;i++) { + string pipecmd = ""; + char **pipeargv = NULL; + for(uint i=0; i < argc; i++) { if(argv[i][0] == '>') { if(argv[i][1] == '>') { // >> =append to file - if(strlen(argv[i]) > 2) fname=&argv[i][2]; // >>filename + if(strlen(argv[i]) > 2) fname = &argv[i][2]; // >>filename else { i++; - if(i<argc && strlen(argv[i]) > 1) fname=argv[i]; // >> filename + if(i<argc && strlen(argv[i]) > 1) fname = argv[i]; // >> filename } if(fname != "") { cout << "append to file: " << fname << endl; fd.open (fname, std::ofstream::out | std::ofstream::app); } } else { // > =open new file - if(strlen(argv[i]) > 1) fname=&argv[i][1]; // >filename + if(strlen(argv[i]) > 1) fname = &argv[i][1]; // >filename else { i++; - if(i<argc && strlen(argv[i]) > 1) fname=argv[i]; // > filename + if(i<argc && strlen(argv[i]) > 1) fname = argv[i]; // > filename } if(fname != "") { cout << "new file: " << fname << endl; @@ -126,22 +141,22 @@ CMDstatus CMD::command(string line, TermOutput& termout, string& cmdname, Server if(!fd) throw runtime_error("Cannot open file: \""+fname+"\""); break; } else if(argv[i][0] == '|') { - if(strlen(argv[i]) > 1) pipecmd=&argv[i][1]; // |command + if(strlen(argv[i]) > 1) pipecmd = &argv[i][1]; // |command else { i++; - if(i<argc && strlen(argv[i]) > 1) pipecmd=argv[i]; // | command + if(i<argc && strlen(argv[i]) > 1) pipecmd = argv[i]; // | command } // pass all args on this line to the pipecmd - pipeargv=new char* [argc-i+1]; + pipeargv = new char* [argc-i+1]; pipeargv[0] = new char[pipecmd.size()+1]; - strcpy(pipeargv[0],pipecmd.c_str()); + strcpy(pipeargv[0], pipecmd.c_str()); int pai=1; - for(uint j=i+1;j<argc;j++) { + for(uint j=i+1; j< argc; j++) { pipeargv[pai] = new char[strlen(argv[j])+1]; - strcpy(pipeargv[pai],argv[j]); + strcpy(pipeargv[pai], argv[j]); pai++; } - pipeargv[pai]=(char *)0; + pipeargv[pai] = (char *)0; break; } } @@ -152,18 +167,18 @@ CMDstatus CMD::command(string line, TermOutput& termout, string& cmdname, Server } else if(pipecmd != "") { // in case of a given: |shell command ostringstream strs_filter; // pass stream strout to system command and replace strout with output of system command: - strs_filter << exec_system_cmd_rw(termout.strout.str(),pipecmd.c_str(),pipeargv); + strs_filter << exec_system_cmd_rw(termout.strout.str(), pipecmd.c_str(), pipeargv); termout.strout.str(""); termout.strout.clear(); termout.strout << strs_filter.str(); - for(int i=0;(pipeargv[i]!=(char *)0);i++) delete[] pipeargv[i]; + for(int i=0; (pipeargv[i] != (char *)0); i++) delete[] pipeargv[i]; delete[] pipeargv; } } catch(exception& e) { termout.strerr << "Error: " << e.what() << endl; } - for(int i=0;i<(argv[i]!=(char *)0);i++) delete[] argv[i]; + for(int i=0; i<(argv[i]!=(char *)0); i++) delete[] argv[i]; delete[] argv; return req_ret; @@ -176,7 +191,7 @@ CMDstatus CMD::command(string line, TermOutput& termout, string& cmdname, Server ***********************/ CMDstatus CMD::Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd) { - CMDstatus ret={CMD_STATUS_ERROR,0,0}; + CMDstatus ret = {CMD_STATUS_ERROR,0,0}; std::vector<int> nodes; po::options_description generic("Uniboard register info"); @@ -205,7 +220,7 @@ CMDstatus CMD::Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd) po::notify(vm); if (vm.count("help")) { - termout.strout << "Usage: " << INFO << " [options] /unb..." << endl + termout.strout << "Usage: " << INFO << " [options] /unb..." << endl << "Options: " << generic << endl << "Example: ls /unb0/pn3" << endl; return {CMD_STATUS_OK,0,0}; @@ -215,7 +230,7 @@ CMDstatus CMD::Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd) return {CMD_STATUS_OK,0,0}; } if (vm.count("file")) { - string filename=vm["file"].as<string>(); + string filename = vm["file"].as<string>(); nodes = sd->unb->path_to_node(filename); } @@ -230,7 +245,7 @@ CMDstatus CMD::Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd) termout.strout << m << endl; } } - ret.status=CMD_STATUS_OK; + ret.status = CMD_STATUS_OK; } catch(po::error& e) { termout.strerr << e.what() << endl; } catch(std::exception& e) { @@ -241,7 +256,7 @@ CMDstatus CMD::Info(int argc, char* argv[], TermOutput& termout, Serverdat *sd) CMDstatus CMD::Mread(int argc, char* argv[], TermOutput& termout, Serverdat *sd) { - CMDstatus ret={CMD_STATUS_ERROR,0,0}; + CMDstatus ret = {CMD_STATUS_ERROR,0,0}; po::options_description generic("Generic read"); generic.add_options() @@ -270,20 +285,20 @@ CMDstatus CMD::Mread(int argc, char* argv[], TermOutput& termout, Serverdat *sd) po::notify(vm); if (vm.count("help")) { - termout.strout << "usage: " << MREAD << " [options] file(s)" << endl + termout.strout << "usage: " << MREAD << " [options] file(s)" << endl << "Options: " << generic << endl << "Example 1: read --nvalues=1 /unb0/pn3/mm/ppsh/ppsh/status" << endl << "Example 2: read /unb[0:10,15]/pn[0:3]/mm/ppsh/ppsh/status" << endl << "Example 3: read /unb0/pn[3]/dev/name" << endl; return {CMD_STATUS_OK,0,0}; } else if (vm.count("file")) { - string addr_str=""; - uint offs=0; - int nvalues=-1; - if(vm.count("file")) { addr_str=vm["file"].as<string>(); } - if(vm.count("offs")) { offs=vm["offs"].as<uint>(); } - if(vm.count("nvalues")) { nvalues=vm["nvalues"].as<int>(); } - if(sd->unb->read(termout,addr_str,offs,nvalues)) ret.status=CMD_STATUS_OK; + string addr_str = ""; + uint offs = 0; + int nvalues = -1; + if(vm.count("file")) { addr_str = vm["file"].as<string>(); } + if(vm.count("offs")) { offs = vm["offs"].as<uint>(); } + if(vm.count("nvalues")) { nvalues = vm["nvalues"].as<int>(); } + if(sd->unb->read(termout, addr_str, offs,nvalues)) ret.status = CMD_STATUS_OK; } else throw runtime_error("missing argument(s)"); } catch(po::error& e) { @@ -296,7 +311,7 @@ CMDstatus CMD::Mread(int argc, char* argv[], TermOutput& termout, Serverdat *sd) CMDstatus CMD::Mwrite(int argc, char* argv[], TermOutput& termout, Serverdat *sd) { - CMDstatus ret={CMD_STATUS_ERROR,0,0}; + CMDstatus ret = {CMD_STATUS_ERROR,0,0}; po::options_description generic("Memory mapped write"); generic.add_options() @@ -325,23 +340,23 @@ CMDstatus CMD::Mwrite(int argc, char* argv[], TermOutput& termout, Serverdat *sd po::notify(vm); if (vm.count("help")) { - termout.strout << "usage: " << MWRITE << " [options] file(s)" << endl + termout.strout << "usage: " << MWRITE << " [options] file(s)" << endl << "Options: " << generic << endl << "Example: mwrite --offs=1 --data=[1,2,3,4] /unb0/pn3/mm/sens/sens/temp_high" << endl; return {CMD_STATUS_OK,0,0}; } else if (vm.count("file")) { - string addr_str=""; - uint offs=0; + string addr_str = ""; + uint offs = 0; std::vector<int64_t> data64; std::vector<int> data; - if(vm.count("file")) { addr_str=vm["file"].as<string>(); } - if(vm.count("offs")) { offs=vm["offs"].as<uint>(); } + if(vm.count("file")) { addr_str = vm["file"].as<string>(); } + if(vm.count("offs")) { offs = vm["offs"].as<uint>(); } if(vm.count("data")) { - string datastr=vm["data"].as<string>(); + string datastr = vm["data"].as<string>(); istringstream vecstr(datastr); - data64=parse_int64_vector_range(vecstr); + data64 = parse_int64_vector_range(vecstr); data.resize(data64.size()); - for(uint i=0;i<data64.size();i++) { + for(uint i=0; i<data64.size(); i++) { if((data64[i] & 0xffffffff00000000) != 0) { cout << "cmd() mwrite() warning 64bit value detected, truncating!!!" << endl; termout.strerr << "cmd() mwrite() warning 64bit value detected, truncating!!!" << endl; @@ -349,7 +364,7 @@ CMDstatus CMD::Mwrite(int argc, char* argv[], TermOutput& termout, Serverdat *sd data[i]=(int)data64[i]; } } - if(sd->unb->mwrite(termout,addr_str,offs,data)) ret.status=CMD_STATUS_OK; + if(sd->unb->mwrite(termout, addr_str, offs, data)) ret.status=CMD_STATUS_OK; } else throw runtime_error("missing argument(s)"); } catch(po::error& e) { termout.strerr << e.what() << endl; @@ -369,7 +384,7 @@ CMDstatus CMD::Mwrite(int argc, char* argv[], TermOutput& termout, Serverdat *sd bool CMD::supported_cmd(std::string cmd) { for(auto supported : supported_cmds) { - if(cmd==supported) return true; + if(cmd == supported) return true; } return false; } @@ -406,7 +421,7 @@ string CMD::exec_system_cmd_rw(const string input, const char* cmd, char *const close(pipe_stdout_fd[PIPE_WRITE]); // run cmd now - execvp(cmd,argv); + execvp(cmd, argv); // should not come here exit(1); } else { // parent diff --git a/src/cmd.h b/src/cmd.h index d6a58cb36549c08be47642cb517f6ba3b7f5ac17..2b06b0d9c12e743ded6521265a86c177ab7cf761 100644 --- a/src/cmd.h +++ b/src/cmd.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef CMD_H #define CMD_H 1 @@ -15,6 +31,7 @@ #define CMD_EMPTY -2 #define CMD_REQUEST_BINARY 2 #define CMD_REQUEST_QUIT 3 + typedef struct { int status; uint extra__blocksize; diff --git a/src/common.cpp b/src/common.cpp index 2a1a936188decd614549de87a631a44b9ff9aa41..8fb9110990f3b6320a9c972eda94704516f31167 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef _REENTRANT #error ACK! You need to compile with _REENTRANT defined since this uses threads #endif @@ -31,7 +47,7 @@ using namespace std; Common::Common(list<class Node*>& nodelist) { - NODE=nodelist; + NODE = nodelist; } Common::~Common() @@ -55,7 +71,8 @@ void Common::print_node_id(ostringstream& strs, Node *node) std::string Common::string_node_id(int node) { auto n = select_node(node); - return "/unb" + to_string(n->GetUniboardNr()) + "/" + n->GetType() + to_string(n->GetLocalNr()) + "/"; + return "/unb" + to_string(n->GetUniboardNr()) + "/" + n->GetType() + + to_string(n->GetLocalNr()) + "/"; } std::vector<int> Common::get_nodes(void) @@ -69,8 +86,8 @@ std::vector<int> Common::get_nodes(void) bool Common::get_system_info(TermOutput& termout, std::vector<int> nodes, const string what) { - bool retval=false; - uint retcnt=0; + bool retval = false; + uint retcnt = 0; for(auto n : nodes) { auto node = select_node(n); @@ -94,25 +111,24 @@ bool Common::read(TermOutput& termout, const string addr, const uint offs, const std::vector<int> nodes = path_to_node(addr); std::string relative_addr = addr_to_relative_addr(addr); - std::string type = addr_to_type(addr); - std::string peripheral = addr_to_peripheral(addr); + std::string type = addr_to_type(addr); + std::string peripheral = addr_to_peripheral(addr); for(uint idx=0;idx<nodes.size();idx++) { auto node = select_node(nodes[idx]); print_node_id(termout.strout,node); - if(idx>0) termout.strout << ","; - //termout.strout << "[" << node->GetGlobalNr() << "],"; + if(idx > 0) termout.strout << ","; termout.strout << "["; if(type == "mm") { RegisterMap *regmap = node->get_RegisterMap(termout.strout); - uint32_t nvalues = (len<0 ? (regmap->getSpan(relative_addr) / 4) : len); + uint32_t nvalues = (len<0 ? (regmap->getSpan(relative_addr) / sizeof(uint32_t)) : len); std::vector<int> datavec; - if(node->mread(termout.strout,relative_addr,offs,datavec,nvalues)) { + if(node->mread(termout.strout, relative_addr, offs, datavec, nvalues)) { retcnt++; } } else if(type == "dev") { - if(node->get_system_info(termout.strout,peripheral)) { + if(node->get_system_info(termout.strout, peripheral)) { retcnt++; } else { termout.strerr << "no such peripheral: " << peripheral; @@ -129,25 +145,25 @@ bool Common::read(TermOutput& termout, const string addr, const uint offs, const bool Common::mwrite(TermOutput& termout, const string addr, const uint offs, const std::vector<int>& data) { - bool retval=false; - uint retcnt=0; + bool retval = false; + uint retcnt = 0; std::vector<int> nodes; - for(uint idx=0;idx<nodes.size();idx++) { + for(uint idx = 0; idx<nodes.size(); idx++) { auto node = select_node(nodes[idx]); - print_node_id(termout.strout,node); + print_node_id(termout.strout, node); - if(idx>0) termout.strout << ","; + if(idx > 0) termout.strout << ","; termout.strout << "[" << node->GetGlobalNr() << "],"; termout.strout << "["; - for(uint i=0;i<data.size();i++) { - if(i>0) termout.strout << ","; + for(uint i = 0; i < data.size(); i++) { + if(i > 0) termout.strout << ","; termout.strout << data[i]; } termout.strout << "]"; - if(node->mwrite(termout.strout,addr,offs,data)) retcnt++; + if(node->mwrite(termout.strout,addr, offs, data)) retcnt++; } retval = (retcnt==nodes.size()); return retval; @@ -166,14 +182,9 @@ std::vector<int> Common::unb_pn__to__nodes(std::vector<int> unbs, std::vector<in std::vector<int> nodes; for(auto unb : unbs) { for(auto pn : pns) { - nodes.push_back(pn+(4*unb)); + nodes.push_back(pn + (c_NOF_PN_on_UNB * unb)); } } -// cout << "unb_pn__to__nodes:"; -// for(auto n : nodes) { -// cout << n << " "; -// } -// cout << endl; return nodes; } @@ -192,34 +203,29 @@ uint Common::ipaddr_to_id(const string ipaddr) */ uint8_t node = (uint8_t)(ip&0xf)-1; uint8_t unb = (uint8_t)(ip>>8); // unb number is stored in 2nd least significant tuble - return (unb*8+node); + return (unb*8 + node); } std::vector<int> Common::unb_name_to_number(const std::string unb_name) { std::vector<int> unbs; - cout << "Common::unb_name_to_number: unb_name=" << unb_name << endl; + //cout << "Common::unb_name_to_number: unb_name=" << unb_name << endl; - if(unb_name.length() >= 4) { + if(unb_name.length() > strlen("unb")) { if(unb_name[0] == 'u' && unb_name[1] == 'n' && unb_name[2] == 'b') { std::string unb_range = unb_name.substr(3); - cout << "unb_range=" << unb_range << endl; + try { - unbs.push_back(std::stoi(unb_range,nullptr)); + unbs.push_back(std::stoi(unb_range, nullptr)); } catch (const std::invalid_argument& ia) { - cerr << "Common::unb_name_to_number: Invalid argument: " << ia.what() << " - but trying vector..." << endl; + cerr << "Common::unb_name_to_number: Invalid argument: " + << ia.what() << " - but trying vector..." << endl; istringstream vecstr(unb_range); unbs=parse_int_vector_range(vecstr); } } } - -// cout << "Common::unb_name_to_number: found unb:" << endl; -// for(auto u : unbs) { -// cout << u << " ";; -// } -// cout << endl; return unbs; } @@ -227,56 +233,55 @@ std::vector<int> Common::pn_name_to_number(const std::string pn_name) { std::vector<int> pns; - if(pn_name.length() >= 3) { + if(pn_name.length() > strlen("pn")) { if(pn_name[0] == 'p' && pn_name[1] == 'n') { std::string pn_range = pn_name.substr(2); - cout << "pn_range=" << pn_range << endl; try { pns.push_back(std::stoi(pn_range,nullptr)); } catch (const std::invalid_argument& ia) { - cerr << "Common::pn_name_to_number: Invalid argument: " << ia.what() << " - but trying vector..." << endl; + cerr << "Common::pn_name_to_number: Invalid argument: " + << ia.what() << " - but trying vector..." << endl; istringstream vecstr(pn_range); pns=parse_int_vector_range(vecstr); } } } -// cout << "Common::pn_name_to_number: found pns:" << endl; -// for(auto p : pns) { -// cout << p << " ";; -// } -// cout << endl; return pns; } +// "/unb0/pn3/mm/addr" +// 0 1 2 3 4 +#define c_PATH_root 0 +#define c_PATH_unb 1 +#define c_PATH_pn 2 +#define c_PATH_type 3 +#define c_PATH_addr 4 + std::vector<int> Common::path_to_node(std::string path_str) { std::vector<int> nodes; std::stringstream ss(path_str); std::string token; std::vector<std::string> tokens; + while (std::getline(ss, token, '/')) { tokens.push_back(token); } - if(tokens.size() >= 3) { - if(tokens[0] == "") { + if(tokens.size() > c_PATH_pn) { + if(tokens[c_PATH_root] == "") { // ok, is absolute path starting with '/' - std::vector<int> unb = unb_name_to_number(tokens[1]); - std::vector<int> pn = pn_name_to_number(tokens[2]); + std::vector<int> unb = unb_name_to_number(tokens[c_PATH_unb]); + std::vector<int> pn = pn_name_to_number(tokens[c_PATH_pn]); for(auto u : unb) { for(auto p : pn) { if(u>=0 && p>=0) { - nodes.push_back(p+(4*u)); + nodes.push_back(p + (c_NOF_PN_on_UNB * u)); } } } } } -// cout << "Common::path_to_node: found nodes:" << endl; -// for(auto n : nodes) { -// cout << n << " ";; -// } -// cout << endl; return nodes; } @@ -291,11 +296,8 @@ std::string Common::addr_to_relative_addr(std::string addr) tokens.push_back(token); } - // "/unb0/pn3/mm/addr" - // 0 1 2 3 4 - - for(uint i=3;i<tokens.size();i++) { - if(i>3) rel_addr += "/"; + for(uint i=c_PATH_type; i < tokens.size(); i++) { + if(i>c_PATH_type) rel_addr += "/"; rel_addr += tokens[i]; } return rel_addr; @@ -312,11 +314,8 @@ std::string Common::addr_to_type(std::string addr) tokens.push_back(token); } - // "/unb0/pn3/dev/peripheral" - // 0 1 2 3 4 - - if(tokens.size() >= 4) { - type = tokens[3]; + if(tokens.size() > c_PATH_type) { + type = tokens[c_PATH_type]; } return type; } @@ -332,11 +331,8 @@ std::string Common::addr_to_peripheral(std::string addr) tokens.push_back(token); } - // "/unb0/pn3/dev/peripheral" - // 0 1 2 3 4 - - if(tokens.size() >= 5) { - peripheral = tokens[4]; + if(tokens.size() > c_PATH_addr) { + peripheral = tokens[c_PATH_addr]; } return peripheral; } diff --git a/src/common.h b/src/common.h index 72e8984c608109f0e66cc32b34b54eb00aeb0353..43665224f79cc76e2ceb4360ff75ac007b10ef85 100644 --- a/src/common.h +++ b/src/common.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef COMMON_H #define COMMON_H 1 @@ -15,6 +31,7 @@ namespace ublas = boost::numeric::ublas; +#define c_NOF_PN_on_UNB 4 class Common { @@ -53,8 +70,6 @@ public: std::string addr_to_relative_addr(std::string addr); std::string addr_to_peripheral(std::string addr); std::string addr_to_type(std::string addr); - - }; #endif diff --git a/src/io/tcpsocket.cpp b/src/io/tcpsocket.cpp index 7dcb98c5b956753336fe21a37668487293c9dffe..a1966b19e3cc5e94690f69df08f1c00840f2f909 100644 --- a/src/io/tcpsocket.cpp +++ b/src/io/tcpsocket.cpp @@ -1,7 +1,18 @@ -// -// Copyright (c) 2009 G.W. Kant, Astron, The Netherlands -// E. van der Wal, Astron, The Netherlands -// +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ #include <unistd.h> #include <stdlib.h> @@ -26,39 +37,28 @@ */ TCPSSocket::TCPSSocket(uint16_t p, const char* iface, int maxservers) throw(const char *) { - port = p; - MaxServers = maxservers; - sock = socket(PF_INET, SOCK_STREAM, 0); - if (sock < 0) - throw "TCPSSocket: socket creation error"; - int val = 1; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - &val, sizeof(val)) < 0) { - close(sock); - cerr << "Error: " << strerror(errno) << endl; - throw "TCPSSocket: cannot set socket option SO_REUSEADDR"; - } - -// this requires root permission: -// if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, -// (void*) iface, strlen(iface)) < 0) { -// close(sock); - // cerr << "Error: " << strerror(errno) << endl; -// -// throw "TCPSSocket: cannot set socket option SO_BINDTODEVICE"; -// } - - /* Give the socket a name. */ - name.sin_family = AF_INET; - name.sin_port = htons (port); - name.sin_addr.s_addr = htonl (INADDR_ANY); - - if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) { - close(sock); - cerr << "Error: " << strerror(errno) << endl; - throw "TCPSSocket: cannot bind socket"; - } + port = p; + MaxServers = maxservers; + sock = socket(PF_INET, SOCK_STREAM, 0); + if (sock < 0) + throw "TCPSSocket: socket creation error"; + int val = 1; + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { + close(sock); + cerr << "Error: " << strerror(errno) << endl; + throw "TCPSSocket: cannot set socket option SO_REUSEADDR"; + } + /* Give the socket a name. */ + name.sin_family = AF_INET; + name.sin_port = htons (port); + name.sin_addr.s_addr = htonl (INADDR_ANY); + + if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) { + close(sock); + cerr << "Error: " << strerror(errno) << endl; + throw "TCPSSocket: cannot bind socket"; + } } TCPSSocket::~TCPSSocket() @@ -68,74 +68,32 @@ TCPSSocket::~TCPSSocket() int TCPSSocket::listen(void) throw(const char *) { -#define USE_NO_FORK - -#ifdef USE_NO_FORK - ostringstream strs; -#else - int Servers=1, status; -#endif - syslog(LOG_INFO,"Listening to tcp port %d\n",port); - if (::listen (sock, 1) < 0) - throw "TCPSSocket::listen: cannot put socket into listening state"; - -#ifdef USE_NO_FORK - /* Block until input arrives on the server socket. */ - int nsock; - struct sockaddr_in clientname; - socklen_t size = sizeof (clientname); - - nsock = accept (sock,(struct sockaddr *) &clientname,&size); - if (nsock < 0) { - cerr << "Error TCPSSocket::listen() accept(): " << strerror(errno) << endl; - exit(-1); - } + ostringstream strs; + syslog(LOG_INFO,"Listening to tcp port %d\n",port); + if (::listen (sock, 1) < 0) + throw "TCPSSocket::listen: cannot put socket into listening state"; + + /* Block until input arrives on the server socket. */ + int nsock; + struct sockaddr_in clientname; + socklen_t size = sizeof (clientname); + + nsock = accept (sock,(struct sockaddr *) &clientname,&size); + if (nsock < 0) { + cerr << "Error TCPSSocket::listen() accept(): " << strerror(errno) << endl; + exit(-1); + } + + struct hostent *he; + he = gethostbyaddr(&clientname.sin_addr, sizeof clientname.sin_addr, AF_INET); + + strs << "Server: Client connect from host " + << (he ? he->h_name : inet_ntoa (clientname.sin_addr)) << " (" << inet_ntoa (clientname.sin_addr) + << "):" << ntohs(clientname.sin_port) << endl; - struct hostent *he; - he = gethostbyaddr(&clientname.sin_addr, sizeof clientname.sin_addr, AF_INET); - - strs << "Server: Client connect from host " - << (he ? he->h_name : inet_ntoa (clientname.sin_addr)) << " (" << inet_ntoa (clientname.sin_addr) - << "):" << ntohs(clientname.sin_port) << endl; - - syslog(LOG_INFO,strs.str().c_str()); - - return nsock; -#else - while (1) { - /* Block until input arrives on the server socket. */ - int nsock; - struct sockaddr_in clientname; - socklen_t size = sizeof (clientname); - - pid_t pid = fork(); - if (pid < 0) - throw "TCPSSocket::listen: cannot fork a child process"; - else if (pid) { // We are the parent - ++Servers; - cerr << "Child " << pid << endl; - if (Servers>MaxServers) { - cerr << "Maximum number of servers (" << MaxServers << ") reached" << endl; - int cpid = wait(&status); - cerr << "Child " << cpid << " terminated" << endl; - --Servers; - } - } - else { // We are child - nsock = accept (sock, - (struct sockaddr *) &clientname, - &size); - if (nsock < 0) - exit(-1); - - cerr << "Server: Client connect from host " - << inet_ntoa (clientname.sin_addr) - << ":" << ntohs (clientname.sin_port) - << endl; - return nsock; - } - } -#endif + syslog(LOG_INFO,strs.str().c_str()); + + return nsock; } TCPCSSocket::TCPCSSocket(int s) @@ -155,28 +113,28 @@ size_t TCPCSSocket::rx(unsigned char *buf, size_t len) throw(const char*) number of actual received bytes */ { - size_t nrx = 0; - ssize_t ret; - do { - fd_set readfds; - FD_ZERO(&readfds); - FD_SET(sock, &readfds); - // No time out - if(select(sock + 1, &readfds, NULL, NULL, NULL) == -1) { - throw "TCPCSSocket::rx: select error"; - } - if FD_ISSET(sock, &readfds) { - ret = recvfrom(sock, buf, len, 0, NULL, NULL); - if(ret == -1) { - throw "TCPCSSocket::rx(): recvfrom=-1 error"; - } else if(ret == 0) { - throw "TCPCSSocket::rx(): recvfrom=0 peer orderly shutdown"; + size_t nrx = 0; + ssize_t ret; + do { + fd_set readfds; + FD_ZERO(&readfds); + FD_SET(sock, &readfds); + // No time out + if(select(sock + 1, &readfds, NULL, NULL, NULL) == -1) { + throw "TCPCSSocket::rx: select error"; } - nrx += ret; - break; - } - } while (1); - return nrx; + if FD_ISSET(sock, &readfds) { + ret = recvfrom(sock, buf, len, 0, NULL, NULL); + if(ret == -1) { + throw "TCPCSSocket::rx(): recvfrom=-1 error"; + } else if(ret == 0) { + throw "TCPCSSocket::rx(): recvfrom=0 peer orderly shutdown"; + } + nrx += ret; + break; + } + } while (1); + return nrx; } size_t TCPCSSocket::_rx(unsigned char *buf, size_t len) throw(const char*) @@ -184,41 +142,41 @@ size_t TCPCSSocket::_rx(unsigned char *buf, size_t len) throw(const char*) Receive len bytes from a TCP socket */ { - size_t nrx = 0; - ssize_t ret; - //struct timeval timeout; - //timeout.tv_sec = timeoutms / 1000; - //timeout.tv_usec = ( timeoutms % 1000 ) * 1000; - - // Receive a datagram from a tx source - do { - fd_set readfds; - FD_ZERO(&readfds); - FD_SET(sock, &readfds); - // No time out - if(select(sock + 1, &readfds, NULL, NULL, NULL) == -1) { - throw "TCPCSSocket::_rx: select error"; - } - if FD_ISSET(sock, &readfds) { - ret = recvfrom(sock, &buf[nrx], len-nrx, 0, NULL, NULL); - if(ret == -1) { - throw "TCPCSSocket::_rx(): recvfrom=-1 error"; - } else if(ret == 0) { - throw "TCPCSSocket::_rx(): recvfrom=0 peer orderly shutdown"; + size_t nrx = 0; + ssize_t ret; + //struct timeval timeout; + //timeout.tv_sec = timeoutms / 1000; + //timeout.tv_usec = ( timeoutms % 1000 ) * 1000; + + // Receive a datagram from a tx source + do { + fd_set readfds; + FD_ZERO(&readfds); + FD_SET(sock, &readfds); + // No time out + if(select(sock + 1, &readfds, NULL, NULL, NULL) == -1) { + throw "TCPCSSocket::_rx: select error"; } - nrx += ret; - } - if (nrx==len) - break; - } while (1); - return nrx; + if FD_ISSET(sock, &readfds) { + ret = recvfrom(sock, &buf[nrx], len-nrx, 0, NULL, NULL); + if(ret == -1) { + throw "TCPCSSocket::_rx(): recvfrom=-1 error"; + } else if(ret == 0) { + throw "TCPCSSocket::_rx(): recvfrom=0 peer orderly shutdown"; + } + nrx += ret; + } + if (nrx==len) + break; + } while (1); + return nrx; } size_t TCPCSSocket::tx(const unsigned char* mes, size_t len) throw(const char*) { - int ntxbytes = write(sock, mes, len); - if (ntxbytes < 0) - throw "TCPCSSocket::tx(): could not send message"; - return ntxbytes; + int ntxbytes = write(sock, mes, len); + if (ntxbytes < 0) + throw "TCPCSSocket::tx(): could not send message"; + return ntxbytes; } diff --git a/src/io/tcpsocket.h b/src/io/tcpsocket.h index cdd621b1f60cd21a9914f5e5804364d79978b92e..b493d424ab624bfaebbe241b9f921be1e77276df 100644 --- a/src/io/tcpsocket.h +++ b/src/io/tcpsocket.h @@ -1,11 +1,21 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef TCPSOCKET_H #define TCPSOCKET_H -// -// $Id$ -// -// Copyright (c) 2009 G.W. Kant, Astron, The Netherlands -// E. van der Wal, Astron, The Netherlands -// #include <sys/socket.h> #include <stdio.h> diff --git a/src/io/udpsocket.cpp b/src/io/udpsocket.cpp index bca86db42b5440b71c43ab8674049d53ca2b4914..cd1c577f3843a8eeb7daf4d98fbb399c2adba506 100644 --- a/src/io/udpsocket.cpp +++ b/src/io/udpsocket.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> diff --git a/src/io/udpsocket.h b/src/io/udpsocket.h index 40fb2b2c3cb7dc3b801bc0f323127dba6757d6d2..f4bc647a968c7fd5a37399efb1e927a7a7fffaea 100644 --- a/src/io/udpsocket.h +++ b/src/io/udpsocket.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef __UDPSOCKET_H__ #define __UDPSOCKET_H__ diff --git a/src/io/unbos.cpp b/src/io/unbos.cpp index 2d5f25ec400f37ef3f1beda0c07af6339492e9f1..7d860700107f61d3b3a7120b55ea12a43c0f1ccf 100644 --- a/src/io/unbos.cpp +++ b/src/io/unbos.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef _REENTRANT #error ACK! You need to compile with _REENTRANT defined since this uses threads #endif @@ -135,7 +151,7 @@ bool UNBos::TransmitWrite(const uint32_t opcode, const uint32_t addr, const uint unb->hdr.opcode = opcode; unb->hdr.nvalues = nvalues; unb->hdr.addr = addr; - memcpy(unb->data,buf,nvalues*sizeof(uint32_t)); + memcpy(unb->data, buf, nvalues*sizeof(uint32_t)); //print_cmd_packet(pkt, pktlength); size_t retval = commdev->tx(pkt, pktlength); @@ -202,17 +218,17 @@ void UNBos::print_cmd_packet(const uint8_t *pkt, const int len) { printf("\x1b[31;1mUNBos::print_cmd_packet\x1b[0m\n"); UnbosCmdPacket *pkt_ptr=(UnbosCmdPacket *)pkt; - printf("hdr.psn=%d ",pkt_ptr->hdr.psn); - printf("hdr.opcode=%d ",pkt_ptr->hdr.opcode); - printf("hdr.nvalues=%d ",pkt_ptr->hdr.nvalues); - printf("hdr.addr=%d\n",pkt_ptr->hdr.addr); + printf("hdr.psn=%d ", pkt_ptr->hdr.psn); + printf("hdr.opcode=%d ", pkt_ptr->hdr.opcode); + printf("hdr.nvalues=%d ", pkt_ptr->hdr.nvalues); + printf("hdr.addr=%d\n", pkt_ptr->hdr.addr); const uint8_t *bufptr=pkt; printf(" "); for(int i=0;i<16;i++) printf("%2x ",i); for(int i=0;i<len;i++) { if ((i%16)==0) printf("\n%02x: ",i); - printf("%02x ",bufptr[i]); + printf("%02x ", bufptr[i]); } printf("\n"); } @@ -220,16 +236,16 @@ void UNBos::print_cmd_packet(const uint8_t *pkt, const int len) void UNBos::print_reply_packet(const uint8_t *pkt, const int len) { printf("\x1b[32;1mUNBos::print_reply_packet\x1b[0m\n"); - UnbosReadAckPacket *pkt_ptr=(UnbosReadAckPacket *)pkt; - printf("hdr.psn=%d ",pkt_ptr->hdr.psn); - printf("hdr.addr=%d\n",pkt_ptr->hdr.addr); + UnbosReadAckPacket *pkt_ptr = (UnbosReadAckPacket *)pkt; + printf("hdr.psn=%d ", pkt_ptr->hdr.psn); + printf("hdr.addr=%d\n", pkt_ptr->hdr.addr); - const uint8_t *bufptr=pkt; + const uint8_t *bufptr = pkt; printf(" "); - for(int i=0;i<16;i++) printf("%2x ",i); - for(int i=0;i<len;i++) { + for(int i=0; i<16; i++) printf("%2x ",i); + for(int i=0; i<len; i++) { if ((i%16)==0) printf("\n%02x: ",i); - printf("%02x ",bufptr[i]); + printf("%02x ", bufptr[i]); } printf("\n"); } @@ -237,12 +253,12 @@ void UNBos::print_reply_packet(const uint8_t *pkt, const int len) bool UNBos::readRegister(uint32_t addr, uint32_t nvalues, uint32_t *data_ptr) { if(data_ptr==NULL) throw runtime_error("UNBos::readRegister data_ptr=NULL"); - return Read(UNBOS_OPCODE_MEMORY_READ,addr,nvalues,data_ptr); + return Read(UNBOS_OPCODE_MEMORY_READ, addr, nvalues, data_ptr); } bool UNBos::writeRegister(uint32_t addr, uint32_t nvalues, const uint32_t *data_ptr) { if(data_ptr==NULL) throw runtime_error("UNBos::writeRegister data_ptr=NULL"); - return Write(UNBOS_OPCODE_MEMORY_WRITE,addr,nvalues,data_ptr); + return Write(UNBOS_OPCODE_MEMORY_WRITE, addr, nvalues, data_ptr); } diff --git a/src/io/unbos.h b/src/io/unbos.h index 5671342e5cf39f7eb8cd20b66bc3e22ef3d2046a..107154e54a6f8e85ec2be11668773cd4c0d1e2a9 100644 --- a/src/io/unbos.h +++ b/src/io/unbos.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef __UNBOS_H__ #define __UNBOS_H__ diff --git a/src/map.cpp b/src/map.cpp index b6c267a415e9f02bdb407f21145be82d00d35a7a..f58a1117e55f1c87f0c0e4ba3da081586e915642 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #include <iostream> #include <sstream> #include <iomanip> diff --git a/src/map.h b/src/map.h index fefb585a076c7557ceab1d238c95f7aae5a8ee34..7ce3af8dbdc01f6b0e2617cd220819c3fbc2aae2 100644 --- a/src/map.h +++ b/src/map.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef UNIBOARD_MAP_H #define UNIBOARD_MAP_H 1 diff --git a/src/node.cpp b/src/node.cpp index f6ac6a739a23c1796dc96e4212ff1baf8c93856c..c8cd7bb2b689fae647552d4d36cdb8a9c0330524 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef _REENTRANT #error ACK! You need to compile with _REENTRANT defined since this uses threads #endif @@ -26,14 +42,12 @@ using namespace std; extern int debug; Node::Node(const string ipaddr, const uint unb, const uint localnr, const std::string type, - const string firmware) - : unbos(ipaddr) + const string firmware) : unbos(ipaddr) { - myIPaddr=ipaddr; - + myIPaddr = ipaddr; periph_system = new Periph_system(unbos, firmware); - myFirmware=periph_system->read_design_name(); + myFirmware = periph_system->read_design_name(); if(myFirmware != firmware) { cerr << "Warning: Node configuration mismatch!! (read_design_name=" << myFirmware << ", config=" << firmware << ")" << endl; @@ -41,14 +55,14 @@ Node::Node(const string ipaddr, const uint unb, const uint localnr, const std::s myFirmware.c_str(),firmware.c_str()); } - UniboardNr=unb; - LocalNr=localnr; - GlobalNr=localnr+4*unb; + UniboardNr = unb; + LocalNr = localnr; + GlobalNr = localnr + 4*unb; if(type!="pn") throw runtime_error("invalid node type: \"" + type + "\""); Type=type; syslog(LOG_INFO,"Uniboard=%d New node IP=%s type=%s localnr=%d globalnr=%d\n", - UniboardNr,myIPaddr.c_str(),Type.c_str(),LocalNr,GlobalNr); + UniboardNr, myIPaddr.c_str(), Type.c_str(), LocalNr, GlobalNr); } Node::~Node() @@ -57,17 +71,17 @@ Node::~Node() } bool Node::get_system_info(ostringstream& strs,const string what) { - if(what=="system") { + if(what == "system") { return periph_system->read_system_info(strs); - } else if(what=="name") { - strs << "read_design_name:" << periph_system->read_design_name(); // << endl; + } else if(what == "name") { + strs << "read_design_name:" << periph_system->read_design_name(); return true; - } else if(what=="stamps") { + } else if(what == "stamps") { return periph_system->read_stamps(strs); - } else if(what=="note") { - strs << "read_design_note:" << periph_system->read_design_note(); // << endl; + } else if(what == "note") { + strs << "read_design_note:" << periph_system->read_design_note(); return true; - } else if(what=="sensors") { + } else if(what == "sensors") { return periph_system->read_unb_sensors(strs,LocalNr); } else return false; @@ -81,10 +95,10 @@ RegisterMap * Node::get_RegisterMap(std::ostringstream& strs) bool Node::mread(std::ostringstream& strs,const std::string addr, const uint offs, std::vector<int>& data, const uint len) { - return periph_system->mread(strs,addr,offs,data,len); + return periph_system->mread(strs, addr, offs, data, len); } bool Node::mwrite(std::ostringstream& strs,const std::string addr, const uint offs, const std::vector<int>& data) { - return periph_system->mwrite(strs,addr,offs,data); + return periph_system->mwrite(strs, addr, offs, data); } diff --git a/src/node.h b/src/node.h index c7a376c674fbcbe90a8b0b7c63c77296b6d944af..a60d18ea9d00f4757243fbb80f189b5296226d46 100644 --- a/src/node.h +++ b/src/node.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef NODE_H #define NODE_H @@ -77,5 +93,4 @@ class Node { RegisterMap * get_RegisterMap(std::ostringstream& strs); }; - #endif /* NODE_H */ diff --git a/src/opcua/ua_server.cpp b/src/opcua/ua_server.cpp index 070e8fd1ecba98e08b9b3b90a07a8e695a3edc0d..3de4168a16e9b82e634da4b0420976e1bc4b932c 100644 --- a/src/opcua/ua_server.cpp +++ b/src/opcua/ua_server.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #include <open62541/plugin/log_stdout.h> #include <open62541/server.h> #include <open62541/server_config_default.h> @@ -22,7 +38,7 @@ string p_termout(TermOutput& termout) static void updateVariable(UA_Server *server) { UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"updateVariable()"); - UA_Int32 my_integer = 30; + UA_Int32 my_integer = 30; // FIXME: this is example code, remove later UA_Variant value; UA_Variant_setScalar(&value, &my_integer, &UA_TYPES[UA_TYPES_INT32]); UA_NodeId currentNodeId = UA_NODEID_STRING(1, (char *)"sensors"); @@ -34,7 +50,7 @@ static void addVariable(UA_Server *server) UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"addVariable()"); /* Define the attribute of the myInteger variable node */ UA_VariableAttributes attr = UA_VariableAttributes_default; - UA_Int32 myInteger = 42; + UA_Int32 myInteger = 42; // FIXME: this is example code, remove later UA_Variant_setScalar(&attr.value, &myInteger, &UA_TYPES[UA_TYPES_INT32]); attr.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"sensors"); attr.displayName = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"sensors"); @@ -92,25 +108,25 @@ static UA_StatusCode UNB_MethodCallback(UA_Server *server, static void add_UNB_Method(UA_Server *server, std::string regname) { - UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"add_UNB_Method: %s",(char *)regname.c_str()); + UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "add_UNB_Method: %s", (char *)regname.c_str()); UA_Argument inputArgument; UA_Argument_init(&inputArgument); - inputArgument.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *) "A String"); + inputArgument.description = UA_LOCALIZEDTEXT((char *)"en-US", (char *) "A String"); inputArgument.name = UA_STRING((char *)"MyInput"); inputArgument.dataType = UA_TYPES[UA_TYPES_STRING].typeId; inputArgument.valueRank = UA_VALUERANK_SCALAR; UA_Argument outputArgument; UA_Argument_init(&outputArgument); - outputArgument.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *) "A String"); + outputArgument.description = UA_LOCALIZEDTEXT((char *)"en-US", (char *) "A String"); outputArgument.name = UA_STRING((char *)"MyOutput"); outputArgument.dataType = UA_TYPES[UA_TYPES_STRING].typeId; outputArgument.valueRank = UA_VALUERANK_SCALAR; UA_MethodAttributes helloAttr = UA_MethodAttributes_default; - helloAttr.description = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB file"); - helloAttr.displayName = UA_LOCALIZEDTEXT((char *)"en-US",(char *)"UNB file"); + helloAttr.description = UA_LOCALIZEDTEXT((char *)"en-US", (char *)"UNB file"); + helloAttr.displayName = UA_LOCALIZEDTEXT((char *)"en-US", (char *)"UNB file"); helloAttr.executable = true; helloAttr.userExecutable = true; UA_Server_addMethodNode(server, UA_NODEID_STRING(1, (char *)regname.c_str()), @@ -146,7 +162,7 @@ int ua_server(Serverdat *sd) { UA_StatusCode retval = UA_Server_run(mUaServer, &ServerRunning); - UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,"UA Server Stopped"); + UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "UA Server Stopped"); UA_Server_delete(mUaServer); return retval == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/src/opcua/ua_server.h b/src/opcua/ua_server.h index b918f24b1e883aae75754c4e3a8bf45e25b32b56..5d6da62e696e3cdc8307e5e75ae8bb714732e1c2 100644 --- a/src/opcua/ua_server.h +++ b/src/opcua/ua_server.h @@ -1,3 +1,20 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + + #ifndef UA_SERVER_H #define UA_SERVER_H diff --git a/src/periph/system.cpp b/src/periph/system.cpp index 4a1e3834a3ace314f502a3be2080375ae174cc6c..b5ed728e74ca67c350df0a3092417bbd6d5fe683 100644 --- a/src/periph/system.cpp +++ b/src/periph/system.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef _REENTRANT #error ACK! You need to compile with _REENTRANT defined since this uses threads #endif @@ -35,10 +51,10 @@ Periph_system::Periph_system(UNBos &commdev, const string design_name) : unbos(c registerMap = new RegisterMap(read_reg_map()); // used old version style } else { registerMap = new RegisterMap(import_ccfg_file(ifs)); - registerMap->add_register("dev/name", 0,0,0xffffffff,0,"RO"); - registerMap->add_register("dev/stamps", 0,0,0xffffffff,0,"RO"); - registerMap->add_register("dev/note", 0,0,0xffffffff,0,"RO"); - registerMap->add_register("dev/sensors",0,0,0xffffffff,0,"RO"); + registerMap->add_register("dev/name", 0, 0, 0xffffffff, 0, "RO"); + registerMap->add_register("dev/stamps", 0, 0, 0xffffffff, 0, "RO"); + registerMap->add_register("dev/note", 0, 0, 0xffffffff, 0, "RO"); + registerMap->add_register("dev/sensors", 0, 0, 0xffffffff, 0, "RO"); } } @@ -53,7 +69,7 @@ bool Periph_system::Read(const string addr_str, const uint32_t offset, const uin ret = unbos.readRegister(addr,nvalues,data_ptr); if(ret && (shift != 0 || mask != 0xffffffff)) { - for(uint32_t i=0;i<nvalues;i++) { + for(uint32_t i=0; i < nvalues; i++) { data_ptr[i] &= mask; data_ptr[i] = data_ptr[i] >> shift; } @@ -70,7 +86,7 @@ bool Periph_system::Write(const string addr_str, const uint32_t offset, const ui uint32_t mask = registerMap->getMask(addr_str); if(shift != 0 || mask != 0xffffffff) { - for(uint32_t i=0;i<nvalues;i++) { + for(uint32_t i=0; i<nvalues; i++) { data_ptr[i] = data_ptr[i] << shift; data_ptr[i] &= mask; } @@ -100,13 +116,13 @@ bool Periph_system::read_system_info(ostringstream& strs) bool retval = Read("mm/system/info/info",0,1,&data); if(data&(1<<11)) { strs << " read_design_name:" << read_design_name() << endl; - read_use_phy(strs); } char str[1000]; - sprintf(str," g_sim = %d\n",((data & 0x400) != 0)); strs << str; - sprintf(str," Firmware version = %d.%d\n",(data & 0xF00000) >> 20, - (data & 0x0F0000) >> 16); strs << str; - sprintf(str," Hardware version = %d\n",((data & 0x300) >> 8)); strs << str; + // FIXME: get rid of magic constants in masks: + sprintf(str," g_sim = %d\n", ((data & 0x00000400) != 0)); strs << str; + sprintf(str," Firmware version = %d.%d\n",(data & 0x00F00000) >> 20, + (data & 0x000F0000) >> 16); strs << str; + sprintf(str," Hardware version = %d\n", ((data & 0x00000300) >> 8)); strs << str; return retval; } @@ -118,11 +134,11 @@ bool Periph_system::mread(std::ostringstream& strs, const std::string addr, if(retval) { datavec.resize(nvalues); strs << "["; - for(uint i=0;i< nvalues;i++) { + for(uint i=0; i < nvalues; i++) { if(i>0) strs << ","; //strs << hex << "0x" << data[i] << dec; strs << data[i]; - datavec[i]=data[i]; + datavec[i] = data[i]; } strs << "]";// << endl; } @@ -135,14 +151,14 @@ bool Periph_system::mwrite(std::ostringstream& strs, const std::string addr, { uint32_t *data = new uint32_t[datavec.size()*sizeof(uint32_t)]; strs << "["; - for(uint i=0;i<datavec.size();i++) { + for(uint i = 0;i < datavec.size(); i++) { if(i>0) strs << ","; //strs << hex << "0x" << datavec[i] << dec; strs << datavec[i]; - data[i]=(uint32_t)datavec[i]; + data[i] = (uint32_t)datavec[i]; } strs << "]";// << endl; - bool retval = Write(addr,offs,1,data); + bool retval = Write(addr, offs, 1, data); delete[] data; return retval; } @@ -151,33 +167,33 @@ string Periph_system::read_design_name(void) { uint32_t nof_design_name_regs = 8; uint32_t nvalues = nof_design_name_regs; - uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)+1]; - bool retval = Read("mm/system/info/info",2,nvalues,data); - char *str_ptr=(char *)data; - string name=string(str_ptr); + uint32_t *data = new uint32_t[nvalues * sizeof(uint32_t)+1]; + bool retval = Read("mm/system/info/info", 2, nvalues, data); + char *str_ptr = (char *)data; + string name = string(str_ptr); delete[] data; - return (retval?name:"? (error)"); + return (retval ? name : "? (error)"); } string Periph_system::read_design_note(void) { uint32_t nof_design_name_regs = 8; uint32_t nvalues = nof_design_name_regs; - uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)+1]; - bool retval = Read("mm/system/info/info",13,nvalues,data); - data[nvalues]=0; // add end of string char - char *str_ptr=(char *)data; - string note=string(str_ptr); + uint32_t *data = new uint32_t[nvalues * sizeof(uint32_t)+1]; + bool retval = Read("mm/system/info/info", 13, nvalues,data); + data[nvalues] = 0; // add end of string char + char *str_ptr = (char *)data; + string note = string(str_ptr); delete[] data; - return (retval?note:"? (error)"); + return (retval ? note : "? (error)"); } bool Periph_system::read_stamps(ostringstream& strs) { uint32_t nof_regs = 3; uint32_t nvalues = nof_regs; - uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)+1]; - bool retval = Read("mm/system/info/info",10,nvalues,data); + uint32_t *data = new uint32_t[nvalues * sizeof(uint32_t)+1]; + bool retval = Read("mm/system/info/info", 10, nvalues, data); strs << " Stamp: date=" << data[0] << endl; strs << " Stamp: time=" << data[1] << endl; @@ -186,49 +202,27 @@ bool Periph_system::read_stamps(ostringstream& strs) return retval; } -bool Periph_system::read_use_phy(ostringstream& strs) -{ - uint32_t data; - bool retval = Read("mm/system/info/info",1,1,&data); - - // This can be used to find the phy name based position in SLV - const char* c_unb_use_phy[] = { - "wdi", // 0x0 - "adc", // 0x1 - "ddr3_II", // 0x2 - "ddr3_I", // 0x3 - "tr_back", // 0x4 - "tr_mesh", // 0x5 - "eth10g", // 0x6 - "eth1g" // 0x7 - }; - for(uint bit=0;bit<8;bit++) { - if(data&(1<<bit)) strs << " Used PHY:" << c_unb_use_phy[bit] << endl; - } - return retval; -} - bool Periph_system::read_unb_sensors(ostringstream& strs, const uint nodeNr) { - bool retval=true; + bool retval = true; uint32_t nvalues = 1; - uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)]; - retval = Read("mm/sens/sens/sens_data0",0,nvalues,data); + uint32_t *data = new uint32_t[nvalues * sizeof(uint32_t)]; + retval = Read("mm/sens/sens/sens_data0", 0, nvalues, data); char str[1000]; - sprintf(str," FPGA temperature = %d [degC]\n",data[0]); strs << str; + sprintf(str," FPGA temperature = %d [degC]\n", data[0]); strs << str; delete[] data; return retval; } bool Periph_system::read_unb_sensor(uint32_t *sensor, const uint nodeNr) { - bool retval=true; + bool retval = true; uint32_t nvalues = 1; - uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)]; - retval = Read("mm/sens/sens/sens_data0",0,nvalues,data); + uint32_t *data = new uint32_t[nvalues * sizeof(uint32_t)]; + retval = Read("mm/sens/sens/sens_data0", 0, nvalues, data); *sensor = data[0]; delete[] data; @@ -237,9 +231,9 @@ bool Periph_system::read_unb_sensor(uint32_t *sensor, const uint nodeNr) bool Periph_system::read_temp_high(ostringstream& strs) { - bool retval=false; + bool retval = false; uint32_t data; - retval=Read("mm/sens/sens/temp_high", 5,1,&data); + retval = Read("mm/sens/sens/temp_high", 5, 1, &data); strs << " High temp limit = " << data << " [degC]" << endl; return retval; } @@ -248,13 +242,13 @@ bool Periph_system::write_temp_high(ostringstream& strs, const int val) { if(val < 10) throw runtime_error("bad high temp value"); uint32_t data = val; - return Write("mm/sens/sens/temp_high", 5,1,&data); + return Write("mm/sens/sens/temp_high", 5, 1, &data); } bool Periph_system::write_wdi_override(ostringstream& strs) { uint32_t data = 0xB007FAC7; - return Write("mm/wdi/wdi/reset_word", 0,1,&data); + return Write("mm/wdi/wdi/reset_word", 0, 1, &data); } /* @@ -265,16 +259,16 @@ RegisterMap Periph_system::read_reg_map(void) RegisterMap reg; uint32_t nvalues = 1024; uint32_t addr = reg.getValidAddr("mm/rom_system/info/info", 0, nvalues); - uint32_t *data = new uint32_t[nvalues*sizeof(uint32_t)]; - if(!unbos.readRegister(addr,nvalues,data)) { + uint32_t *data = new uint32_t[nvalues * sizeof(uint32_t)]; + if(!unbos.readRegister(addr, nvalues, data)) { delete[] data; throw runtime_error("unbos.Read()"); } - for(uint i=0;i<nvalues;i++) { - data[i]=ntohl(data[i]); + for(uint i=0; i < nvalues; i++) { + data[i] = ntohl(data[i]); } - char *str_ptr=(char *)data; + char *str_ptr = (char *)data; string reg_map_str(str_ptr); delete[] data; @@ -299,11 +293,11 @@ RegisterMap Periph_system::read_reg_map(void) throw runtime_error("Corrupt base/span on "+regname+ " "+to_string(base)+" "+to_string(span)); } - newRegisterMap.add_register(regname,base,span,0xffffffff,0,"RW"); + newRegisterMap.add_register(regname, base, span, 0xffffffff, 0, "RW"); } } catch(runtime_error& e) { cerr << "Periph_system::read_reg_map: " << e.what() << endl; - syslog(LOG_ERR,"Periph_system::read_reg_map: %s\n",e.what()); + syslog(LOG_ERR,"Periph_system::read_reg_map: %s\n", e.what()); throw; } return newRegisterMap; diff --git a/src/periph/system.h b/src/periph/system.h index 4a3de409127f17b3b1df180dd4ea2fcf099cfcb7..e92f86d6448aafe94d249839b2d6dbace6b8c57f 100644 --- a/src/periph/system.h +++ b/src/periph/system.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef __PERIPH_SYSTEM_H__ #define __PERIPH_SYSTEM_H__ @@ -30,7 +46,6 @@ public: std::string read_design_name(void); std::string read_design_note(void); bool read_stamps(ostringstream& strs); - bool read_use_phy(ostringstream& strs); bool read_unb_sensor(uint32_t *sensor, const uint nodeNr); bool read_unb_sensors(ostringstream& strs, const uint nodeId); bool read_temp_high(ostringstream& strs); @@ -38,7 +53,7 @@ public: bool write_wdi_override(ostringstream& strs); RegisterMap read_reg_map(void); RegisterMap * getRegisterMap(void) { return registerMap; }; - void print_regmap(ostringstream& strs, std::string prefix) { registerMap->print(strs,prefix); }; + void print_regmap(ostringstream& strs, std::string prefix) { registerMap->print(strs, prefix); }; }; #endif // __PERIPH_SYSTEM_H__ diff --git a/src/registers.cpp b/src/registers.cpp index 58d9127a1e839db6770a2d35bc9562a8c56e0053..6a78b0b14c0bc12dccc6bbcb7521607f2f3c1e5e 100644 --- a/src/registers.cpp +++ b/src/registers.cpp @@ -29,7 +29,7 @@ void RegisterMap::add_register(const std::string name, const uint32_t base, const uint32_t shift, const std::string access) { register_info r={base, span, mask, shift, access}; - reg.insert(reg.end(),std::pair<std::string,register_info>(name,r)); + reg.insert(reg.end(), std::pair<std::string, register_info>(name, r)); } void RegisterMap::print(ostringstream& strs, std::string prefix) diff --git a/src/registers.h b/src/registers.h index 81385e63742e1d65deeb2fe6a997284c632af896..59f422da06311221a92415c3a6832ca45e9acc17 100644 --- a/src/registers.h +++ b/src/registers.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef __REGISTERMAP_H__ #define __REGISTERMAP_H__ diff --git a/src/sdpunb.cpp b/src/sdpunb.cpp index 82638dac985bee3812656602de4edbfae53db264..7dc5f07359c9f55a3ec6dec6d5e05b42e3a5bbc1 100644 --- a/src/sdpunb.cpp +++ b/src/sdpunb.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #include <stdlib.h> #include <sys/time.h> #include <sys/types.h> @@ -32,7 +48,6 @@ namespace po = boost::program_options; /* Global var */ volatile bool ServerRunning = true; int debug = 0; -bool USE_THREADS=true; const char* SDPUNB_VERSION= " (testing) " __DATE__ " " __TIME__; @@ -54,50 +69,47 @@ void control_server(TCPSSocket *sock, Serverdat *sd, const int clientId, std::at bool quit=false; while(ServerRunning) { try { - //cout << "control server thread[" << clientId << "] started" << endl; sd->controlSocket[clientId] = new TCPCSSocket(sock->listen()); string banner = "output={ SDP to Uniboard Translator " + string(SDPUNB_VERSION) - + ". (use 'help' for available commands) }\n"; - sd->controlSocket[clientId]->tx((unsigned char *)banner.c_str(),strlen(banner.c_str())); + + ". (use 'help' for available commands) }\n"; + sd->controlSocket[clientId]->tx((unsigned char *)banner.c_str(), strlen(banner.c_str())); CMD Cmd; string line; - string cmdname=""; - CMDstatus cmdstatus={CMD_STATUS_OK, 0,0}; - CMDstatus cmdstatusnew=cmdstatus; + string cmdname = ""; + CMDstatus cmdstatus = {CMD_STATUS_OK, 0,0}; + CMDstatus cmdstatusnew = cmdstatus; TermOutput termout; - unsigned char tcpbuf[1000]; + unsigned char tcpbuf[c_TCP_CONTROL_BUFFERSIZE]; while(!quit) { string prompt = "sdpunb:" + cmdname + ":" + to_string(cmdstatus.status) + ":CMD>"; - sd->controlSocket[clientId]->tx((unsigned char *)prompt.c_str(),strlen(prompt.c_str())); + sd->controlSocket[clientId]->tx((unsigned char *)prompt.c_str(), strlen(prompt.c_str())); - int len = sd->controlSocket[clientId]->rx(tcpbuf,1000); + int len = sd->controlSocket[clientId]->rx(tcpbuf, c_TCP_CONTROL_BUFFERSIZE); if(len < 1) { quit = true; } else { // With telnet, a \r\n is added to the transmitted string, get rid of them. string sbuf((char *)tcpbuf); size_t pos = sbuf.find("\n"); - if (pos!=string::npos) tcpbuf[pos]=0; + if (pos != string::npos) tcpbuf[pos] = 0; pos = sbuf.find("\r"); - if (pos!=string::npos) tcpbuf[pos]=0; - cmdstatusnew=Cmd.command(string((char *)tcpbuf),termout,cmdname,sd); - if(cmdstatusnew.status!=CMD_EMPTY) cmdstatus=cmdstatusnew; + if (pos != string::npos) tcpbuf[pos] = 0; + cmdstatusnew = Cmd.command(string((char *)tcpbuf), termout, cmdname, sd); + if(cmdstatusnew.status != CMD_EMPTY) cmdstatus = cmdstatusnew; string s = print_termout(termout); - sd->controlSocket[clientId]->tx((unsigned char *)s.c_str(),strlen(s.c_str())); + sd->controlSocket[clientId]->tx((unsigned char *)s.c_str(), strlen(s.c_str())); termout.clear(); - if(cmdstatus.status==CMD_REQUEST_QUIT) { + if(cmdstatus.status == CMD_REQUEST_QUIT) { quit = true; } } } - //cerr << "client disconnect" << endl; sd->controlSocket[clientId]->Shutdown(); delete sd->controlSocket[clientId]; } catch(const char *str) { - //cerr << "catch at server: " << str << " (closing user connection)" << endl; delete sd->controlSocket[clientId]; } } @@ -115,29 +127,27 @@ static void stopHandler(int signal) int main (int argc, char* argv[]) { // defaults: - int control_tcpport = 3335; + int control_tcpport = c_TCP_CONTROL_SOCKET; bool nodaemon = false; int verbose = 1; debug=0; string configfile = "/etc/uniboard.conf"; - USE_THREADS=true; std::atomic<size_t> ncthreads(0); std::thread *control_server_thread[c_MAX_CONTROL_SERVERS]; po::options_description desc("Allowed options"); desc.add_options() - ("help,h", "shows this help text") - ("version,v", "prints sdpunb version info") - ("tcpport", po::value<int>(&control_tcpport)->default_value(control_tcpport), - "The TCP (ctrl) port to listen to (default=3335)") - ("nodaemon", po::value<bool>(&nodaemon)->zero_tokens(), - "With this flag, the server runs NOT as daemon") - ("nothreads", "With this flag, the server does not use threads for nodes") - ("debug", po::value(&debug),"Prints out debug info (default=0)") - ("verbose", po::value(&verbose),"More messages and infos") + ("help,h", "shows this help text") + ("version,v", "prints sdpunb version info") + ("tcpport", po::value<int>(&control_tcpport)->default_value(control_tcpport), + "The TCP (ctrl) port to listen to (default=3335)") + ("nodaemon", po::value<bool>(&nodaemon)->zero_tokens(), + "With this flag, the server runs NOT as daemon") + ("debug", po::value(&debug), "Prints out debug info (default=0)") + ("verbose", po::value(&verbose), "More messages and infos") ("configfile", po::value<string>(&configfile)->default_value(configfile), - "Specify uniboard configuration file location") + "Specify uniboard configuration file location") ; try { @@ -154,9 +164,6 @@ int main (int argc, char* argv[]) cout << argv[0] << ' ' << SDPUNB_VERSION << endl; exit(EXIT_SUCCESS); } - if (vm.count("nothreads")) { - USE_THREADS=false; - } if(debug) { cout << "Debug printing enabled. Level=" << debug << endl; } } catch(po::error& e) { cerr << "ERROR: " << e.what() << endl << endl; @@ -172,8 +179,8 @@ int main (int argc, char* argv[]) try { /* Open syslog connection */ - openlog(basename(argv[0]),0,LOG_LOCAL0); - syslog(LOG_INFO,"Starting server %s\n",SDPUNB_VERSION); + openlog(basename(argv[0]), 0, LOG_LOCAL0); + syslog(LOG_INFO,"Starting server %s\n", SDPUNB_VERSION); ostringstream sstr; list<class NODE_config> NC; @@ -183,12 +190,13 @@ int main (int argc, char* argv[]) ifs.open(configfile.c_str()); if (!ifs.is_open()) { cerr << "Error opening config file: " << configfile << " (use --configfile=filename)" << endl; - syslog(LOG_ERR,"Error opening config file: %s (use --configfile=filename)\n",configfile.c_str()); + syslog(LOG_ERR,"Error opening config file: %s (use --configfile=filename)\n", + configfile.c_str()); exit(EXIT_FAILURE); } else { if(!importdatfile(ifs, NC)) { cerr << "Error reading config file: " << configfile << endl; - syslog(LOG_ERR,"Error reading config file: %s\n",configfile.c_str()); + syslog(LOG_ERR,"Error reading config file: %s\n", configfile.c_str()); exit(EXIT_FAILURE); } } @@ -196,36 +204,36 @@ int main (int argc, char* argv[]) list<class Node*> nodelist; for(auto nc : NC) { - uint gn=(uint)nc.gn; - uint uniboardnr=GLOBALNODE_to_UNB(gn); - uint n=GLOBALNODE_to_NODE(gn); - string type=GLOBALNODE_to_TYPE(gn); + uint gn = (uint)nc.gn; + uint uniboardnr = GLOBALNODE_to_UNB(gn); + uint n = GLOBALNODE_to_NODE(gn); + string type = GLOBALNODE_to_TYPE(gn); - Node *node = new Node(nc.ipaddr,uniboardnr,n,type,nc.firmware); + Node *node = new Node(nc.ipaddr, uniboardnr, n, type, nc.firmware); nodelist.push_back(node); } if(!nodaemon) { - if(daemon(1,0) < 0) cerr << "Error fork as daemon: " << strerror(errno) << endl; + if(daemon(1, 0) < 0) cerr << "Error fork as daemon: " << strerror(errno) << endl; } Serverdat control_server_dat; control_server_dat.unb = new UniboardMap(nodelist); - for(uint c=0;c<c_MAX_CONTROL_SERVERS;c++) { + for(uint c=0; c<c_MAX_CONTROL_SERVERS; c++) { control_server_dat.tcpport = control_tcpport; control_server_dat.verbose[c] = verbose; } TCPSSocket sock(control_tcpport, "", c_MAX_CONTROL_SERVERS); - for(uint c=0;c<c_MAX_CONTROL_SERVERS;c++) { + for(uint c=0; c<c_MAX_CONTROL_SERVERS; c++) { control_server_thread[c] = new std::thread(control_server, &sock, &control_server_dat, c, &ncthreads); ++ncthreads; } ua_server(&control_server_dat); - 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]; } + 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]; } for(auto node : nodelist) { delete node; } @@ -235,7 +243,7 @@ int main (int argc, char* argv[]) exit(EXIT_SUCCESS); } catch(exception& e) { cerr << "Error server: " << e.what() << endl; - syslog(LOG_ERR,"Error server: %s\n",e.what()); + syslog(LOG_ERR,"Error server: %s\n", e.what()); closelog(); // close syslog connection exit(EXIT_FAILURE); } diff --git a/src/sdpunb.h b/src/sdpunb.h index cd14bc32fceff61d71eb04f1f013caf255a5659e..db09cb47dd33990d9d8d45415822b1b438c4aba1 100644 --- a/src/sdpunb.h +++ b/src/sdpunb.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef SDPUNB_H #define SDPUNB_H 1 @@ -13,7 +29,9 @@ using namespace std; #include "map.h" #include "io/tcpsocket.h" -#define c_MAX_CONTROL_SERVERS 3 +#define c_MAX_CONTROL_SERVERS 3 +#define c_TCP_CONTROL_SOCKET 3335 +#define c_TCP_CONTROL_BUFFERSIZE 1000 class Serverdat { public: diff --git a/src/tools/ccfg.cpp b/src/tools/ccfg.cpp index 923fa681b6546f263c78bf9fdbd46b903d08e34f..53fb751eb92da33c76a22653d344cfae93355bed 100644 --- a/src/tools/ccfg.cpp +++ b/src/tools/ccfg.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #include <iostream> #include <sstream> #include <iomanip> diff --git a/src/tools/ccfg.h b/src/tools/ccfg.h index fedf18a113119d6d248ac9f44882ff6a865d8562..de4e7887cf5d664d02ddeb5fcb86c3b95f0a2e9a 100644 --- a/src/tools/ccfg.h +++ b/src/tools/ccfg.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef CCFG_H #define CCFG_H diff --git a/src/tools/parse.cpp b/src/tools/parse.cpp index b897bd4cf636f68266fc8c9e73a5bc30f1976da5..a5a4182a8fdce7cac552cc736c4fdbcc81eae6ef 100644 --- a/src/tools/parse.cpp +++ b/src/tools/parse.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #include <math.h> #include <string.h> #include <iostream> @@ -23,7 +39,7 @@ int parse_int(istringstream& vecstr) int num; vecstr >> num; - if(debug&0xe) cout << "parse_int:" << num << endl; + if(debug) cout << "parse_int:" << num << endl; if (vecstr.fail() || vecstr.bad()) { syslog(LOG_ERR,"parse_int parse error\n"); throw runtime_error("Invalid string"); @@ -36,7 +52,7 @@ int parse_uint_nothrow(istringstream& vecstr) int num; vecstr >> num; - if(debug&0xe) cout << "parse_int_nothrow:" << num << endl; + if(debug) cout << "parse_int_nothrow:" << num << endl; if (vecstr.fail() || vecstr.bad()) { //syslog(LOG_ERR,"parse_int_nothrow no input: assume -1\n"); return -1; @@ -49,7 +65,7 @@ double parse_double(istringstream& vecstr) double num; vecstr >> num; - if(debug&0xe) cout << "parse_double:" << num << endl; + if(debug) cout << "parse_double:" << num << endl; if (vecstr.fail() || vecstr.bad()) { syslog(LOG_ERR,"parse_double parse error\n"); @@ -63,7 +79,7 @@ double parse_double_nothrow(istringstream& vecstr) double num; vecstr >> num; - if(debug&0xe) cout << "parse_double_nothrow:" << num << endl; + if(debug) cout << "parse_double_nothrow:" << num << endl; if (vecstr.fail() || vecstr.bad()) { //syslog(LOG_INFO,"parse_double_nothrow no input: assume NAN\n"); @@ -76,7 +92,7 @@ std::complex<double> parse_complex_double(istringstream& vecstr) { complex<double> num; vecstr >> num; - if(debug&0xe) cout << "parse_complex_double:" << num << endl; + if(debug) cout << "parse_complex_double:" << num << endl; if (vecstr.fail() || vecstr.bad()) { syslog(LOG_ERR,"parse_complex_double parse error\n"); @@ -98,7 +114,7 @@ std::vector<int> parse_int_vector(istringstream& vecstr) c=vecstr.peek(); if(c==']' || c==0) { - if(debug&0xe) cout << "parse_int_vector: empty vector" << endl; + if(debug) cout << "parse_int_vector: empty vector" << endl; vecstr >> c; // flush it from istringstream return v; } @@ -120,7 +136,7 @@ std::vector<int> parse_int_vector(istringstream& vecstr) syslog(LOG_ERR,"parse_int_vector error\n"); throw runtime_error("parse_int_vector error"); } - if(debug&0xe) { + if(debug) { cout << "parse_int_vector result: "; for(int i=0;i<(int)v.size();i++) { cout << v[i] << " "; @@ -142,7 +158,7 @@ std::vector<int> parse_int_vector_range(istringstream& vecstr) c=vecstr.peek(); if(c==']' || c==0) { - if(debug&0xe) cout << "parse_int_vector_range: empty vector" << endl; + if(debug) cout << "parse_int_vector_range: empty vector" << endl; vecstr >> c; // flush it from istringstream return v; } @@ -181,7 +197,7 @@ std::vector<int> parse_int_vector_range(istringstream& vecstr) syslog(LOG_ERR,"parse_int_vector_range error\n"); throw runtime_error("parse_int_vector_range error"); } - if(debug&0xe) { + if(debug) { cout << "parse_int_vector_range result: "; for(int i=0;i<(int)v.size();i++) { cout << v[i] << " "; @@ -213,7 +229,7 @@ std::vector<int64_t> parse_int64_vector_range(istringstream& vecstr) c=vecstr.peek(); if(c==']' || c==0) { - if(debug&0xe) cout << "parse_int64_vector_range: empty vector" << endl; + if(debug) cout << "parse_int64_vector_range: empty vector" << endl; vecstr >> c; // flush it from istringstream return v; } @@ -252,7 +268,7 @@ std::vector<int64_t> parse_int64_vector_range(istringstream& vecstr) syslog(LOG_ERR,"parse_int64_vector_range error\n"); throw runtime_error("parse_int64_vector_range error"); } - if(debug&0xe) { + if(debug) { cout << "parse_int64_vector_range result: "; for(int i=0;i<(int)v.size();i++) { cout << v[i] << " "; @@ -298,7 +314,7 @@ std::vector<double> parse_double_vector(istringstream& vecstr) syslog(LOG_ERR,"parse_double_vector error\n"); throw runtime_error("parse_double_vector error"); } - if(debug&0xe) { + if(debug) { cout << "parse_double_vector result: "; for(int i=0;i<(int)v.size();i++) { cout << v[i] << " "; @@ -343,7 +359,7 @@ std::vector< complex<double> > parse_complex_vector(istringstream& vecstr) syslog(LOG_ERR,"parse_complex_vector error\n"); throw runtime_error("parse_complex_vector error"); } - if(debug&0xe) { + if(debug) { cout << "parse_complex_vector result: "; for(int i=0;i<(int)v.size();i++) { cout << v[i] << " "; @@ -358,7 +374,7 @@ ublas::matrix< complex<double> > parse_complex_matrix(istringstream& vecstr) { ublas::matrix< complex<double> > m; vecstr >> m; - if(debug&0xe) cout << "parse_complex_matrix result:" << m << endl; + if(debug) cout << "parse_complex_matrix result:" << m << endl; if (vecstr.fail() || vecstr.bad()) { syslog(LOG_ERR,"error parse_complex_matrix\n"); throw runtime_error("error parse_complex_matrix"); @@ -370,7 +386,7 @@ ublas::matrix<double> parse_double_matrix(istringstream& vecstr) { ublas::matrix<double> m; vecstr >> m; - if(debug&0xe) cout << "parse_double_matrix result:" << m << endl; + if(debug) cout << "parse_double_matrix result:" << m << endl; if (vecstr.fail() || vecstr.bad()) { syslog(LOG_ERR,"error parse_double_matrix\n"); throw runtime_error("error parse_double_matrix"); diff --git a/src/tools/parse.h b/src/tools/parse.h index ca7a66bdfc38555b48ef35eba33d6745fa3c169c..d25fa84f853e171f223cf53f9b0fb1ae7635bf4a 100644 --- a/src/tools/parse.h +++ b/src/tools/parse.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef PARSE_H #define PARSE_H 1 diff --git a/src/tools/util.cpp b/src/tools/util.cpp index b5c1caa3451c2348a3d434a274edc22c6691bd9f..6cfbcdf3b6eea6bc7fb96a145f5b0cd6560d9bfd 100644 --- a/src/tools/util.cpp +++ b/src/tools/util.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #include <math.h> #include <vector> #include <algorithm> diff --git a/src/tools/util.h b/src/tools/util.h index 6ad96573e48b6871c95cbef384446851ef975eb6..07e1951e718bab43f102573143a293b453cedf14 100644 --- a/src/tools/util.h +++ b/src/tools/util.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../../LICENSE.txt for more info. + */ + #ifndef __UTIL_H__ #define __UTIL_H__ diff --git a/src/unb_config.cpp b/src/unb_config.cpp index 2b56f053b56c1a03cedcf494a50e833926e3a35f..aedbebebc1f146773ef743c3df50ef11f51cbd8f 100644 --- a/src/unb_config.cpp +++ b/src/unb_config.cpp @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #include <iostream> #include <sstream> #include <iomanip> diff --git a/src/unb_config.h b/src/unb_config.h index 18cefd58a4c66a0be6685bab10e1172d1c823c21..a3269976109e83bff348abbdc4d3f14bb80b99f1 100644 --- a/src/unb_config.h +++ b/src/unb_config.h @@ -1,3 +1,19 @@ +/* + * Copyright 2020 Stichting Nederlandse Wetenschappelijk Onderzoek Instituten, + * ASTRON Netherlands Institute for Radio Astronomy + * Licensed under the Apache License, Version 2.0 (the "License"); + * + * you may not use this file except in compliance with the License. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * See ../LICENSE.txt for more info. + */ + #ifndef UNB_CONFIG_H #define UNB_CONFIG_H diff --git a/src/uniboard2.conf b/src/uniboard2.conf index 58703c4fdb9974a054310b8771e0c8bc25132e5c..520722488a03153e2c6226a95c2893700eae4f9b 100644 --- a/src/uniboard2.conf +++ b/src/uniboard2.conf @@ -2,7 +2,7 @@ # the following nodes are contributing # NODE config: -# gn ipaddr firmware +# gn ipaddr expected firmware node 3 10.99.1.4 unb2b_minimal