* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
+#include <unistd.h>
+#include <getopt.h>
#include "ccdbg.h"
+static const struct option options[] = {
+ { .name = "tty", .has_arg = 1, .val = 'T' },
+ { .name = "device", .has_arg = 1, .val = 'D' },
+ { 0, 0, 0, 0},
+};
+
+static void usage(char *program)
+{
+ fprintf(stderr, "usage: %s [--tty <tty-name>] [--device <device-name>] file.ihx\n", program);
+ exit(1);
+}
+
int
main (int argc, char **argv)
{
uint16_t pc;
struct hex_file *hex;
struct hex_image *image;
- char *filename;
- FILE *file;
+ char *filename;
+ FILE *file;
+ char *tty = NULL;
+ char *device = NULL;
+ int c;
- filename = argv[1];
+ while ((c = getopt_long(argc, argv, "T:D:", options, NULL)) != -1) {
+ switch (c) {
+ case 'T':
+ tty = optarg;
+ break;
+ case 'D':
+ device = optarg;
+ break;
+ default:
+ usage(argv[0]);
+ break;
+ }
+ }
+ filename = argv[optind];
if (filename == NULL) {
fprintf(stderr, "usage: %s <filename.ihx>\n", argv[0]);
exit(1);
}
ccdbg_hex_file_free(hex);
- dbg = ccdbg_open();
+ if (!tty)
+ tty = cc_usbdevs_find_by_arg(device, "TIDongle");
+ dbg = ccdbg_open(tty);
if (!dbg)
exit (1);