diff options
Diffstat (limited to 'utils/hwstub/tools')
-rw-r--r-- | utils/hwstub/tools/hwstub_load.cpp | 13 | ||||
-rw-r--r-- | utils/hwstub/tools/hwstub_shell.cpp | 12 |
2 files changed, 21 insertions, 4 deletions
diff --git a/utils/hwstub/tools/hwstub_load.cpp b/utils/hwstub/tools/hwstub_load.cpp index 87737939c3..6ca6079294 100644 --- a/utils/hwstub/tools/hwstub_load.cpp +++ b/utils/hwstub/tools/hwstub_load.cpp | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <getopt.h> | 24 | #include <getopt.h> |
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include <ctype.h> | 26 | #include <ctype.h> |
27 | #include <iostream> | ||
27 | #include "hwstub.hpp" | 28 | #include "hwstub.hpp" |
28 | #include "hwstub_uri.hpp" | 29 | #include "hwstub_uri.hpp" |
29 | 30 | ||
@@ -111,6 +112,7 @@ void usage(void) | |||
111 | printf(" --quiet/-q Quiet output\n"); | 112 | printf(" --quiet/-q Quiet output\n"); |
112 | printf(" --type/-t <t> Override file type\n"); | 113 | printf(" --type/-t <t> Override file type\n"); |
113 | printf(" --dev/-d <uri> Device URI (see below)\n"); | 114 | printf(" --dev/-d <uri> Device URI (see below)\n"); |
115 | printf(" --verbose/-v Display debug output\n"); | ||
114 | printf("file types:\n"); | 116 | printf("file types:\n"); |
115 | printf(" raw Load a raw binary blob\n"); | 117 | printf(" raw Load a raw binary blob\n"); |
116 | printf(" rockbox Load a rockbox image produced by scramble\n"); | 118 | printf(" rockbox Load a rockbox image produced by scramble\n"); |
@@ -128,6 +130,7 @@ int main(int argc, char **argv) | |||
128 | bool quiet = false; | 130 | bool quiet = false; |
129 | enum image_type_t type = IT_DETECT; | 131 | enum image_type_t type = IT_DETECT; |
130 | const char *uri = "usb:"; | 132 | const char *uri = "usb:"; |
133 | bool verbose = false; | ||
131 | 134 | ||
132 | // parse command line | 135 | // parse command line |
133 | while(1) | 136 | while(1) |
@@ -138,10 +141,11 @@ int main(int argc, char **argv) | |||
138 | {"quiet", no_argument, 0, 'q'}, | 141 | {"quiet", no_argument, 0, 'q'}, |
139 | {"type", required_argument, 0, 't'}, | 142 | {"type", required_argument, 0, 't'}, |
140 | {"dev", required_argument, 0, 'd'}, | 143 | {"dev", required_argument, 0, 'd'}, |
144 | {"verbose", no_argument, 0, 'v'}, | ||
141 | {0, 0, 0, 0} | 145 | {0, 0, 0, 0} |
142 | }; | 146 | }; |
143 | 147 | ||
144 | int c = getopt_long(argc, argv, "?qt:d:", long_options, NULL); | 148 | int c = getopt_long(argc, argv, "?qt:d:v", long_options, NULL); |
145 | if(c == -1) | 149 | if(c == -1) |
146 | break; | 150 | break; |
147 | switch(c) | 151 | switch(c) |
@@ -170,6 +174,9 @@ int main(int argc, char **argv) | |||
170 | case 'd': | 174 | case 'd': |
171 | uri = optarg; | 175 | uri = optarg; |
172 | break; | 176 | break; |
177 | case 'v': | ||
178 | verbose = true; | ||
179 | break; | ||
173 | default: | 180 | default: |
174 | abort(); | 181 | abort(); |
175 | } | 182 | } |
@@ -236,6 +243,8 @@ int main(int argc, char **argv) | |||
236 | printf("Cannot create context: %s\n", errstr.c_str()); | 243 | printf("Cannot create context: %s\n", errstr.c_str()); |
237 | return 1; | 244 | return 1; |
238 | } | 245 | } |
246 | if(verbose) | ||
247 | hwctx->set_debug(std::cout); | ||
239 | std::vector<std::shared_ptr<hwstub::device>> list; | 248 | std::vector<std::shared_ptr<hwstub::device>> list; |
240 | hwstub::error ret = hwctx->get_device_list(list); | 249 | hwstub::error ret = hwctx->get_device_list(list); |
241 | if(ret != hwstub::error::SUCCESS) | 250 | if(ret != hwstub::error::SUCCESS) |
@@ -277,7 +286,7 @@ int main(int argc, char **argv) | |||
277 | char buffer[128]; | 286 | char buffer[128]; |
278 | size_t size = sizeof(buffer) - 1; | 287 | size_t size = sizeof(buffer) - 1; |
279 | hwstub::error err = hwdev->get_log(buffer, size); | 288 | hwstub::error err = hwdev->get_log(buffer, size); |
280 | if(err != hwstub::error::SUCCESS) | 289 | if(err != error::SUCCESS || size == 0) |
281 | break; | 290 | break; |
282 | buffer[size] = 0; | 291 | buffer[size] = 0; |
283 | fprintf(stderr, "%s", buffer); | 292 | fprintf(stderr, "%s", buffer); |
diff --git a/utils/hwstub/tools/hwstub_shell.cpp b/utils/hwstub/tools/hwstub_shell.cpp index 5fb3e13840..b2cf2cec60 100644 --- a/utils/hwstub/tools/hwstub_shell.cpp +++ b/utils/hwstub/tools/hwstub_shell.cpp | |||
@@ -1239,6 +1239,7 @@ void usage(void) | |||
1239 | printf("options:\n"); | 1239 | printf("options:\n"); |
1240 | printf(" --help/-? Display this help\n"); | 1240 | printf(" --help/-? Display this help\n"); |
1241 | printf(" --quiet/-q Quiet non-command messages\n"); | 1241 | printf(" --quiet/-q Quiet non-command messages\n"); |
1242 | printf(" -b/--batch Disable interactive mode after running commands and files\n"); | ||
1242 | printf(" --verbose/-v Verbose output\n"); | 1243 | printf(" --verbose/-v Verbose output\n"); |
1243 | printf(" -i <init> Set lua init file (default is init.lua)\n"); | 1244 | printf(" -i <init> Set lua init file (default is init.lua)\n"); |
1244 | printf(" -e <cmd> Execute <cmd> at startup\n"); | 1245 | printf(" -e <cmd> Execute <cmd> at startup\n"); |
@@ -1293,6 +1294,7 @@ int main(int argc, char **argv) | |||
1293 | { | 1294 | { |
1294 | std::string dev_uri = hwstub::uri::default_uri().full_uri(); | 1295 | std::string dev_uri = hwstub::uri::default_uri().full_uri(); |
1295 | bool verbose = false; | 1296 | bool verbose = false; |
1297 | bool batch = false; | ||
1296 | 1298 | ||
1297 | const char *lua_init = "init.lua"; | 1299 | const char *lua_init = "init.lua"; |
1298 | std::vector< std::pair< exec_type, std::string > > startup_cmds; | 1300 | std::vector< std::pair< exec_type, std::string > > startup_cmds; |
@@ -1309,11 +1311,12 @@ int main(int argc, char **argv) | |||
1309 | {"startfile", required_argument, 0, 'f'}, | 1311 | {"startfile", required_argument, 0, 'f'}, |
1310 | {"dev", required_argument, 0, 'd'}, | 1312 | {"dev", required_argument, 0, 'd'}, |
1311 | {"verbose", no_argument, 0, 'v'}, | 1313 | {"verbose", no_argument, 0, 'v'}, |
1314 | {"batch", no_argument, 0, 'b'}, | ||
1312 | {"debug-rw", no_argument, 0, OPT_DBG_RW}, | 1315 | {"debug-rw", no_argument, 0, OPT_DBG_RW}, |
1313 | {0, 0, 0, 0} | 1316 | {0, 0, 0, 0} |
1314 | }; | 1317 | }; |
1315 | 1318 | ||
1316 | int c = getopt_long(argc, argv, "?qi:e:f:d:v", long_options, NULL); | 1319 | int c = getopt_long(argc, argv, "?qi:e:f:d:vb", long_options, NULL); |
1317 | if(c == -1) | 1320 | if(c == -1) |
1318 | break; | 1321 | break; |
1319 | switch(c) | 1322 | switch(c) |
@@ -1344,6 +1347,9 @@ int main(int argc, char **argv) | |||
1344 | case OPT_DBG_RW: | 1347 | case OPT_DBG_RW: |
1345 | g_print_mem_rw = true; | 1348 | g_print_mem_rw = true; |
1346 | break; | 1349 | break; |
1350 | case 'b': | ||
1351 | batch = true; | ||
1352 | break; | ||
1347 | default: | 1353 | default: |
1348 | abort(); | 1354 | abort(); |
1349 | } | 1355 | } |
@@ -1441,7 +1447,9 @@ int main(int argc, char **argv) | |||
1441 | /* intercept CTRL+C */ | 1447 | /* intercept CTRL+C */ |
1442 | signal(SIGINT, do_signal); | 1448 | signal(SIGINT, do_signal); |
1443 | // start interactive shell | 1449 | // start interactive shell |
1444 | luap_enter(g_lua, &g_exit); | 1450 | if(!batch) |
1451 | luap_enter(g_lua, &g_exit); | ||
1452 | // cleanup | ||
1445 | lua_close(g_lua); | 1453 | lua_close(g_lua); |
1446 | 1454 | ||
1447 | // display log if handled | 1455 | // display log if handled |