equal
deleted
inserted
replaced
1 /***************************************************************************** |
1 /***************************************************************************** |
2 * |
2 * |
3 * $Id:$ |
3 * $Id$ |
4 * |
4 * |
5 ****************************************************************************/ |
5 ****************************************************************************/ |
6 |
6 |
7 #include <iostream> |
7 #include <iostream> |
8 #include <iomanip> |
8 #include <iomanip> |
9 using namespace std; |
9 using namespace std; |
10 |
10 |
11 #include "CommandFoeRead.h" |
11 #include "CommandFoeRead.h" |
12 #include "byteorder.h" |
12 #include "byteorder.h" |
|
13 #include "foe.h" |
13 |
14 |
14 /*****************************************************************************/ |
15 /*****************************************************************************/ |
15 |
16 |
16 CommandFoeRead::CommandFoeRead(): |
17 CommandFoeRead::CommandFoeRead(): |
17 FoeCommand("foe_read", "Read a file from a slave via FoE.") |
18 FoeCommand("foe_read", "Read a file from a slave via FoE.") |
81 |
82 |
82 try { |
83 try { |
83 m.readFoe(&data); |
84 m.readFoe(&data); |
84 } catch (MasterDeviceException &e) { |
85 } catch (MasterDeviceException &e) { |
85 delete [] data.buffer; |
86 delete [] data.buffer; |
86 throw e; |
87 if (data.result) { |
|
88 if (data.result == FOE_OPCODE_ERROR) { |
|
89 err << "FoE read aborted with error code 0x" |
|
90 << setw(8) << setfill('0') << hex << data.error_code |
|
91 << ": " << errorText(data.error_code); |
|
92 } else { |
|
93 err << "Failed to write via FoE: " |
|
94 << resultText(data.result); |
|
95 } |
|
96 throwCommandException(err); |
|
97 } else { |
|
98 throw e; |
|
99 } |
87 } |
100 } |
88 |
101 |
89 // TODO --output-file |
102 // TODO --output-file |
90 for (i = 0; i < data.data_size; i++) { |
103 for (i = 0; i < data.data_size; i++) { |
91 uint8_t *w = data.buffer + i; |
104 uint8_t *w = data.buffer + i; |