Commit 9d860129 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

lib/fdelay_board_time: added wr/local time setting option

parent 30458b54
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <unistd.h>
#include "fdelay-lib.h" #include "fdelay-lib.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct fdelay_board *b; struct fdelay_board *b;
int i, get = 0, host = 0; int i, get = 0, host = 0, wr_on = 0, wr_off = 0;
struct fdelay_time t; struct fdelay_time t;
int dev = 0; int dev = 0;
...@@ -21,17 +22,21 @@ int main(int argc, char **argv) ...@@ -21,17 +22,21 @@ int main(int argc, char **argv)
} }
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "%s: Use \"%s [-i <devindex> \"get\"|\"host\"|" fprintf(stderr,
"%s: Use \"%s [-i <devindex> \"get\"|\"host\"|\"local\"|\"wr\"|"
"<float-value>\"\n", argv[0], argv[0]); "<float-value>\"\n", argv[0], argv[0]);
exit(1); exit(1);
} }
/* Crappy parser */ /* Crappy parser */
if (!strcmp(argv[1], "get")) if (!strcmp(argv[1], "get"))
get = 1; get = 1;
else if (!strcmp(argv[1], "host")) else if (!strcmp(argv[1], "host"))
host = 1; host = 1;
else if (!strcmp(argv[1], "wr"))
wr_on = 1;
else if (!strcmp(argv[1], "local"))
wr_off = 1;
else { else {
double nano; double nano;
long long sec; long long sec;
...@@ -93,6 +98,38 @@ int main(int argc, char **argv) ...@@ -93,6 +98,38 @@ int main(int argc, char **argv)
return 0; return 0;
} }
if (wr_on) {
printf("Locking the card to WR: ");
if (fdelay_wr_mode(b, 1) < 0) {
fprintf(stderr, "%s: fdelay_wr_mode(): %s\n",
argv[0], strerror(errno));
exit(1);
}
while (fdelay_check_wr_mode(b) != 0) {
printf(".");
sleep(1);
}
printf(" locked!\n");
fdelay_close(b);
fdelay_exit();
return 0;
}
if (wr_off) {
if (fdelay_wr_mode(b, 0) < 0) {
fprintf(stderr, "%s: fdelay_wr_mode(): %s\n",
argv[0], strerror(errno));
exit(1);
}
fdelay_close(b);
fdelay_exit();
return 0;
}
if (fdelay_set_time(b, &t) < 0) { if (fdelay_set_time(b, &t) < 0) {
fprintf(stderr, "%s: fdelay_set_host_time(): %s\n", fprintf(stderr, "%s: fdelay_set_host_time(): %s\n",
argv[0], strerror(errno)); argv[0], strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment