summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--ao-make-product.5c26
-rw-r--r--ao.h3
-rw-r--r--ao_cmd.c10
-rw-r--r--ao_product.c9
5 files changed, 47 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index a570be7b..ab72b413 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,8 @@
#
CC=sdcc
+VERSION=$(shell git describe)
+
CFLAGS=--model-small --debug --opt-code-speed
LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
@@ -238,21 +240,22 @@ ao_product-tidongle-$(SERIAL).rel: ao_product.c $(TIDONGLE_DEFS)
$(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TIDONGLE_DEFS)\"' -o$@ ao_product.c
$(TELEMETRUM_DEFS): ao-make-product.5c
- nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -s $(SERIAL) > $@
+ nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -s $(SERIAL) -v $(VERSION) > $@
$(TELETERRA_DEFS): ao-make-product.5c
- nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -s $(SERIAL) > $@
+ nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -s $(SERIAL) -v $(VERSION) > $@
$(TELEDONGLE_DEFS): ao-make-product.5c
- nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -s $(SERIAL) > $@
+ nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -s $(SERIAL) -v $(VERSION) > $@
$(TIDONGLE_DEFS): ao-make-product.5c
- nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -s $(SERIAL) > $@
+ nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -s $(SERIAL) -v $(VERSION) > $@
clean:
rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
rm -f $(PROGS) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
rm -f $(ALL_DEFS) $(HOST_PROGS)
+ rm -f $(TELEMETRUM_DEFS) $(TELETERRA_DEFS) $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
install:
diff --git a/ao-make-product.5c b/ao-make-product.5c
index 4f5bcba9..933032dd 100644
--- a/ao-make-product.5c
+++ b/ao-make-product.5c
@@ -3,13 +3,14 @@
autoimport ParseArgs;
void
-write_string(string a, string description)
+write_ucs2(string a, string description)
{
int len = String::length(a);
printf("/* %s */\n", description);
printf("#define AO_%s_LEN 0x%02x\n", description, len * 2 + 2);
- printf("#define AO_%s_STRING", description);
+ printf("#define AO_%s_STRING \"%s\"\n", description, a);
+ printf("#define AO_%s_UCS2", description);
for (int i = 0; i < len; i++) {
int c = a[i];
if (i > 0)
@@ -23,6 +24,13 @@ write_string(string a, string description)
}
void
+write_string(string a, string description)
+{
+ printf ("/* %s */\n", description);
+ printf ("#define AO_%s_STRING \"%s\"\n", description, a);
+}
+
+void
write_int(int a, string description)
{
printf ("/* %s */\n", description);
@@ -31,6 +39,7 @@ write_int(int a, string description)
string manufacturer = "altusmetrum.org";
string product = "TeleMetrum";
+string version = "0.0";
int serial = 1;
int user_argind = 0;
@@ -54,6 +63,12 @@ argdesc argd = {
.name = "serial",
.expr_name = "number",
.desc = "Serial number." },
+ {
+ .var = { .arg_string = &version },
+ .abbr = 'v',
+ .name = "version",
+ .expr_name = "string",
+ .desc = "Program version." },
},
.prog_name = "usb descriptors",
};
@@ -63,10 +78,11 @@ main()
{
string[dim(argv)-1] nargv = {[n] = argv[n+1]};
parseargs(&argd, &nargv);
- write_string(manufacturer, "iManufacturer");
- write_string(product, "iProduct");
- write_string(sprintf("%06d", serial), "iSerial");
+ write_ucs2(manufacturer, "iManufacturer");
+ write_ucs2(product, "iProduct");
+ write_ucs2(sprintf("%06d", serial), "iSerial");
write_int(serial, "iSerial");
+ write_string(version, "iVersion");
}
main();
diff --git a/ao.h b/ao.h
index 12948ed3..aa7163fc 100644
--- a/ao.h
+++ b/ao.h
@@ -841,5 +841,8 @@ ao_config_init(void);
extern const uint8_t ao_usb_descriptors [];
extern const uint16_t ao_serial_number;
+extern const char ao_version[];
+extern const char ao_manufacturer[];
+extern const char ao_product[];
#endif /* _AO_H_ */
diff --git a/ao_cmd.c b/ao_cmd.c
index f0459a73..827545d0 100644
--- a/ao_cmd.c
+++ b/ao_cmd.c
@@ -212,6 +212,15 @@ echo(void)
lex_echo = ao_cmd_lex_i != 0;
}
+static void
+version(void)
+{
+ printf("manufacturer %s\n", ao_manufacturer);
+ printf("product %s\n", ao_product);
+ printf("serial-number %u\n", ao_serial_number);
+ printf("software-version %s\n", ao_version);
+}
+
static const char help_txt[] = "All numbers are in hex";
#define NUM_CMDS 11
@@ -297,6 +306,7 @@ __code struct ao_cmds ao_base_cmds[] = {
{ 'T', ao_task_info, "T Show task states" },
{ 'E', echo, "E <0 off, 1 on> Set command echo mode" },
{ 'd', dump, "d <start> <end> Dump memory" },
+ { 'v', version, "v Show version" },
{ 0, help, NULL },
};
diff --git a/ao_product.c b/ao_product.c
index b743e9f0..b42e62c0 100644
--- a/ao_product.c
+++ b/ao_product.c
@@ -22,6 +22,9 @@
/* Defines which mark this particular AltOS product */
const uint16_t ao_serial_number = AO_iSerial_NUMBER;
+const char ao_version[] = AO_iVersion_STRING;
+const char ao_manufacturer[] = AO_iManufacturer_STRING;
+const char ao_product[] = AO_iProduct_STRING;
#define LE_WORD(x) ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
@@ -134,17 +137,17 @@ const uint8_t ao_usb_descriptors [] =
/* iManufacturer */
AO_iManufacturer_LEN,
AO_USB_DESC_STRING,
- AO_iManufacturer_STRING,
+ AO_iManufacturer_UCS2,
/* iProduct */
AO_iProduct_LEN,
AO_USB_DESC_STRING,
- AO_iProduct_STRING,
+ AO_iProduct_UCS2,
/* iSerial */
AO_iSerial_LEN,
AO_USB_DESC_STRING,
- AO_iSerial_STRING,
+ AO_iSerial_UCS2,
/* Terminating zero */
0