Commit 2baed43a authored by Leon Hiemstra's avatar Leon Hiemstra

monitor deisgn_name/version as expected, to test

parent 67a03e81
......@@ -31,14 +31,14 @@ make
# Configure server:
vi src/uniboard2.conf
vi src/uniboard.conf
Usage:
Startup server process:
(for testing)
```
cd src
./sdpunb --configfile=uniboard2.conf --nodaemon
./sdpunb --configfile=uniboard.conf --nodaemon
```
......@@ -84,7 +84,7 @@ then execute the command shown in the README file in that directory
1. Start the sdpunb server on dop36:
```
cd src
./sdpunb --configfile=uniboard2.conf --nodaemon
./sdpunb --configfile=uniboard.conf --nodaemon
```
2. Run the client:
......
......@@ -110,7 +110,7 @@ bool UNBos::Read(const uint32_t opcode, const uint32_t addr, const uint nvalues,
int retstat=0;
uint nreceived=0;
cout << "UNBos::Read from addr=0x" << hex << addr << " span=" << dec << nvalues << endl;
//cout << "UNBos::Read from addr=0x" << hex << addr << " span=" << dec << nvalues << endl;
while(nreceived < nvalues) {
uint _nvalues = nvalues-nreceived;
......@@ -188,7 +188,7 @@ bool UNBos::Write(const uint32_t opcode, const uint32_t addr, const uint nvalues
int retstat=0;
uint nsent=0;
cout << "UNBos::Write to addr=0x" << hex << addr << " span=" << dec << nvalues << endl;
//cout << "UNBos::Write to addr=0x" << hex << addr << " span=" << dec << nvalues << endl;
while(nsent < nvalues) {
uint _nvalues = nvalues-nsent;
......
......@@ -42,18 +42,11 @@ 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, const uint firmware_version) : unbos(ipaddr)
{
myIPaddr = ipaddr;
periph_system = new Periph_system(unbos, firmware);
myFirmware = periph_system->read_design_name();
if(myFirmware != firmware) {
cerr << "Warning: Node configuration mismatch!! (read_design_name=" << myFirmware
<< ", config=" << firmware << ")" << endl;
syslog(LOG_WARNING,"Node configuration mismatch!! (read_design_name=%s, config=%s)\n",
myFirmware.c_str(),firmware.c_str());
}
periph_system = new Periph_system(unbos, firmware, firmware_version);
UniboardNr = unb;
LocalNr = localnr;
......
......@@ -45,6 +45,7 @@ public:
int gn;
std::string ipaddr;
std::string firmware;
uint version;
};
#define GLOBALNODE_to_UNB(n) (n>>3)
......@@ -54,8 +55,6 @@ public:
class Node {
private:
std::string myIPaddr;
std::string myFirmware;
std::string myFirmwareShortname;
uint UniboardNr;
uint GlobalNr;
uint LocalNr;
......@@ -71,15 +70,14 @@ class Node {
public:
Node(const std::string ipaddr,
const uint unb, const uint localnr, const std::string type, const std::string firmware);
const uint unb, const uint localnr, const std::string type,
const std::string firmware, const uint firmware_version);
~Node();
uint ipaddr_to_id(const std::string ipaddr);
const uint GetLocalNr() { return LocalNr; }
const uint GetUniboardNr() { return UniboardNr; }
const std::string GetIP() { return myIPaddr; }
const std::string GetFirmwareName(void) { return myFirmware; }
const std::string GetFirmwareShortname(void) { return myFirmwareShortname; }
const uint GetGlobalNr() { return GlobalNr; }
const uint GetNr() { return LocalNr; }
const std::string GetType() { return Type; }
......
......@@ -38,8 +38,13 @@ using namespace std;
extern int debug;
Periph_system::Periph_system(UNBos &commdev, const string design_name) : unbos(commdev)
Periph_system::Periph_system(UNBos &commdev,
const string expected_design_name,
const uint expected_firmware_version) : unbos(commdev)
{
my_expected_design_name = expected_design_name;
my_expected_firmware_version = expected_firmware_version;
registerMap = new RegisterMap(read_reg_map());
// Add composite registers:
......@@ -48,6 +53,8 @@ Periph_system::Periph_system(UNBos &commdev, const string design_name) : unbos(c
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");
std::string design_name = read_design_name();
}
bool Periph_system::Read(const string addr_str, const uint32_t offset, const uint32_t nvalues, uint32_t *data_ptr)
......@@ -106,16 +113,31 @@ bool Periph_system::read_system_info(ostringstream& strs)
{
uint32_t data;
bool retval = Read("mm/system/info/info",0,1,&data);
if(data&(1<<11)) {
strs << " read_design_name:" << read_design_name() << endl;
}
std::string design_name = read_design_name();
strs << "Design name = " << design_name << endl;
char str[1000];
// FIXME: get rid of magic constants in masks:
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;
// FIXME: get rid of magic constants in masks, should be in CCFG:
uint firmware_version = (data & 0x00F00000) >> 20;
uint firmware_subversion = (data & 0x000F0000) >> 16;
uint hardware_version = (data & 0x00000300) >> 8;
sprintf(str,"Firmware version = %d.%d\n",firmware_version,firmware_subversion); strs << str;
sprintf(str,"Hardware version = %d\n",hardware_version); strs << str;
if(design_name == my_expected_design_name && firmware_version == my_expected_firmware_version) {
retval = true;
} else {
retval = false;
strs << "Unexpected design_name / firmware_version" << endl;
cerr << "Warning: Node configuration mismatch!! (read_design_name/version=" << design_name
<< "/" << firmware_version << "), expected=" << my_expected_design_name
<< "/" << my_expected_firmware_version << ")" << endl;
syslog(LOG_WARNING,"Node configuration mismatch!! (read_design_name/version=%s/%d, expected=%s/%d)\n",
design_name.c_str(), firmware_version,
my_expected_design_name.c_str(), my_expected_firmware_version);
}
return retval;
// FIXME: test if design_name is expected, otherwise reload REGMAP by calling function: raise(SIGHUP);
}
bool Periph_system::mread(std::ostringstream& strs, const std::string addr,
......
......@@ -30,12 +30,14 @@ class Periph_system {
private:
UNBos &unbos;
RegisterMap *registerMap;
std::string my_expected_design_name;
uint my_expected_firmware_version;
bool Read(const string addr_str, const uint32_t offset, const uint32_t nvalues, uint32_t *data_ptr);
bool Write(const string addr_str, const uint32_t offset, const uint32_t nvalues, uint32_t *data_ptr);
public:
Periph_system(UNBos &unbos, const string design_name);
Periph_system(UNBos &unbos, const string expected_design_name, const uint expected_firmware_version);
~Periph_system() {};
bool read_system_info(std::ostringstream& strs);
......
......@@ -77,7 +77,8 @@ void monitor(void)
while(ServerRunning) {
usleep(1000000);
while(!SD.monitor_mutex.try_lock()) { cerr << "mutex not ready\n"; usleep(100000); }
cmdstatusnew = Cmd.command("read /unb0/pn[0:2]/dev/system", termout, cmdname, &SD);
//cmdstatusnew = Cmd.command("read /unb0/pn[0:2]/dev/system", termout, cmdname, &SD);
cmdstatusnew = Cmd.command("read /unb0/pn[0]/dev/system", termout, cmdname, &SD);
SD.monitor_mutex.unlock();
if(cmdstatusnew.status != CMD_EMPTY) cmdstatus = cmdstatusnew;
cout << "Monitor thread: " << print_termout(termout) << endl;
......@@ -179,7 +180,7 @@ void server_init(bool warm_start)
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, nc.version);
nodelist.push_back(node);
}
SD.unb = new UniboardMap(nodelist);
......
# Peripherals for unb2b_minimal:
# peripheral=system start=0x0000 span=0x0020 type=LITE count=01 idx=0 stop=0x0020
# REG-SLAVE=info no.slaves=1 len=1 (base=0x20)
DistrRAM 0x00000000 len=32 RO system info info
# peripheral=rom_system start=0x0400 span=0x0400 type=LITE count=01 idx=0 stop=0x0800
# REG-SLAVE=info no.slaves=1 len=1 (base=0x400)
DistrRAM 0x00000400 len=1024 RO rom_system info info
# peripheral=ctrl start=0x00E0 span=0x0001 type=LITE count=01 idx=0 stop=0x00E1
# REG-SLAVE=pio_wdi no.slaves=1 len=4 (base=0x0)
BitField 0x000000E0 b[31:0] WO ctrl pio_wdi nios_reset
# peripheral=wdi start=0x0C00 span=0x0001 type=LITE count=01 idx=0 stop=0x0C01
# REG-SLAVE=wdi no.slaves=1 len=4 (base=0x0)
BitField 0x00000C00 b[31:0] WO wdi wdi reset_word
# peripheral=eth1g start=0x0800 span=0x0400 type=LITE count=01 idx=0 stop=0x0C00
# REG-SLAVE=tse no.slaves=1 len=1 (base=0x400)
DistrRAM 0x00000800 len=1024 NA eth1g tse status
# peripheral=eth1g start=0x0020 span=0x000C type=LITE count=01 idx=0 stop=0x002C
# REG-SLAVE=eth no.slaves=1 len=48 (base=0x400)
BitField 0x00000020 b[31:0] NA eth1g eth status0
BitField 0x00000021 b[31:0] NA eth1g eth status1
BitField 0x00000022 b[31:0] NA eth1g eth status2
BitField 0x00000023 b[31:0] NA eth1g eth status3
BitField 0x00000024 b[31:0] NA eth1g eth status4
BitField 0x00000025 b[31:0] NA eth1g eth status5
BitField 0x00000026 b[31:0] NA eth1g eth status6
BitField 0x00000027 b[31:0] NA eth1g eth status7
BitField 0x00000028 b[31:0] NA eth1g eth status8
BitField 0x00000029 b[31:0] NA eth1g eth status9
BitField 0x0000002A b[31:0] NA eth1g eth status10
BitField 0x0000002B b[31:0] NA eth1g eth status11
# peripheral=eth1g start=0x1000 span=0x0400 type=FULL count=01 idx=0 stop=0x1400
# RAM-SLAVE=eth
BlockRAM 0x00001000 len=1024 RW eth1g eth data
# peripheral=ppsh start=0x00EC span=0x0002 type=LITE count=01 idx=0 stop=0x00EE
# REG-SLAVE=ppsh no.slaves=1 len=8 (base=0x0)
BitField 0x000000EC b[31:0] RO ppsh ppsh status
BitField 0x000000ED b[31:0] RW ppsh ppsh control
# peripheral=epcs start=0x00D0 span=0x0006 type=LITE count=01 idx=0 stop=0x00D6
# REG-SLAVE=epcs no.slaves=1 len=24 (base=0x0)
BitField 0x000000D0 b[23:0] WO epcs epcs addr
BitField 0x000000D1 b[0:0] WO epcs epcs rden
BitField 0x000000D2 b[0:0] WO epcs epcs read_bit
BitField 0x000000D3 b[0:0] WO epcs epcs write_bit
BitField 0x000000D4 b[0:0] WO epcs epcs sector_erase
BitField 0x000000D5 b[0:0] RO epcs epcs busy
# peripheral=epcs start=0x00EA span=0x0001 type=LITE count=01 idx=0 stop=0x00EB
# REG-SLAVE=dpmm_ctrl no.slaves=1 len=4 (base=0x6)
BitField 0x000000EA b[31:0] RW epcs dpmm_ctrl ctrl
# peripheral=epcs start=0x00E8 span=0x0001 type=LITE count=01 idx=0 stop=0x00E9
# REG-SLAVE=dpmm_data no.slaves=1 len=4 (base=0x7)
BitField 0x000000E8 b[31:0] RW epcs dpmm_data data
# peripheral=epcs start=0x00E6 span=0x0001 type=LITE count=01 idx=0 stop=0x00E7
# REG-SLAVE=mmdp_ctrl no.slaves=1 len=4 (base=0x8)
BitField 0x000000E6 b[31:0] RW epcs mmdp_ctrl ctrl
# peripheral=epcs start=0x00E4 span=0x0001 type=LITE count=01 idx=0 stop=0x00E5
# REG-SLAVE=mmdp_data no.slaves=1 len=4 (base=0x9)
BitField 0x000000E4 b[31:0] RW epcs mmdp_data data
# peripheral=remu start=0x00D8 span=0x0007 type=LITE count=01 idx=0 stop=0x00DF
# REG-SLAVE=remu no.slaves=1 len=28 (base=0x0)
BitField 0x000000D8 b[31:0] WO remu remu reconfigure_key
BitField 0x000000D9 b[2:0] WO remu remu param
BitField 0x000000DA b[0:0] WO remu remu read_param
BitField 0x000000DB b[0:0] WO remu remu write_param
BitField 0x000000DC b[23:0] RO remu remu data_out
BitField 0x000000DD b[23:0] WO remu remu data_in
BitField 0x000000DE b[0:0] RO remu remu busy
# peripheral=sens start=0x0080 span=0x0006 type=LITE count=01 idx=0 stop=0x0086
# REG-SLAVE=sens no.slaves=1 len=24 (base=0x0)
BitField 0x00000080 b[7:0] RO sens sens sens_data0
BitField 0x00000081 b[7:0] RO sens sens sens_data1
BitField 0x00000082 b[7:0] RO sens sens sens_data2
BitField 0x00000083 b[7:0] RO sens sens sens_data3
BitField 0x00000084 b[0:0] RO sens sens sens_err
BitField 0x00000085 b[6:0] RW sens sens temp_high
......@@ -67,6 +67,7 @@ bool importdatfile(ifstream& ifs, list<class NODE_config>& N)
ss >> nc.gn;
ss >> nc.ipaddr;
ss >> nc.firmware;
ss >> nc.version;
if (!(ss.fail() || ss.bad())) {
N.push_back(nc);
}
......
# Configuration file for sdpunb
# the following nodes are contributing
# NODE config:
# gn ipaddr expected firmware expected version
node 0 10.99.1.1 unb2b_minimal 2
#node 1 10.99.1.2 unb2b_minimal 2
#node 2 10.99.1.3 unb2b_minimal 2
#node 3 10.99.1.4 unb2b_minimal 2
# Configuration file for sdpunb
# the following nodes are contributing
# NODE config:
# gn ipaddr expected firmware
node 3 10.99.1.4 unb2b_minimal
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