2020-01-21 19:34:23 +01:00
|
|
|
/** Node-type: CAN bus
|
|
|
|
*
|
|
|
|
* @file
|
2020-07-08 13:32:33 +02:00
|
|
|
* @author Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2022-07-04 18:20:03 +02:00
|
|
|
* @license Apache 2.0
|
2020-01-21 19:34:23 +01:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-07-08 13:33:13 +02:00
|
|
|
#include <jansson.h>
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/timing.hpp>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2020-07-08 13:33:13 +02:00
|
|
|
/* Forward declarations */
|
2021-08-10 10:12:48 -04:00
|
|
|
class NodeCompat;
|
|
|
|
union SignalData;
|
2020-07-08 13:33:13 +02:00
|
|
|
|
2020-07-08 16:07:24 +02:00
|
|
|
struct can_signal {
|
2020-07-08 13:33:58 +02:00
|
|
|
uint32_t id;
|
|
|
|
int offset;
|
|
|
|
int size;
|
2020-07-08 16:07:24 +02:00
|
|
|
};
|
|
|
|
|
2020-01-21 19:34:23 +01:00
|
|
|
struct can {
|
2020-07-08 13:33:58 +02:00
|
|
|
/* Settings */
|
|
|
|
char *interface_name;
|
|
|
|
struct can_signal *in;
|
|
|
|
struct can_signal *out;
|
|
|
|
|
|
|
|
/* States */
|
|
|
|
int socket;
|
2021-08-10 10:12:48 -04:00
|
|
|
union SignalData *sample_buf;
|
2020-07-08 13:33:58 +02:00
|
|
|
size_t sample_buf_num;
|
|
|
|
struct timespec start_time;
|
2020-01-21 19:34:23 +01:00
|
|
|
};
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_init(NodeCompat *n);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_destroy(NodeCompat *n);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_parse(NodeCompat *n, json_t *json);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
char * can_print(NodeCompat *n);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_check(NodeCompat *n);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_prepare(NodeCompat *n);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_start(NodeCompat *n);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_stop(NodeCompat *n);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
int can_poll_fds(NodeCompat *n, int fds[]);
|
2020-01-21 19:34:23 +01:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|