add rxloss to examples

pull/68/head
Jeffery Weston 2022-05-03 14:21:11 -04:00
parent b997771fec
commit 8c9f0951ff
3 changed files with 49 additions and 8 deletions

View File

@ -183,6 +183,9 @@ class NormCaster
void SetTxLoss(double txloss)
{NormSetTxLoss(norm_session, txloss);}
void SetRxLoss(double rxloss)
{NormSetRxLoss(norm_session, rxloss);}
private:
bool is_running;
NormSessionHandle norm_session;
@ -808,12 +811,12 @@ void Usage()
" [repeat <interval> [updatesOnly]] [id <nodeIdInteger>]\n"
" [addr <addr>[/<port>]] [interface <name>] [loopback]\n"
" [ack auto|<node1>[,<node2>,...]] [segment <bytes>]\n"
" [block <count>] [parity <count>] [auto <count>]\n"
" [cc|cce|ccl|rate <bitsPerSecond>] [ptos <value>]\n"
" [block <count>] [parity <count>] [auto <count>] [ptos <value>]\n"
" [cc|cce|ccl|rate <bitsPerSecond>] [rxloss <lossFraction>]\n"
" [flush {none|passive|active}] [silent] [txloss <lossFraction>]\n"
" [processor <processorCmdLine>] [saveaborts]\n"
" [buffer <bytes>] [txsockbuffer <bytes>] [rxsockbuffer <bytes>]\n"
" [debug <level>] [trace] [log <logfile>]\n"
" [processor <processorCmdLine>] [saveaborts]\n");
" [debug <level>] [trace] [log <logfile>]\n");
} // end Usage()
int main(int argc, char* argv[])
@ -844,6 +847,7 @@ int main(int argc, char* argv[])
bool trace = false;
bool silentReceiver = false;
double txloss = 0.0;
double rxloss = 0.0;
bool loopback = false;
NormCaster normCast;
@ -1209,6 +1213,15 @@ int main(int argc, char* argv[])
return -1;
}
}
else if (0 == strncmp(cmd, "rxloss", len))
{
if (1 != sscanf(argv[i++], "%lf", &rxloss))
{
fprintf(stderr, "normCast error: invalid 'rxloss' value!\n");
Usage();
return -1;
}
}
else if (0 == strncmp(cmd, "debug", len))
{
if (i >= argc)
@ -1308,6 +1321,7 @@ int main(int argc, char* argv[])
if (silentReceiver) normCast.SetSilentReceiver(true);
if (txloss > 0.0) normCast.SetTxLoss(txloss);
if (rxloss > 0.0) normCast.SetRxLoss(rxloss);
if (autoAck)

View File

@ -202,6 +202,8 @@ class NormMsgr
{NormSetSilentReceiver(norm_session, state);}
void SetTxLoss(double txloss)
{NormSetTxLoss(norm_session, txloss);}
void SetRxLoss(double rxloss)
{NormSetRxLoss(norm_session, rxloss);}
private:
bool is_running;
@ -783,7 +785,8 @@ void Usage()
" [ack auto|<node1>[,<node2>,...]] [output <outFile>]\n"
" [cc|cce|ccl|rate <bitsPerSecond>] [interface <name>] [loopback]\n"
" [debug <level>] [trace] [log <logfile>] [silent]\n"
" [flush {none|passive|active}] [omit] [txloss <lossFraction>]\n");
" [flush {none|passive|active}] [omit] [txloss <lossFraction>]\n"
" [rxloss <lossFraction>]\n");
}
int main(int argc, char* argv[])
{
@ -811,6 +814,7 @@ int main(int argc, char* argv[])
bool omitHeaderOnOutput = false;
bool silentReceiver = false;
double txloss = 0.0;
double rxloss = 0.0;
bool loopback = false;
NormMsgr normMsgr;
@ -1003,6 +1007,15 @@ int main(int argc, char* argv[])
return -1;
}
}
else if (0 == strncmp(cmd, "rxloss", len))
{
if (1 != sscanf(argv[i++], "%lf", &rxloss))
{
fprintf(stderr, "nodeMsgr error: invalid 'rxloss' value!\n");
Usage();
return -1;
}
}
else if (0 == strncmp(cmd, "debug", len))
{
if (i >= argc)
@ -1073,6 +1086,7 @@ int main(int argc, char* argv[])
if (silentReceiver) normMsgr.SetSilentReceiver(true);
if (txloss > 0.0) normMsgr.SetTxLoss(txloss);
if (rxloss > 0.0) normMsgr.SetRxLoss(rxloss);
if (autoAck)
{

View File

@ -256,6 +256,8 @@ class NormStreamer
{NormSetSilentReceiver(norm_session, state);}
void SetTxLoss(double txloss)
{NormSetTxLoss(norm_session, txloss);}
void SetRxLoss(double rxloss)
{NormSetRxLoss(norm_session, rxloss);}
// Set the scheduler for running the app and norm threads.
static bool BoostPriority();
@ -1353,8 +1355,8 @@ void Usage()
" [insockbuffer <bytes>] [outsockbuffer <bytes>]\n"
" [txsockbuffer <bytes>] [rxsockbuffer <bytes>]\n"
" [streambuffer <bytes>]\n"
" [check64 | check32]\n"
" [omit] [silent] [txloss <lossFraction>]\n");
" [check64 | check32] [omit] [silent]\n"
" [txloss <lossFraction>] [rxloss <lossFraction>]\n");
} // end Usage()
void PrintHelp()
@ -1437,6 +1439,7 @@ int main(int argc, char* argv[])
bool omitHeaderOnOutput = false;
bool silentReceiver = false;
double txloss = 0.0;
double rxloss = 0.0;
bool boostPriority = false;
unsigned int checkSequence = 0; // can set to 64 or 32
// TBD - set these defaults to reasonable values or just use NormStreamer constructor defaults
@ -1955,6 +1958,15 @@ int main(int argc, char* argv[])
return -1;
}
}
else if (0 == strncmp(cmd, "rxloss", len))
{
if (1 != sscanf(argv[i++], "%lf", &rxloss))
{
fprintf(stderr, "normStreamer error: invalid 'rxloss' value!\n");
Usage();
return -1;
}
}
else if (0 == strncmp(cmd, "debug", len))
{
if (i >= argc)
@ -2069,6 +2081,7 @@ int main(int argc, char* argv[])
if (silentReceiver) normStreamer.SetSilentReceiver(true);
if (txloss > 0.0) normStreamer.SetTxLoss(txloss);
if (rxloss > 0.0) normStreamer.SetRxLoss(rxloss);
for (unsigned int i = 0; i < ackingNodeCount; i++)
normStreamer.AddAckingNode(ackingNodeList[i]);