/usr/share/doc/libx52pro0/examples/x52output.c is in libx52pro-dev 0.1.1-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <x52pro.h>
/* just for debugging */
int x52_custom(struct x52 *x52, int index, int value);
int main(int argc, char**argv)
{
struct x52 *hdl = x52_init();
if (hdl==NULL)
return 1;
x52_debug(hdl, 1);
char *prog = argv[0];
if (argc < 2) {
printf("usage: %s {text|bri|led|time|offset|date|custom}\n", prog);
return 0;
}
char *cmd = argv[1];
if (!strcmp(cmd, "text")) {
if (argc < 4) {
printf("usage: %s text <line> <text>\n", prog);
return 0;
}
x52_settext(hdl, atoi(argv[2]), argv[3], strlen(argv[3]));
} else if (!strcmp(cmd, "bri")) {
if (argc < 4) {
printf("usage: %s bri <mfd> <value>\n", prog);
return 0;
}
x52_setbri(hdl, atoi(argv[2]), atoi(argv[3]));
} else if (!strcmp(cmd, "led")) {
if (argc < 4) {
printf("usage: %s led <id> <on>\n", prog);
return 0;
}
x52_setled(hdl, atoi(argv[2]), atoi(argv[3]));
} else if (!strcmp(cmd, "time")) {
if (argc < 5) {
printf("usage: %s time <h24> <hour> <min>\n", prog);
return 0;
}
x52_settime(hdl, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
} else if (!strcmp(cmd, "offset")) {
if (argc < 6) {
printf("usage: %s time <idx> <h24> <inv> <minutes>\n", prog);
return 0;
}
x52_setoffs(hdl, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]),
atoi(argv[5]));
} else if (!strcmp(cmd, "date")) {
if (argc < 5) {
printf("usage: %s date <year> <month> <day>\n", prog);
return 0;
}
x52_setdate(hdl, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
} else if (!strcmp(cmd, "second")) {
if (argc < 3) {
printf("usage: %s date <year> <month> <day>\n", prog);
return 0;
}
x52_setsecond(hdl, atoi(argv[2]));
} else if (!strcmp(cmd, "model")) {
enum x52_type type = x52_gettype(hdl);
switch (type) {
case DEV_X52:
printf("Model: X52 Flight Control System\n");
break;
case DEV_X52PRO:
printf("Model: X52 Pro Flight Control System\n");
break;
case DEV_YOKE:
printf("Model: Pro Flight Yoke\n");
break;
}
} else if (!strcmp(cmd, "custom")) {
if (argc < 4) {
printf("usage: %s custom <idx> <value>\n", prog);
return 0;
}
int index = strtol(argv[2], NULL, 16);
int value = strtol(argv[3], NULL, 16);
x52_custom(hdl, index, value);
} else {
printf("unknown command %s\n", cmd);
}
x52_close(hdl);
return 0;
}
|