Commit a1fc8805 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/tools: add wrs_status_led to manage status LED

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 06920861
......@@ -6,6 +6,8 @@ TOOLS += sdb-read
TOOLS += nbtee
TOOLS += wrs_auxclk
TOOLS += wrs_checkcfg
TOOLS += wrs_status_led
PPSI_CONFIG = ../ppsi/include/generated/autoconf.h
WR_INSTALL_ROOT ?= /usr/lib/white-rabbit
......
/*
* wrs_status_led.c
*
* Turn on/off and change color of status LED
*
* Created on: July 9, 2015
* Authors:
* - Adam Wujek
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License...
*/
#include <stdlib.h>
#include <getopt.h>
#include <libwr/shw_io.h>
#include <libwr/wrs-msg.h>
#ifndef __GIT_VER__
#define __GIT_VER__ "x.x"
#endif
#ifndef __GIT_USR__
#define __GIT_USR__ "?"
#endif
void help(const char* pgrname)
{
printf("wrs_status_led. Commit %s, built on " __DATE__ "\n",
__GIT_VER__);
printf("usage: %s <command>\n", pgrname);
printf("available commands are:\n"
" -x turn off status led\n"
" -h this help\n"
"\n");
exit(1);
}
int main(int argc, char **argv)
{
int opt;
/* argc forced to 1: -t and -v are not "terse" and "verbose" */
wrs_msg_init(1, argv);
assert_init(shw_pio_mmap_init());
shw_io_init();
shw_io_configure_all();
while ((opt = getopt(argc, argv, "yxhqv")) != -1) {
switch (opt) {
case 'x':
shw_io_write(shw_io_led_state_o, 0);
shw_io_write(shw_io_led_state_g, 0);
break;
case 'y':
shw_io_write(shw_io_led_state_o, 1);
shw_io_write(shw_io_led_state_g, 1);
break;
case 'h':
help(argv[0]);
exit(0);
break;
case 'q': break; /* done in wrs_msg_init() */
case 'v': break; /* done in wrs_msg_init() */
default:
fprintf(stderr,
"Unrecognized option. Call %s -h for help.\n",
argv[0]);
exit (1);
}
}
return 0;
}
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