1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

minor cleanup, bug fixes and refactoring

This commit is contained in:
Steffen Vogel 2017-03-27 12:50:01 +02:00
parent a06a7eec57
commit 267d244167
7 changed files with 28 additions and 28 deletions

View file

@ -18,7 +18,8 @@ int node_type_start(struct node_type *vt, int argc, char *argv[], config_setting
{
int ret;
assert(vt->state != STATE_STARTED);
if (vt->state != STATE_STARTED)
return 0;
info("Initializing " YEL("%s") " node type which is used by %zu nodes", plugin_name(vt), list_length(&vt->instances));
{ INDENT
@ -35,7 +36,8 @@ int node_type_stop(struct node_type *vt)
{
int ret;
assert(vt->state == STATE_STARTED);
if (vt->state != STATE_STARTED)
return 0;
info("De-initializing " YEL("%s") " node type", plugin_name(vt));
{ INDENT

View file

@ -71,7 +71,7 @@ static int websocket_connection_write(struct websocket_connection *c, struct sam
return -1;
case WEBSOCKET_CLOSED:
if (c->node) {
struct websocket *w = (struct websocket *) c->node->_vd;
struct websocket *w = c->node->_vd;
list_remove(&w->connections, c);
}
else
@ -169,7 +169,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
info("LWS: New connection %s", websocket_connection_name(c));
if (c->node != NULL) {
struct websocket *w = (struct websocket *) c->node->_vd;
struct websocket *w = c->node->_vd;
list_push(&w->connections, c);
}
else {
@ -191,7 +191,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
case LWS_CALLBACK_CLIENT_WRITEABLE:
case LWS_CALLBACK_SERVER_WRITEABLE: {
w = (struct websocket *) c->node->_vd;
w = c->node->_vd;
if (c->node && c->node->state != STATE_STARTED)
return -1;
@ -224,7 +224,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
case LWS_CALLBACK_CLIENT_RECEIVE:
case LWS_CALLBACK_RECEIVE: {
w = (struct websocket *) c->node->_vd;
w = c->node->_vd;
if (c->node->state != STATE_STARTED)
return -1;

View file

@ -1,10 +1,8 @@
/** Statistic collection.
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2014-2016, Institute for Automation of Complex Power Systems, EONERC
* This file is part of VILLASnode. All Rights Reserved. Proprietary and confidential.
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
*********************************************************************************/
#include "stats.h"
#include "hist.h"

View file

@ -84,15 +84,15 @@ int fpga_benchmark_jitter(struct fpga_card *c)
{
int ret;
struct fpga_ip *tmr;
tmr = list_lookup(&c->ips, "timer_0");
if (!tmr || !c->intc)
struct fpga_ip *ip = list_lookup(&c->ips, "timer_0");
if (!ip || !c->intc)
return -1;
XTmrCtr *xtmr = &tmr->timer.inst;
struct timer *tmr = ip->_vd;
ret = intc_enable(c->intc, (1 << tmr->irq), intc_flags);
XTmrCtr *xtmr = &tmr->inst;
ret = intc_enable(c->intc, (1 << ip->irq), intc_flags);
if (ret)
error("Failed to enable interrupt");
@ -107,12 +107,12 @@ int fpga_benchmark_jitter(struct fpga_card *c)
uint64_t end, start = rdtsc();
for (int i = 0; i < runs; i++) {
uint64_t cnt = intc_wait(c->intc, tmr->irq);
uint64_t cnt = intc_wait(c->intc, ip->irq);
if (cnt != 1)
warn("fail");
/* Ackowledge IRQ */
XTmrCtr_WriteReg((uintptr_t) c->map + tmr->baseaddr, 0, XTC_TCSR_OFFSET, XTmrCtr_ReadReg((uintptr_t) c->map + tmr->baseaddr, 0, XTC_TCSR_OFFSET));
XTmrCtr_WriteReg((uintptr_t) c->map + ip->baseaddr, 0, XTC_TCSR_OFFSET, XTmrCtr_ReadReg((uintptr_t) c->map + ip->baseaddr, 0, XTC_TCSR_OFFSET));
end = rdtsc();
hist[i] = end - start;
@ -130,7 +130,7 @@ int fpga_benchmark_jitter(struct fpga_card *c)
free(hist);
ret = intc_disable(c->intc, (1 << tmr->irq));
ret = intc_disable(c->intc, (1 << ip->irq));
if (ret)
error("Failed to disable interrupt");

View file

@ -33,8 +33,6 @@ void usage()
printf(" -d Set log level\n\n");
print_copyright();
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[])
@ -44,8 +42,10 @@ int main(int argc, char *argv[])
struct super_node sn;
struct fpga_card *card;
if (argc < 3)
if (argc < 3) {
usage(argv[0]);
exit(EXIT_FAILURE);
}
/* Parse arguments */
char c, *endptr;
@ -58,6 +58,7 @@ int main(int argc, char *argv[])
case '?':
default:
usage();
exit(EXIT_SUCCESS);
}
}

View file

@ -51,12 +51,10 @@ static int hook_parse_cli(struct hook *h, char *params[], int paramlen)
cfg_root = config_root_setting(&cfg);
ret = hook_parse(h, cfg_root);
if (ret)
error("Failed to parse hook settings");
free(str);
return 0;
return ret;
}
static void usage()

View file

@ -82,8 +82,6 @@ int main(int argc, char *argv[])
else if (argc > 2)
usage();
#endif
super_node_init(&sn);
info("This is VILLASnode %s (built on %s, %s)", BLD(YEL(VERSION_STR)),
BLD(MAG(__DATE__)), BLD(MAG(__TIME__)));
@ -93,7 +91,10 @@ int main(int argc, char *argv[])
error("Your kernel version is to old: required >= %u.%u", KERNEL_VERSION_MAJ, KERNEL_VERSION_MIN);
signals_init(quit);
log_init(&sn.log, V, LOG_ALL);
log_start(&sn.log);
super_node_init(&sn);
super_node_parse_cli(&sn, argc, argv);
super_node_check(&sn);
super_node_start(&sn);
@ -113,7 +114,7 @@ int main(int argc, char *argv[])
for (size_t j = 0; j < list_length(&p->hooks); j++) {
struct hook *h = list_at(&p->hooks, j);
hook_run(h, HOOK_PERIODIC, NULL, 0);
hook_periodic(h);
}
}