added FIELD.N to 'read' command for retrieving N'th FIELD, fixed getMasterNumber(), check maximum NN in message, use more constants, check all type conversions, added --nodevicecheck to ebusfeed help

This commit is contained in:
john30
2015-02-22 13:57:37 +01:00
parent 564a602eaf
commit d50b3b6cb2
17 changed files with 172 additions and 130 deletions
+5 -5
View File
@@ -37,7 +37,7 @@ using namespace std;
struct options
{
const char* device; //!< device to write to [/dev/ttyUSB60]
int time; //!< delay between bytes in us [10000]
unsigned int time; //!< delay between bytes in us [10000]
const char* dumpFile; //!< dump file to read
};
@@ -67,7 +67,7 @@ static const char argpdoc[] =
" 2. create symbol links to appropriate devices, e.g.\n"
" 'ln -s /dev/pts/2 /dev/ttyUSB60'\n"
" 'ln -s /dev/pts/3 /dev/ttyUSB20'\n"
" 3. start "PACKAGE": '"PACKAGE" -f -d /dev/ttyUSB20'\n"
" 3. start "PACKAGE": '"PACKAGE" -f -d /dev/ttyUSB20 --nodevicecheck'\n"
" 4. start ebusfeed: 'ebusfeed /path/to/ebus_dump.bin'\n";
/** the description of the accepted arguments. */
@@ -101,7 +101,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state)
opt->device = arg;
break;
case 't': // --time=10000
opt->time = strtol(arg, &strEnd, 10);
opt->time = (unsigned int)strtoul(arg, &strEnd, 10);
if (strEnd == NULL || *strEnd != 0 || opt->time < 1000 || opt->time > 100000000) {
argp_error(state, "invalid time");
return EINVAL;
@@ -131,7 +131,7 @@ int main(int argc, char* argv[])
if (argp_parse(&argp, argc, argv, ARGP_IN_ORDER, NULL, &opt) != 0)
return EINVAL;
Device* device = Device::create(opt.device, true, NULL);
Device* device = Device::create(opt.device, false, NULL);
if (device == NULL) {
cout << "unable to create device " << opt.device << endl;
return EINVAL;
@@ -150,7 +150,7 @@ int main(int argc, char* argv[])
if (file.is_open()) {
while (true) {
unsigned char byte = file.get();
unsigned char byte = (unsigned char)file.get();
if (file.eof())
break;
cout << hex << setw(2) << setfill('0')