Commit 5b42506c authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Various small stuff before importing changes from Daan.

parent fb8da95e
......@@ -33,7 +33,10 @@
*/
struct _va_dyn {
unsigned char regs[176];
union {
struct _va_dyn *self;
unsigned char regs[176];
} u;
unsigned char overflow_area[256];
size_t overflow;
unsigned gp_offset;
......@@ -47,12 +50,12 @@ do {\
vadyn = malloc(sizeof(struct _va_dyn));\
(list)[0].gp_offset = 8;\
(list)[0].fp_offset = 48;\
(list)[0].reg_save_area = vadyn->regs;\
(list)[0].reg_save_area = vadyn->u.regs;\
(list)[0].overflow_arg_area = vadyn->overflow_area;\
vadyn->overflow = 0;\
vadyn->gp_offset = 8;\
vadyn->fp_offset = 48;\
*(struct _va_dyn **)&vadyn->regs = vadyn;\
vadyn->u.self = vadyn;\
} while (0)
#define va_add(list, type, val)\
......@@ -67,12 +70,12 @@ do {\
u.v = (val); \
\
if (!strcmp(#type, "double")) { \
memcpy(&vadyn->regs[vadyn->fp_offset], &u.d, sizeof(u.d)); \
memcpy(&vadyn->u.regs[vadyn->fp_offset], &u.d, sizeof(u.d)); \
/* *(double *)&vadyn->regs[vadyn->fp_offset] = u.d;*/\
vadyn->fp_offset += sizeof(long double);\
} else { \
if (vadyn->gp_offset < 48) { \
memcpy(&vadyn->regs[vadyn->gp_offset], &u.ul, sizeof(u.ul)); \
memcpy(&vadyn->u.regs[vadyn->gp_offset], &u.ul, sizeof(u.ul)); \
/* *(unsigned long *)&vadyn->regs[vadyn->gp_offset] = \
(unsigned long)u.ul;*/\
vadyn->gp_offset += sizeof(unsigned long);\
......
......@@ -47,7 +47,7 @@ size_t trace_handler_read(struct trace *trace, void *buf, size_t len)
r = write(fd_file, buf, len);
if (r != len) {
printf("Could not write %d bytes to file %d : %d: %s\n",
printf("Could not write %zd bytes to file %d : %zd: %s\n",
r, fd_file, len, strerror(errno));
exit(1);
}
......
......@@ -46,7 +46,7 @@ int main(int argc, char **argv)
sprintf(linebuf, "%.1f C, %.0f mbar\n",
weather_get_temperature(weather),
weather_get_pressure(weather));
printf(linebuf);
printf("%s", linebuf);
write(fda, linebuf, strlen(linebuf));
fflush(NULL);
close(fda);
......
......@@ -183,7 +183,7 @@ int main (int argc, char **argv)
"Established connection to controller");
entry->buffer[strlen(entry->buffer)+1] = 0;
entry->buffer[strlen(entry->buffer)] = '\n';
printf(entry->buffer);
printf("%s", entry->buffer);
entry->buflen = strlen(entry->buffer);
}
} else if (FD_ISSET(fd_log, &fd_rd)) {
......@@ -232,7 +232,7 @@ int main (int argc, char **argv)
"Lost connection to controller");
entry->buffer[strlen(entry->buffer)+1] = 0;
entry->buffer[strlen(entry->buffer)] = '\n';
printf(entry->buffer);
printf("%s", entry->buffer);
entry->buflen = strlen(entry->buffer);
}
}
......
/*
* Copyright (c) 2014,
* Daan Vreeken <Daan @ Vitsch . nl> - Vitsch Electronics
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS `AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <errno.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <controller/controller_block.h>
#include <log/log.h>
/*
pand
input output
name name
----------------------------------------------
---| TODO: fill in.. |---
----------------------------------------------
Omschrijving:
...
*/
// definitie van variabelen die we gebruiken
struct controller_block_private {
// ingangen
bool *reset_button, *start_button;
float *temp_test, *temp_wtw[4];
float *co2_test;
// uitgangen
bool test_out;
float test_analog;
// interne variabelen
};
// een paar definities voor de leesbaarheid van de code
#define OUTPUT(name) (sub->private->name)
#define INPUT(name) (*sub->private->name)
static int show_debug = 0;
static int no_debug_override = 0;
/*
static int dprintf(const char *fmt, ...)
{
va_list args;
int ret;
if ((! show_debug) || (no_debug_override))
return (0);
va_start(args, fmt);
ret = vprintf(fmt, args);
va_end(args);
return (ret);
}
*/
struct timespec last_t;
static void calculate(struct controller_block *sub)
{
struct controller_block_private *priv;
struct timespec t;
priv = sub->private;
//priv->now = gettick();
clock_gettime(0, &t);
OUTPUT(test_out) = (t.tv_nsec >= 500 * 1000 * 1000) ? 1 : 0;
OUTPUT(test_analog) = (t.tv_nsec * 10.0) / 1.0e9;
if (last_t.tv_sec != t.tv_sec) {
last_t.tv_sec = t.tv_sec;
log_send(LOG_T_DEBUG,
" %0.3f mA %0.5f %0.2f %0.2f %0.2f "
"%0.2f\n", INPUT(co2_test) * 1.0e3,
INPUT(temp_test), INPUT(temp_wtw[0]), INPUT(temp_wtw[1]),
INPUT(temp_wtw[2]), INPUT(temp_wtw[3])
);
}
}
static struct controller_block_interm_list interms[] = {
{ "reset", CONTROLLER_BLOCK_TERM_BOOL,
offsetof(struct controller_block_private, reset_button) },
{ "start", CONTROLLER_BLOCK_TERM_BOOL,
offsetof(struct controller_block_private, start_button) },
{ "temp_test", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_test) },
{ "co2_test", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, co2_test) },
{ "temp_wtw_1", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[0]) },
{ "temp_wtw_2", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[1]) },
{ "temp_wtw_3", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[2]) },
{ "temp_wtw_4", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, temp_wtw[3]) },
{ NULL },
};
static struct controller_block_outterm_list outterms[] = {
{ "test_out", CONTROLLER_BLOCK_TERM_BOOL,
offsetof(struct controller_block_private, test_out) },
{ "test_analog", CONTROLLER_BLOCK_TERM_FLOAT,
offsetof(struct controller_block_private, test_analog) },
{ NULL },
};
struct controller_block * block_pand_create(char *name)
{
struct controller_block *sub;
struct controller_block_private *priv;
int failed;
sub = controller_block_alloc("pand", name,
sizeof(struct controller_block_private));
if (sub == NULL)
return NULL;
priv = sub->private;
// lijst van inputs
if (controller_block_interm_list_init(sub, interms))
goto err_sub;
failed = 0;
#if 0
failed = controller_block_add_bool_input(sub, "reset",
&priv->reset_button);
failed |= controller_block_add_bool_input(sub, "start",
&priv->start_button);
failed |= controller_block_add_float_input(sub, "temp_test",
&priv->temp_test);
failed |= controller_block_add_float_input(sub, "co2_test",
&priv->co2_test);
failed |= controller_block_add_float_input(sub, "temp_wtw_1",
&priv->temp_wtw[0]);
failed |= controller_block_add_float_input(sub, "temp_wtw_2",
&priv->temp_wtw[1]);
failed |= controller_block_add_float_input(sub, "temp_wtw_3",
&priv->temp_wtw[2]);
failed |= controller_block_add_float_input(sub, "temp_wtw_4",
&priv->temp_wtw[3]);
#endif
// outputs
if (controller_block_outterm_list_init(sub, outterms))
goto err_sub;
#if 0
failed |= controller_block_add_bool_output(sub, "test_out",
&sub->private->test_out);
failed |= controller_block_add_float_output(sub, "test_analog",
&sub->private->test_analog);
#endif
OUTPUT(test_out) = false;
if (failed)
goto err_sub;
sub->calculate = calculate;
log_send(LOG_T_DEBUG, "pand: booted V0.1 2014-12-15");
// dit blokje heeft geen instelbare parameters
sub->param_get = NULL;
sub->param_set = NULL;
controller_block_add(sub);
return sub;
err_sub:
controller_block_free(sub);
return NULL;
}
BLOCK_TARGETS := $(LIBDIR)/libblock.la
OS= $(shell uname -s)
$(eval $(call SUBDIR,il2c))
BLOCKS := \
......
......@@ -22,7 +22,6 @@ $(LIBDIR)/libcontroller.la: libshell.la libcommand.la libtrace.la
$(LIBDIR)/libcontroller.la_LDFLAGS += -lshell -pthread -lrt -lcommand -ltrace
ifneq ($(OS), FreeBSD)
BLOCKS+= \
$(LIBDIR)/libcontroller.la_LDFLAGS += -ldl
endif
......
......@@ -65,18 +65,18 @@ struct ec_pdo_frame {
};
static struct ec_pdo_frame tx_pdo_real = {
frame_hdr: (struct ec_frame_hdr *)&tx_pdo_real.tx_frame,
flen: sizeof(struct ec_frame_hdr),
tx_users: 0,
rx_users: 0,
.frame_hdr = (struct ec_frame_hdr *)&tx_pdo_real.tx_frame,
.flen = sizeof(struct ec_frame_hdr),
.tx_users = 0,
.rx_users = 0,
};
static struct ec_pdo_frame *tx_pdo = &tx_pdo_real;
static struct ec_pdo_frame rx_pdo = {
frame_hdr: (struct ec_frame_hdr *)&rx_pdo.tx_frame,
flen: sizeof(struct ec_frame_hdr),
tx_users: 0,
rx_users: 0,
.frame_hdr = (struct ec_frame_hdr *)&rx_pdo.tx_frame,
.flen = sizeof(struct ec_frame_hdr),
.tx_users = 0,
.rx_users = 0,
};
static int rx_pdo_enabled = 1;
......
......@@ -149,7 +149,7 @@ struct esc_vendor {
static struct esc_vendor __attribute__((unused)) esc_vendor_list[] = {
{ ESC_ESI_VENDORID_BECKHOFF, "Beckhoff Automation GmbH" },
{ ESC_ESI_VENDORID_STOEBER, "STÖBER ANTRIEBSTECHNIK GmbH & Co. KG" },
{ ESC_ESI_VENDORID_STOEBER, "STOEBER ANTRIEBSTECHNIK GmbH & Co. KG" },
{ ESC_ESI_VENDORID_BROM, "Brom Mechatronica B.V." },
};
......
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