Commit 8450f2f0 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

First batch of cherry picks from the vitsch branch.

parent 6dcea292
......@@ -20,7 +20,7 @@
#define _INCLUDE_DYNARG_H_
#include <stdarg.h>
#include <malloc.h>
#include <stdlib.h>
......
......@@ -25,6 +25,8 @@
#include <netinet/in.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include "tcp_listen.h"
......
......@@ -7,11 +7,16 @@ CFLAGS= -Wall -O3 \
-I../common/trace \
-I../common/include \
-Idt_azimuth -Idt_elevation -Iec -Ishell -Ilog
LDFLAGS= -lpthread -lrt -lm -ldl -Wl,-E -L../common/lib -L./lib
LDFLAGS= -lpthread -lrt -lm -Wl,-E -L../common/lib -L./lib
CFLAGS_SIM=-DUSE_AZ_SIM -DUSE_EL_SIM
OS= $(shell uname -s)
ifneq ($(OS), FreeBSD)
LDFLAGS+= -ldl
endif
dt_ctrl_LDFLAGS=`controller/block_list.sh lib/*.a` \
dt_ctrl_LDFLAGS=`./controller/block_list.sh lib/*.a` \
-lcontroller -lethercat -llog -lshell -ldt_azimuth -ldt_elevation
all: dt_ctrl \
......
......@@ -8,6 +8,13 @@ VPATH= /lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib
LIBTOOL=libtool
OS= $(shell uname -s)
ifneq ($(OS), FreeBSD)
FLEX=flex
else
FLEX=/usr/local/bin/flex
endif
%.o : %.c
@echo "LT CC $<"
@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
......@@ -22,7 +29,11 @@ LIBTOOL=libtool
%.lo: %.c
@echo "LT CC $<"
@${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
@sed -i -e "s:\.libs/::" -e "s:\.o:\.lo:" .libs/$*.d
# compatibility hack: Linux's sed doesn't have a separate argument to '-i',
# while on FreeBSD, '-i' takes a non-optional extension argument. With
# '-i -i' we'll specify '-i' twice on Linux and let FreeBSD use '[filename]-i'
# as intermediate file for in-place editing.
@sed -e "s:\.libs/::" -e "s:\.o:\.lo:" -i -i .libs/$*.d
%.la:
@echo "LIBTOOL $@"
......@@ -38,7 +49,8 @@ LIBTOOL=libtool
%.yy.c %.yy.h: %.l %.tab.h
@echo " FLEX $<"
@flex --header-file=$*.yy.h -o $*.yy.c $<
@echo $(FLEX) --header-file=$*.yy.h -o $*.yy.c $<
@$(FLEX) --header-file=$*.yy.h -o $*.yy.c $<
# il2c: instruction list 2 c 'compiler'
%.c %.h: %.il
......
......@@ -14,7 +14,6 @@ BLOCKSRCS= \
block_friction.c \
block_gain.c \
block_gain_var.c \
block_joystick.c \
block_limit.c \
block_limit_dyn.c \
block_limit_2nd.c \
......@@ -43,6 +42,13 @@ BLOCKSRCS= \
block_value_bool.c \
block_value_uint32.c
OS= $(shell uname -s)
ifneq ($(OS), FreeBSD)
BLOCKSRCS+= \
block_joystick.c
endif
CONTROLLERSRCS= \
controller_block.c \
controller_block_param.c \
......
#!/bin/bash
#!/bin/sh
for lib in $@; do
SYMBOLS=`nm $lib |grep "block_.*_create" |cut -d' ' -f3`
......
......@@ -25,7 +25,7 @@
*/
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include "controller_block.h"
#include "controller_sample.h"
......
......@@ -22,7 +22,7 @@
This module takes care of tracing block outputs.
*/
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include "controller_block.h"
......
......@@ -18,7 +18,7 @@
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <controller/controller_block.h>
#include <controller/controller_trace.h>
......
......@@ -19,7 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdbool.h>
#include "controller_load_parser.tab.h"
#include "controller_load_parser.yy.h"
......
......@@ -19,7 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdbool.h>
#include "il.tab.h"
#include "il2c.h"
......
......@@ -19,7 +19,7 @@
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include "controller_block.h"
......
......@@ -20,7 +20,7 @@
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include "controller_block.h"
#include "log.h"
......
......@@ -20,7 +20,7 @@
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include "controller_block.h"
......
......@@ -33,6 +33,8 @@ BLOCKSRCS= \
block_beckhoff_el7031.c \
block_stoeber.c
# block_beckhoff_ax5xxx.c \
BLOCKS=$(BLOCKSRCS:.c=.lo)
SRCS=$(BLOCKSRCS) $(LIBSRCS)
......
......@@ -21,6 +21,12 @@
#include <stdio.h>
#include <pthread.h>
#if defined(__linux__)
#include <endian.h>
#else
#include <sys/endian.h>
#endif
#include "canopen.h"
#include "log.h"
......
......@@ -32,12 +32,6 @@
#include "esc_coe.h"
#include "log.h"
#define ESC_MAILBOX_TYPE_ADS 0x1
#define ESC_MAILBOX_TYPE_EOE 0x2
#define ESC_MAILBOX_TYPE_COE 0x3
#define ESC_MAILBOX_TYPE_FOE 0x4
#define ESC_MAILBOX_TYPE_SOE 0x5
#define ESC_MAILBOX_TYPE_VOE 0xf
struct canopen_dev_priv {
......
......@@ -133,6 +133,8 @@
#define ESC_ESI_PRODUCTCODE_BECKHOFF_EL7031 0x1b773052
#define ESC_ESI_PRODUCTCODE_BECKHOFF_AX5203 0x14536012
struct esc_vendor {
uint32_t vendorid;
char *name;
......
......@@ -35,5 +35,12 @@ void esc_mailbox_destroy(struct esc_mailbox *mailbox);
int esc_syncmanager_claim(struct ec_dgram_addr *addr);
#define ESC_MAILBOX_TYPE_ADS 0x1
#define ESC_MAILBOX_TYPE_EOE 0x2
#define ESC_MAILBOX_TYPE_COE 0x3
#define ESC_MAILBOX_TYPE_FOE 0x4
#define ESC_MAILBOX_TYPE_SOE 0x5
#define ESC_MAILBOX_TYPE_VOE 0xf
#endif /* _INCLUDE_EC_ESC_MAILBOX_H_ */
......@@ -28,8 +28,8 @@ struct sockaddr_ll {
size_t sll_halen;
};
static struct tx_timeout;
static struct rx_timeout;
static struct timeval tx_timeout;
static struct timeval rx_timeout;
static struct sockaddr_ll sockaddr_ll;
int eth_timeout_set(int ec_sock, struct timeval *tx, struct timeval *rx)
......@@ -151,7 +151,7 @@ int eth_recv(int ec_sock, void *frame, int max_len)
while (1) {
// TODO: kqueue?
memcpy(&timeout, rx_timeout, sizeof(timeout));
memcpy(&timeout, &rx_timeout, sizeof(timeout));
FD_ZERO(&fdr);
FD_SET(ec_sock, &fdr);
......@@ -226,7 +226,7 @@ struct ethercat_pkt tx_pkt;
int eth_send(int ec_sock, void *frame, int len)
{
struct sockaddr_ll *addr = (struct sockaddr_ll *)sockaddr_ll;
struct sockaddr_ll *addr = (struct sockaddr_ll *)&sockaddr_ll;
int result;
uint8_t *ptr;
......@@ -244,6 +244,18 @@ int eth_send(int ec_sock, void *frame, int len)
memcpy(tx_pkt.data, frame, len);
ptr = (uint8_t *)&tx_pkt;
//TODO: do this once during start-up, in ec_init()
// destination address
ptr[0] = 0xff;
ptr[1] = 0xff;
ptr[2] = 0xff;
ptr[3] = 0xff;
ptr[4] = 0xff;
ptr[5] = 0xff;
// protocol
ptr[2 * 6 + 0] = ETH_P_ETHERCAT >> 8;
ptr[2 * 6 + 1] = ETH_P_ETHERCAT & 0xff;
#if 0
printf("tx:");
for (result = 0; result < ETHER_HDR_LEN + len; result++) {
......
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