#
CC=sdcc
+VERSION=$(shell git describe)
+
CFLAGS=--model-small --debug --opt-code-speed
LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
$(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:
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)
printf("\n\n");
}
+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)
{
string manufacturer = "altusmetrum.org";
string product = "TeleMetrum";
+string version = "0.0";
int serial = 1;
int user_argind = 0;
.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",
};
{
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();
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_ */
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
{ '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 },
};
/* 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))
/* 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