author | Florian Pose <fp@igh-essen.com> |
Mon, 26 Jan 2009 10:30:17 +0000 | |
changeset 1323 | 10fbef0a3ac5 |
parent 1167 | 9e0ebb38e301 |
child 1363 | 11c0b2caa253 |
permissions | -rw-r--r-- |
1142 | 1 |
/***************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
5 |
****************************************************************************/ |
|
6 |
||
7 |
#include <iostream> |
|
8 |
using namespace std; |
|
9 |
||
10 |
#include "CommandData.h" |
|
11 |
||
12 |
/*****************************************************************************/ |
|
13 |
||
14 |
CommandData::CommandData(): |
|
15 |
Command("data", "Output binary domain process data.") |
|
16 |
{ |
|
17 |
} |
|
18 |
||
19 |
/*****************************************************************************/ |
|
20 |
||
21 |
string CommandData::helpString() const |
|
22 |
{ |
|
23 |
stringstream str; |
|
24 |
||
25 |
str << getName() << " [OPTIONS]" << endl |
|
26 |
<< endl |
|
27 |
<< getBriefDescription() << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
28 |
<< endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
29 |
<< "Data of multiple domains are concatenated." << endl |
1142 | 30 |
<< endl |
31 |
<< "Command-specific options:" << endl |
|
1167 | 32 |
<< " --domain -d <index> Positive numerical domain index." << endl |
33 |
<< " If omitted, data of all domains" << endl |
|
34 |
<< " are output." << endl |
|
1142 | 35 |
<< endl |
36 |
<< numericInfo(); |
|
37 |
||
38 |
return str.str(); |
|
39 |
} |
|
40 |
||
41 |
/****************************************************************************/ |
|
42 |
||
43 |
void CommandData::execute(MasterDevice &m, const StringVector &args) |
|
44 |
{ |
|
1166 | 45 |
DomainList domains; |
46 |
DomainList::const_iterator di; |
|
47 |
||
1142 | 48 |
m.open(MasterDevice::Read); |
1166 | 49 |
domains = selectedDomains(m); |
1142 | 50 |
|
1166 | 51 |
for (di = domains.begin(); di != domains.end(); di++) { |
52 |
outputDomainData(m, *di); |
|
53 |
} |
|
1142 | 54 |
} |
55 |
||
56 |
/****************************************************************************/ |
|
57 |
||
1166 | 58 |
void CommandData::outputDomainData( |
59 |
MasterDevice &m, |
|
60 |
const ec_ioctl_domain_t &domain |
|
61 |
) |
|
1142 | 62 |
{ |
63 |
ec_ioctl_domain_data_t data; |
|
64 |
unsigned char *processData; |
|
65 |
unsigned int i; |
|
66 |
||
67 |
if (!domain.data_size) |
|
68 |
return; |
|
69 |
||
70 |
processData = new unsigned char[domain.data_size]; |
|
71 |
||
72 |
try { |
|
1166 | 73 |
m.getData(&data, domain.index, domain.data_size, processData); |
1142 | 74 |
} catch (MasterDeviceException &e) { |
75 |
delete [] processData; |
|
76 |
throw e; |
|
77 |
} |
|
78 |
||
79 |
for (i = 0; i < data.data_size; i++) |
|
80 |
cout << processData[i]; |
|
81 |
cout.flush(); |
|
82 |
||
83 |
delete [] processData; |
|
84 |
} |
|
85 |
||
86 |
/****************************************************************************/ |