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

comedi: merge comedi node with tested DAC functionality

This commit is contained in:
Daniel Krebs 2018-06-15 17:44:25 +02:00
commit bfcf87d970
17 changed files with 1256 additions and 39 deletions

View file

@ -57,6 +57,7 @@ endif
WITH_NODE_FPGA ?= $(IS_LINUX)
WITH_NODE_CBUILDER ?= $(IS_LINUX)
WITH_NODE_LOOPBACK ?= $(IS_LINUX)
WITH_NODE_COMEDI ?= $(IS_LINUX)
WITH_NODE_TEST_RTT ?= 1
WITH_NODE_FILE ?= 1
WITH_NODE_SIGNAL ?= 1

View file

@ -92,6 +92,8 @@ help:
$E " WITH_NODE_AMQP = $(WITH_NODE_AMQP)"
$E " WITH_NODE_MQTT = $(WITH_NODE_MQTT)"
$E " WITH_NODE_IEC61850 = $(WITH_NODE_IEC61850)"
$E " WITH_NODE_MQTT = $(WITH_NODE_MQTT)"
$E " WITH_NODE_COMEDI = $(WITH_NODE_COMEDI)"
$E
$E "Available dependencies: $(LIB_PKGS)"
$E "Enabled node-types: $(LIB_NODES)"

90
etc/comedi.conf Normal file
View file

@ -0,0 +1,90 @@
/** Example configuration file for VILLASnode/comedi.
*
* The syntax of this file is similar to JSON.
* A detailed description of the format can be found here:
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
*
* @author Daniel Krebs <github@daniel-krebs.net>
* @copyright 2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* 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 3 of the License, or
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
nodes = {
pcie6259 = {
type = "comedi",
device = "/dev/comedi0",
in = {
subdevice = 0,
rate = 1000,
signals = (
# note: order in this array defines order in villas sample
{ channel = 0, range = 0, aref = 0, name = "temperature_int" },
{ channel = 1, range = 0, aref = 0, name = "loopback_ao0" },
{ channel = 2, range = 0, aref = 0, name = "loopback_ao1" },
{ channel = 3, range = 0, aref = 0, name = "bnc_ext" }
)
},
out = {
subdevice = 1,
# Note: buffer size and rate shouldn't be changed at the moment
# output sample rate
rate = 40000,
# comedi write buffer in kilobytes
bufsize = 24,
signals = (
# note: order in this array corresponds to order in villas sample
{ name = "ao0", channel = 0, range = 0, aref = 0 },
{ name = "ao1", channel = 1, range = 0, aref = 0 },
{ name = "ao2", channel = 2, range = 0, aref = 0 },
{ name = "ao3", channel = 3, range = 0, aref = 0 }
)
}
},
remote = {
type = "socket",
layer = "udp"
format = "protobuf",
local = "*:12000"
remote = "134.130.169.32:12000"
},
sine1 = {
type = "signal",
signal = "sine",
values = 1,
frequency = 50,
rate = 10000,
},
sine2 = {
type = "signal",
signal = "sine",
values = 1,
frequency = 100,
rate = 10000,
}
}
paths = (
# 2-ch sine
#{ in = ("sine1.data[0]", "sine2.data[0]"), out = "pcie6259", rate = 10000, mask = () }
# Remote data via UDP
{ in = "remote.data[0-3]", out = "pcie6259", rate = 40000, mask = () }
)

View file

@ -55,30 +55,31 @@ extern "C" {
* To be or-ed with the debug level
*/
enum log_facilities {
LOG_POOL = (1L << 8),
LOG_QUEUE = (1L << 9),
LOG_POOL = (1L << 8),
LOG_QUEUE = (1L << 9),
LOG_CONFIG = (1L << 10),
LOG_HOOK = (1L << 11),
LOG_PATH = (1L << 12),
LOG_NODE = (1L << 13),
LOG_MEM = (1L << 14),
LOG_WEB = (1L << 15),
LOG_API = (1L << 16),
LOG_LOG = (1L << 17),
LOG_VFIO = (1L << 18),
LOG_PCI = (1L << 19),
LOG_XIL = (1L << 20),
LOG_TC = (1L << 21),
LOG_IF = (1L << 22),
LOG_ADVIO = (1L << 23),
LOG_HOOK = (1L << 11),
LOG_PATH = (1L << 12),
LOG_NODE = (1L << 13),
LOG_MEM = (1L << 14),
LOG_WEB = (1L << 15),
LOG_API = (1L << 16),
LOG_LOG = (1L << 17),
LOG_VFIO = (1L << 18),
LOG_PCI = (1L << 19),
LOG_XIL = (1L << 20),
LOG_TC = (1L << 21),
LOG_IF = (1L << 22),
LOG_ADVIO = (1L << 23),
/* Node-types */
LOG_SOCKET = (1L << 24),
LOG_FILE = (1L << 25),
LOG_FPGA = (1L << 26),
LOG_NGSI = (1L << 27),
LOG_FILE = (1L << 25),
LOG_FPGA = (1L << 26),
LOG_NGSI = (1L << 27),
LOG_WEBSOCKET = (1L << 28),
LOG_OPAL = (1L << 30),
LOG_OPAL = (1L << 30),
LOG_COMEDI = (1L << 31),
/* Classes */
LOG_NODES = LOG_NODE | LOG_SOCKET | LOG_FILE | LOG_FPGA | LOG_NGSI | LOG_WEBSOCKET | LOG_OPAL,

View file

@ -1,6 +1,4 @@
/** Node type: amqp
*
* This file implements the file type for nodes.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>

View file

@ -2,7 +2,23 @@
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Steffen Vogel
* @copyright 2018, Steffen Vogel
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* 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 3 of the License, or
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/**

View file

@ -0,0 +1,102 @@
/** Node type: comedi
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* 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 3 of the License, or
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/**
* @addtogroup comedi Comedi node type
* @ingroup node
* @{
*/
#pragma once
#include <comedilib.h>
#include <villas/node.h>
#include <villas/list.h>
#include <villas/timing.h>
// whether to use read() or mmap() kernel interface
#define COMEDI_USE_READ (1)
//#define COMEDI_USE_READ (0)
struct comedi_chanspec {
unsigned int maxdata;
comedi_range *range;
};
struct comedi_direction {
int subdevice; ///< Comedi subdevice
int buffer_size; ///< Comedi's kernel buffer size
int sample_size; ///< Size of a single measurement sample
int sample_rate_hz; ///< Sample rate in Hz
bool present; ///< Config present
bool enabled; ///< Card is started successfully
bool running; ///< Card is actively transfering samples
struct timespec started; ///< Timestamp when sampling started
int counter; ///< Number of villas samples transfered
struct comedi_chanspec *chanspecs; ///< Range and maxdata config of channels
unsigned *chanlist; ///< Channel list in comedi's packed format
size_t chanlist_len; ///< Number of channels for this direction
char* buffer;
char* bufptr;
};
struct comedi {
char *device;
struct comedi_direction in, out;
comedi_t *dev;
#if COMEDI_USE_READ
char* buf;
char* bufptr;
#else
char *map;
size_t bufpos;
size_t front;
size_t back;
#endif
};
/** @see node_type::print */
char * comedi_print(struct node *n);
/** @see node_type::parse */
int comedi_parse(struct node *n, json_t *cfg);
/** @see node_type::open */
int comedi_start(struct node *n);
/** @see node_type::close */
int comedi_stop(struct node *n);
/** @see node_type::read */
int comedi_read(struct node *n, struct sample *smps[], unsigned cnt);
/** @see node_type::write */
int comedi_write(struct node *n, struct sample *smps[], unsigned cnt);
/** @} */

View file

@ -1,6 +1,4 @@
/** Node type: File
*
* This file implements the file type for nodes.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>

View file

@ -1,6 +1,4 @@
/** Node type: mqtt
*
* This file implements the file type for nodes.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>

View file

@ -1,6 +1,4 @@
/** Node type: nanomsg
*
* This file implements the file type for nodes.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>

View file

@ -1,6 +1,4 @@
/** Node type: OPAL (libOpalAsync API)
*
* This file implements the opal subtype for nodes.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>

View file

@ -1,6 +1,4 @@
/** Node type: socket
*
* This file implements the socket subtype for nodes.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>

View file

@ -1,7 +1,4 @@
/** Node type: WebSockets
*
* This file implements the websocket type for nodes.
* It's based on the libwebsockets library.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>

View file

@ -155,3 +155,12 @@ ifneq ($(wildcard /usr/include/mosquitto.h),)
WITH_IO = 1
endif
endif
# Enable Comedi support
ifeq ($(WITH_NODE_COMEDI),1)
ifeq ($(shell $(PKGCONFIG) comedilib; echo $$?),0)
LIB_PKGS += comedilib
LIB_SRCS += lib/nodes/comedi.c
LIB_NODES += comedi
endif
endif

1010
lib/nodes/comedi.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -53,7 +53,7 @@ RUN dnf -y install \
iproute \
python-pip \
valgrind gdb gdb-gdbserver \
xmlto rubygem-asciidoctor \
xmlto dblatex rubygem-asciidoctor \
psmisc procps-ng
# Tools for debugging, coverage, profiling
@ -77,7 +77,8 @@ RUN dnf -y install \
protobuf-c-devel \
libiec61850-devel \
librabbitmq-devel \
mosquitto-devel
mosquitto-devel \
comedilib-devel
# Build & Install Criterion
RUN cd /tmp && \

View file

@ -14,8 +14,8 @@ BuildRequires: gcc pkgconfig make
Requires: iproute module-init-tools
BuildRequires: openssl-devel libconfig-devel libnl3-devel libcurl-devel jansson-devel libwebsockets-devel zeromq-devel nanomsg-devel libiec61850-devel librabbitmq-devel mosquitto-devel
Requires: openssl libconfig libnl3 libcurl jansson libwebsockets zeromq nanomsg libiec61850 librabbitmq mosquitto
BuildRequires: openssl-devel libconfig-devel libnl3-devel libcurl-devel jansson-devel libwebsockets-devel zeromq-devel nanomsg-devel libiec61850-devel librabbitmq-devel mosquitto-devel comedilib-devel
Requires: openssl libconfig libnl3 libcurl jansson libwebsockets zeromq nanomsg libiec61850 librabbitmq mosquitto comedilib
%description