3.10.2013 - PIPeer release, PIConsole now can work as server and remote client. Remote console test program in directory "remote_console"

This commit is contained in:
peri4
2013-10-03 16:04:02 +04:00
parent 9111640ca8
commit 4b90f2818e
56 changed files with 6422 additions and 673 deletions

View File

@@ -26,7 +26,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
PIObject::setName(name);
PIConfig conf(config, PIIODevice::ReadOnly);
if (!conf.isOpened()) {
piCout << "[PIProtocol \"" << name << "\"] Can`t open \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Can`t open \"" << config << "\"!";
devReceiverState = devSenderState = "Config error";
return;
}
@@ -41,7 +41,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
/// receiver section
if (rb.isEntryExists("ip") && rb.isEntryExists("device")) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receiver type in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receiver type in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -50,7 +50,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) dev = gdev;
if (gok && ok && (dev != gdev)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receiver type in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receiver type in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -59,7 +59,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) ps = gps;
if (gok && ok && (ps != gps)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receive port in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receive port in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -74,7 +74,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) flag = gflag;
if (gok && ok && (flag != gflag)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectEnabled\" flag in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectEnabled\" flag in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -85,18 +85,18 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) freq = gfreq;
if (gok && ok && (freq != gfreq)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectTimeout\" value in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectTimeout\" value in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
eth->setReopenTimeout(freq * 1000);
}
if (recDataPtr == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null receive data pointer!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null receive data pointer!";
if (recDataSize == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null receive data size!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null receive data size!";
} else {
piCout << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".receiver.port\" or \"" << name << ".port\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".receiver.port\" or \"" << name << ".port\" in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -106,7 +106,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) dev = gdev;
if (gok && ok && (dev != gdev)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receiver type in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receiver type in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -115,7 +115,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) ps = gps;
if (gok && ok && (ps != gps)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receive \"speed\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receive \"speed\" in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -124,7 +124,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) flag = gflag;
if (gok && ok && (flag != gflag)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receive \"parity\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receive \"parity\" in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -135,7 +135,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) flag = gflag;
if (gok && ok && (flag != gflag)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receive \"twoStopBits\" parity in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receive \"twoStopBits\" parity in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -154,7 +154,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) ps = gps;
if (gok && ok && (ps != gps)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receive \"vtime\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receive \"vtime\" in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -162,11 +162,11 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
}
has_dev = true;
if (recDataPtr == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null receive data pointer!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null receive data pointer!";
if (recDataSize == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null receive data size!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null receive data size!";
} else {
piCout << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".receiver.speed\" or \"" << name << ".speed\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".receiver.speed\" or \"" << name << ".speed\" in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -176,7 +176,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) history_write_rec = ghist;
if (gok && ok && (history_write_rec != ghist)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous receiver history in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous receiver history in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -187,7 +187,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
history_id_rec = rb.getValue("historyID", 0, &ok);
if (!ok) {
history_id_rec = protName.toByteArray().checksumCRC16();
piCout << "[PIProtocol \"" << name << "\"] Warning: no receiver history ID defined, write with ID = " << history_id_rec;
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: no receiver history ID defined, write with ID = " << history_id_rec;
}
history_file_rec.open(history_path_rec, PIIODevice::WriteOnly);
}
@@ -196,21 +196,21 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
gfreq = b.getValue("frequency", -1.f, &gok);
if (gok && !ok) freq = gfreq;
if (gok && ok && (freq != gfreq)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous expected frequency in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous expected frequency in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
if (freq > 0.f && !has_dev)
piCout << "[PIProtocol \"" << name << "\"] Warning: no receiver device and not null expected frequency!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: no receiver device and not null expected frequency!";
float tm = b.getValue("disconnectTimeout", 3.f);
if (tm <= 0.f)
piCout << "[PIProtocol \"" << name << "\"] Warning: diconnect timeout <= 0 s!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: diconnect timeout <= 0 s!";
timeout_ = (tm < 0.f) ? 0.f : tm;
setExpectedFrequency(freq);
/// sender section
if (sb.isEntryExists("ip") && sb.isEntryExists("device")) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous sender type in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous sender type in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -220,7 +220,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) dev = gdev;
if (gok && ok && (dev != gdev)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous sender type in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous sender type in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -229,7 +229,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) ps = gps;
if (gok && ok && (ps != gps)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous send port in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous send port in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -243,7 +243,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) flag = gflag;
if (gok && ok && (flag != gflag)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectEnabled\" flag in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectEnabled\" flag in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
@@ -254,18 +254,18 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) freq = gfreq;
if (gok && ok && (freq != gfreq)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectTimeout\" value in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous \"reconnectTimeout\" value in \"" << config << "\"!";
devReceiverState = "Config error";
return;
}
eth->setReopenTimeout(freq * 1000);
}
if (sendDataPtr_ == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null send data pointer!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null send data pointer!";
if (sendDataSize_ == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null send data size!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null send data size!";
} else {
piCout << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".sender.port\" or \"" << name << ".port\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".sender.port\" or \"" << name << ".port\" in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -275,7 +275,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) dev = gdev;
if (gok && ok && (dev != gdev)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous sender type in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous sender type in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -284,7 +284,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) ps = gps;
if (gok && ok && (ps != gps)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous send \"speed\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous send \"speed\" in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -293,7 +293,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) flag = gflag;
if (gok && ok && (flag != gflag)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous send \"parity\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous send \"parity\" in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -304,14 +304,14 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
if (ok || gok) {
if (gok && !ok) flag = gflag;
if (gok && ok && (flag != gflag)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous send \"twoStopBits\" parity in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous send \"twoStopBits\" parity in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
pp.setFlag(PISerial::TwoStopBits, flag);
}
} else {
piCout << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".sender.speed\" or \"" << name << ".speed\" in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Can`t find \"" << name << ".sender.speed\" or \"" << name << ".speed\" in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -322,16 +322,16 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
ser->setParameters(pp);
has_dev = true;
if (sendDataPtr_ == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null send data pointer!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null send data pointer!";
if (sendDataSize_ == 0)
piCout << "[PIProtocol \"" << name << "\"] Warning: null send data size!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: null send data size!";
}
history_write_send = sb.getValue("writeHistory", false, &ok);
ghist = b.getValue("writeHistory", false, &gok);
if (ok || gok) {
if (gok && !ok) history_write_send = ghist;
if (gok && ok && (history_write_send != ghist)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous sender history in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous sender history in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
@@ -342,7 +342,7 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
history_id_send = sb.getValue("historyID", 0, &ok);
if (!ok) {
history_id_send = protName.toByteArray().checksumCRC16() + 1;
piCout << "[PIProtocol \"" << name << "\"] Warning: no sender history ID defined, write with ID = " << history_id_send;
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: no sender history ID defined, write with ID = " << history_id_send;
}
history_file_send.open(history_path_send, PIIODevice::WriteOnly);
}
@@ -351,12 +351,12 @@ PIProtocol::PIProtocol(const PIString & config, const PIString & name, void * re
gfreq = b.getValue("frequency", -1.f, &gok);
if (gok && !ok) freq = gfreq;
if (gok && ok && (freq != gfreq)) {
piCout << "[PIProtocol \"" << name << "\"] Ambiguous sender frequency in \"" << config << "\"!";
piCoutObj << "[PIProtocol \"" << name << "\"] Ambiguous sender frequency in \"" << config << "\"!";
devSenderState = "Config error";
return;
}
if (freq > 0.f && !has_dev)
piCout << "[PIProtocol \"" << name << "\"] Warning: no sender device and not null send frequency!";
piCoutObj << "[PIProtocol \"" << name << "\"] Warning: no sender device and not null send frequency!";
setSenderFrequency(freq);
headerPtr = (uchar * )recHeaderPtr;