6 write_ucs2(string a, string description)
8 int len = String::length(a);
10 printf("/* %s */\n", description);
11 printf("#define AO_%s_LEN 0x%02x\n", description, len * 2 + 2);
12 printf("#define AO_%s_STRING \"%s\"\n", description, a);
13 printf("#define AO_%s_UCS2", description);
14 for (int i = 0; i < len; i++) {
18 if (0x20 <= c && c < 128)
19 printf(" '%c', 0", c);
21 printf(" LE_WORD(0x%04x),", c);
27 write_string(string a, string description)
29 printf ("/* %s */\n", description);
30 printf ("#define AO_%s_STRING \"%s\"\n", description, a);
34 write_int(int a, string description)
36 printf ("/* %s */\n", description);
37 printf ("#define AO_%s_NUMBER %d\n\n", description, a);
41 write_hex(int a, string description)
43 printf ("/* %s */\n", description);
44 printf ("#define AO_%s_NUMBER 0x%04x\n\n", description, a);
47 string manufacturer = "altusmetrum.org";
48 string product = "TeleMetrum";
49 string version = "0.0";
52 int id_product = 0x000a;
57 .var = { .arg_string = &manufacturer },
59 .name = "manufacturer",
61 .desc = "Manufacturer name." },
63 .var = { .arg_string = &product },
67 .desc = "Product name." },
69 .var = { .arg_int = &id_product },
73 .desc = "Product ID." },
75 .var = { .arg_int = &serial },
78 .expr_name = "number",
79 .desc = "Serial number." },
81 .var = { .arg_string = &version },
84 .expr_name = "string",
85 .desc = "Program version." },
87 .prog_name = "usb descriptors",
93 string[dim(argv)-1] nargv = {[n] = argv[n+1]};
94 parseargs(&argd, &nargv);
95 write_ucs2(manufacturer, "iManufacturer");
96 write_ucs2(product, "iProduct");
97 write_ucs2(sprintf("%06d", serial), "iSerial");
98 write_int(serial, "iSerial");
99 write_hex(id_product, "idProduct");
100 write_string(version, "iVersion");