projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add version command to show product information
[fw/altos]
/
ao-make-product.5c
diff --git
a/ao-make-product.5c
b/ao-make-product.5c
index 4f5bcba92ec1288c18856bca4d5db34b60326842..933032dd6344f3835bfe88d8066ba1c2c508d724 100644
(file)
--- a/
ao-make-product.5c
+++ b/
ao-make-product.5c
@@
-3,13
+3,14
@@
autoimport ParseArgs;
void
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);
{
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)
for (int i = 0; i < len; i++) {
int c = a[i];
if (i > 0)
@@
-22,6
+23,13
@@
write_string(string a, string description)
printf("\n\n");
}
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)
{
void
write_int(int a, string description)
{
@@
-31,6
+39,7
@@
write_int(int a, string description)
string manufacturer = "altusmetrum.org";
string product = "TeleMetrum";
string manufacturer = "altusmetrum.org";
string product = "TeleMetrum";
+string version = "0.0";
int serial = 1;
int user_argind = 0;
int serial = 1;
int user_argind = 0;
@@
-54,6
+63,12
@@
argdesc argd = {
.name = "serial",
.expr_name = "number",
.desc = "Serial number." },
.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",
};
},
.prog_name = "usb descriptors",
};
@@
-63,10
+78,11
@@
main()
{
string[dim(argv)-1] nargv = {[n] = argv[n+1]};
parseargs(&argd, &nargv);
{
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_int(serial, "iSerial");
+ write_string(version, "iVersion");
}
main();
}
main();