diff options
Diffstat (limited to 'ao-tools/ao-eeprom')
| -rw-r--r-- | ao-tools/ao-eeprom/Makefile.am | 2 | ||||
| -rw-r--r-- | ao-tools/ao-eeprom/ao-eeprom.1 | 33 | ||||
| -rw-r--r-- | ao-tools/ao-eeprom/ao-eeprom.c | 33 | 
3 files changed, 66 insertions, 2 deletions
diff --git a/ao-tools/ao-eeprom/Makefile.am b/ao-tools/ao-eeprom/Makefile.am index 587acee7..efeed976 100644 --- a/ao-tools/ao-eeprom/Makefile.am +++ b/ao-tools/ao-eeprom/Makefile.am @@ -8,3 +8,5 @@ ao_eeprom_DEPENDENCIES = $(AO_EEPROM_LIBS)  ao_eeprom_LDADD=$(AO_EEPROM_LIBS) $(LIBUSB_LIBS)  ao_eeprom_SOURCES = ao-eeprom.c + +man_MANS = ao-eeprom.1 diff --git a/ao-tools/ao-eeprom/ao-eeprom.1 b/ao-tools/ao-eeprom/ao-eeprom.1 new file mode 100644 index 00000000..8caff9d1 --- /dev/null +++ b/ao-tools/ao-eeprom/ao-eeprom.1 @@ -0,0 +1,33 @@ +.\" +.\" Copyright © 2009 Keith Packard <keithp@keithp.com> +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, but +.\" WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU +.\" General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License along +.\" with this program; if not, write to the Free Software Foundation, Inc., +.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +.\" +.\" +.TH AO-EEPROM 1 "ao-eeprom" "" +.SH NAME +ao-eeprom \- Fetch eeprom contents from TeleMetrum device +.SH SYNOPSIS +.B "ao-eeprom" +[\-tty \fItty-device\fP] +.SH DESCRIPTION +.I ao-eeprom +downloads the eeprom contents from a connected TeleMetrum device. +.SH USAGE +.I ao-eeprom +connects to the specified target device and dumps each block of the +eeprom to stdout in hexidecimal bytes. +.SH AUTHOR +Keith Packard diff --git a/ao-tools/ao-eeprom/ao-eeprom.c b/ao-tools/ao-eeprom/ao-eeprom.c index 399732d9..726cc22c 100644 --- a/ao-tools/ao-eeprom/ao-eeprom.c +++ b/ao-tools/ao-eeprom/ao-eeprom.c @@ -18,10 +18,23 @@  #include <stdio.h>  #include <stdlib.h> +#include <unistd.h> +#include <getopt.h>  #include "cc-usb.h"  #define NUM_BLOCK	512 +static const struct option options[] = { +	{ .name = "tty", .has_arg = 1, .val = 'T' }, +	{ 0, 0, 0, 0}, +}; + +static void usage(char *program) +{ +	fprintf(stderr, "usage: %s [--tty <tty-name>]\n", program); +	exit(1); +} +  int  main (int argc, char **argv)  { @@ -31,10 +44,26 @@ main (int argc, char **argv)  	uint8_t		*b;  	int		i, j;  	uint32_t	addr; -	char		*tty; +	char		*tty = NULL; +	int		c; -	tty = getenv("CCDBG_TTY"); +	while ((c = getopt_long(argc, argv, "T:", options, NULL)) != -1) { +		switch (c) { +		case 'T': +			tty = optarg; +			break; +		default: +			usage(argv[0]); +			break; +		} +	} +	if (!tty) +		tty = getenv("ALTOS_TTY"); +	if (!tty) +		tty="/dev/ttyACM0";  	cc = cc_usb_open(tty); +	if (!cc) +		exit(1);  	for (block = 0; block < NUM_BLOCK; block++) {  		cc_queue_read(cc, bytes, sizeof (bytes));  		cc_usb_printf(cc, "e %x\n", block);  | 
