solved some TODOs, check hex input and message length, simplified SymbolString ctors, fixed extra newline in scan result, no longer include write messages in default find command types, append command type to find result in verbose mode, add source and/or destination to update log when not set in the message definition, documentation

This commit is contained in:
john30
2015-02-15 12:20:06 +01:00
parent 2de793784e
commit 71d8727d2d
9 changed files with 177 additions and 136 deletions
+23 -5
View File
@@ -215,8 +215,18 @@ int main()
string check[5] = checks[i];
istringstream isstr(check[0]);
string expectStr = check[1];
SymbolString mstr(check[2], false);
SymbolString sstr(check[3], false);
SymbolString mstr(false);
result_t result = mstr.parseHex(check[2]);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": parse \"" << check[2] << "\" error: " << getResultCode(result) << endl;
continue;
}
SymbolString sstr(false);
result = sstr.parseHex(check[3]);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": parse \"" << check[3] << "\" error: " << getResultCode(result) << endl;
continue;
}
string flags = check[4];
bool isSet = flags.find('s') != string::npos;
bool failedCreate = flags.find('c') != string::npos;
@@ -237,7 +247,7 @@ int main()
fields = NULL;
}
vector<string>::iterator it = entries.begin();
result_t result = DataField::create(it, entries.end(), templates, fields, isSet, isTemplate ? SYN : mstr[1]);
result = DataField::create(it, entries.end(), templates, fields, isSet, isTemplate ? SYN : mstr[1]);
if (failedCreate == true) {
if (result == RESULT_OK)
cout << "\"" << check[0] << "\": failed create error: unexpectedly succeeded" << endl;
@@ -272,8 +282,16 @@ int main()
}
ostringstream output;
SymbolString writeMstr(mstr.getDataStr().substr(0, 10), false);
SymbolString writeSstr(sstr.getDataStr().substr(0, 2), false);
SymbolString writeMstr(false);
result = writeMstr.parseHex(mstr.getDataStr().substr(0, 10));
if (result != RESULT_OK) {
cout << " parse \"" << mstr.getDataStr().substr(0, 10) << "\" error: " << getResultCode(result) << endl;
}
SymbolString writeSstr(false);
result = writeSstr.parseHex(sstr.getDataStr().substr(0, 2));
if (result != RESULT_OK) {
cout << " parse \"" << sstr.getDataStr().substr(0, 2) << "\" error: " << getResultCode(result) << endl;
}
result = fields->read(pt_masterData, mstr, 0, output, false, verbose);
if (result >= RESULT_OK) {
result = fields->read(pt_slaveData, sstr, 0, output, output.str().empty() == false, verbose);
+12 -3
View File
@@ -74,8 +74,18 @@ int main()
string check[5] = checks[i];
istringstream isstr(check[0]);
string inputStr = check[1];
SymbolString mstr(check[2]);
SymbolString sstr(check[3]);
SymbolString mstr(true);
result_t result = mstr.parseHex(check[2]);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": parse \"" << check[2] << "\" error: " << getResultCode(result) << endl;
continue;
}
SymbolString sstr(true);
result = sstr.parseHex(check[3]);
if (result != RESULT_OK) {
cout << "\"" << check[0] << "\": parse \"" << check[3] << "\" error: " << getResultCode(result) << endl;
continue;
}
string flags = check[4];
bool isTemplate = flags == "t";
bool dontMap = flags.find('m') != string::npos;
@@ -94,7 +104,6 @@ int main()
delete deleteMessage;
deleteMessage = NULL;
}
result_t result;
if (isTemplate == true) {
// store new template
DataField* fields = NULL;
+13 -6
View File
@@ -25,14 +25,18 @@ using namespace std;
int main ()
{
SymbolString sstr("10feb5050427a915aa");
SymbolString sstr(true);
result_t result = sstr.parseHex("10feb5050427a915aa", false);
if (result != RESULT_OK)
std::cout << "parse escaped error: " << getResultCode(result) << std::endl;
std::string gotStr = sstr.getDataStr(false), expectStr = "10feb5050427a90015a90177";
if (strcasecmp(gotStr.c_str(), expectStr.c_str()) == 0)
std::cout << "ctor escaped OK" << std::endl;
std::cout << "parse escaped OK" << std::endl;
else
std::cout << "ctor escaped error: got " << gotStr << ", expected "
std::cout << "parse escaped error: got " << gotStr << ", expected "
<< expectStr << std::endl;
unsigned char gotCrc = sstr.getCRC(), expectCrc = 0x77;
@@ -55,14 +59,17 @@ int main ()
std::cout << "unescape error: got " << gotStr << ", expected "
<< expectStr << std::endl;
sstr = SymbolString("10feb5050427a90015a90177", true);
sstr = SymbolString(false);
result = sstr.parseHex("10feb5050427a90015a90177", true);
if (result != RESULT_OK)
std::cout << "parse unescaped error: " << getResultCode(result) << std::endl;
gotStr = sstr.getDataStr();
if (strcasecmp(gotStr.c_str(), expectStr.c_str()) == 0)
std::cout << "ctor unescaped OK" << std::endl;
std::cout << "parse unescaped OK" << std::endl;
else
std::cout << "ctor unescaped error: got " << gotStr << ", expected "
std::cout << "parse unescaped error: got " << gotStr << ", expected "
<< expectStr << std::endl;
return 0;