author | Florian Pose <fp@igh-essen.com> |
Fri, 25 Jul 2008 14:10:04 +0000 | |
changeset 1149 | f1fce286d53b |
parent 1144 | 7dbfdd61812c |
child 1166 | 006244d53f68 |
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 |
|
32 |
<< " --domain -d <index> Positive numerical domain index, or" << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
33 |
<< " 'all' for all domains (default)." << endl |
1142 | 34 |
<< endl |
35 |
<< numericInfo(); |
|
36 |
||
37 |
return str.str(); |
|
38 |
} |
|
39 |
||
40 |
/****************************************************************************/ |
|
41 |
||
42 |
void CommandData::execute(MasterDevice &m, const StringVector &args) |
|
43 |
{ |
|
44 |
m.open(MasterDevice::Read); |
|
45 |
||
46 |
if (domainIndex == -1) { |
|
47 |
unsigned int i; |
|
48 |
ec_ioctl_master_t master; |
|
49 |
||
50 |
m.getMaster(&master); |
|
51 |
||
52 |
for (i = 0; i < master.domain_count; i++) { |
|
53 |
outputDomainData(m, i); |
|
54 |
} |
|
55 |
} else { |
|
56 |
outputDomainData(m, domainIndex); |
|
57 |
} |
|
58 |
} |
|
59 |
||
60 |
/****************************************************************************/ |
|
61 |
||
62 |
void CommandData::outputDomainData(MasterDevice &m, unsigned int domainIndex) |
|
63 |
{ |
|
64 |
ec_ioctl_domain_t domain; |
|
65 |
ec_ioctl_domain_data_t data; |
|
66 |
unsigned char *processData; |
|
67 |
unsigned int i; |
|
68 |
||
69 |
m.getDomain(&domain, domainIndex); |
|
70 |
||
71 |
if (!domain.data_size) |
|
72 |
return; |
|
73 |
||
74 |
processData = new unsigned char[domain.data_size]; |
|
75 |
||
76 |
try { |
|
77 |
m.getData(&data, domainIndex, domain.data_size, processData); |
|
78 |
} catch (MasterDeviceException &e) { |
|
79 |
delete [] processData; |
|
80 |
throw e; |
|
81 |
} |
|
82 |
||
83 |
for (i = 0; i < data.data_size; i++) |
|
84 |
cout << processData[i]; |
|
85 |
cout.flush(); |
|
86 |
||
87 |
delete [] processData; |
|
88 |
} |
|
89 |
||
90 |
/****************************************************************************/ |