Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified ChangeLog
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified Makefile
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified TODO
100644 → 100755
Empty file.
1 change: 0 additions & 1 deletion configure.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ RTAIINCDIR = $(subst /rtai.h,,$(firstword $(wildcard $(foreach i,$(subst -I,,$(f
ifneq ($(RTAIINCDIR),)
RTAIDIR = $(realpath $(RTAIINCDIR)/..)
endif

Empty file modified debian/changelog
100644 → 100755
Empty file.
Empty file modified debian/compat
100644 → 100755
Empty file.
Empty file modified debian/control
100644 → 100755
Empty file.
Empty file modified debian/copyright
100644 → 100755
Empty file.
Empty file modified debian/docs
100644 → 100755
Empty file.
Empty file modified debian/source/format
100644 → 100755
Empty file.
Empty file modified examples/Makefile
100644 → 100755
Empty file.
Empty file modified examples/generic-complex/CPD17/cpd17_x.hal
100644 → 100755
Empty file.
Empty file modified examples/generic-complex/CPD17/cpd17_x.ini
100644 → 100755
Empty file.
Empty file modified examples/generic-complex/CPD17/ethercat-conf_X.xml
100644 → 100755
Empty file.
Empty file modified examples/generic-complex/README
100644 → 100755
Empty file.
Empty file modified examples/generic-complex/ethercat-conf.xml
100644 → 100755
Empty file.
Empty file modified examples/swm-fm45a/ethercat-conf.xml
100644 → 100755
Empty file.
Empty file modified examples/swm-fm45a/swm-fm45a-axis.hal
100644 → 100755
Empty file.
Empty file modified examples/swm-fm45a/swm-fm45a-io.hal
100644 → 100755
Empty file.
Empty file modified examples/swm-fm45a/swm-fm45a-spindle.hal
100644 → 100755
Empty file.
Empty file modified examples/swm-fm45a/swm-fm45a.hal
100644 → 100755
Empty file.
Empty file modified examples/swm-fm45a/swm-fm45a.ini
100644 → 100755
Empty file.
Empty file modified examples/swm-fm45a/tool.tbl
100644 → 100755
Empty file.
Empty file modified src/Kbuild
100644 → 100755
Empty file.
Empty file modified src/Makefile
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions src/lcec.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ typedef struct lcec_master {
uint32_t app_time_period;
int sync_ref_cnt;
int sync_ref_cycles;
uint32_t reference_time;
} lcec_master_t;

typedef struct {
Expand Down Expand Up @@ -155,6 +156,7 @@ typedef struct lcec_slave {
ec_pdo_info_t *generic_pdos;
ec_sync_info_t *generic_sync_managers;
lcec_slave_sdoconf_t *sdo_config;
LCEC_CONF_ATTR_T attrs[LCEC_CONF_ATTR_MAX];
} lcec_slave_t;

ec_sdo_request_t *lcec_read_sdo(struct lcec_slave *slave, uint16_t index, uint8_t subindex, size_t size);
Expand Down
57 changes: 56 additions & 1 deletion src/lcec_conf.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ typedef struct {
LCEC_SLAVE_TYPE_T type;
} LCEC_CONF_TYPELIST_T;

typedef struct {
char *name;
LCEC_SLAVE_TYPE_T type;
char *attr[LCEC_CONF_ATTR_MAX];
} LCEC_CONF_ATTRLIST_T;

typedef struct {
hal_u32_t *master_count;
hal_u32_t *slave_count;
Expand Down Expand Up @@ -147,6 +153,12 @@ static const LCEC_CONF_TYPELIST_T slaveTypes[] = {
{ NULL }
};

static const LCEC_CONF_ATTRLIST_T slaveAttrs[] = {
{"DeASDA", lcecSlaveTypeDeASDA, "test","",""},
{"EL7041-1000", lcecSlaveTypeEL7041_1000, "maxCurrent","nomVoltage",""},
{NULL}
};

char *modname = "lcec_conf";
int hal_comp_id;
LCEC_CONF_HAL_T *conf_hal_data;
Expand Down Expand Up @@ -627,6 +639,8 @@ void parseMasterAttrs(const char **attr) {

void parseSlaveAttrs(const char **attr) {
LCEC_CONF_SLAVE_T *p = getOutputBuffer(sizeof(LCEC_CONF_SLAVE_T));
int i;
int attrcont= -1 ;
if (p == NULL) {
return;
}
Expand Down Expand Up @@ -687,7 +701,48 @@ void parseSlaveAttrs(const char **attr) {
continue;
}
}

else { //Atributos adicionales para tipos no genericos, hay que comprobar si son validos y si no estan repetidos.
//Additionals attributes for no generic type. It must check if they are valid and aren't repeated.

const LCEC_CONF_ATTRLIST_T *slaveAttr;
for (slaveAttr = slaveAttrs; slaveAttr->name != NULL; slaveAttr++) { //recorremos lista con atributos validos por tipo de esclavo
if (p->type == slaveAttr->type){ //comprobamos si estamos en el esclavo correcto
for (i=0; i<LCEC_CONF_ATTR_MAX;i++){
if (strcmp(name, slaveAttr->attr[i]) == 0){
break; //vemos si el atributo es valido para el esclavo en cuestion
}
}
break;
}
}
if (slaveAttr->name == NULL) { //si no ha encontrado el esclavo en la lista o no tenia los atributos validos
fprintf(stderr, "%s: ERROR: Invalid slave attribute %s\n", modname, name);
XML_StopParser(parser, 0);
return;
}

//hay que comprobar si no estaba repetido ya y guardarlo en el que este libre.
for (i=attrcont; i>=0; i--){ //comprobacion de repetido
if (strcmp(name, p->attrs[i].attr) == 0){ //ya estaba definido y por tanto error
fprintf(stderr, "%s: ERROR: Duplicated slave attribute %s\n", modname, name);
XML_StopParser(parser, 0);
return;
}
}
strncpy(p->attrs[attrcont+1].attr, name, LCEC_CONF_STR_MAXLEN);
p->attrs[attrcont+1].attr[LCEC_CONF_STR_MAXLEN - 1] = 0;
p->attrs[attrcont+1].val = atof(val);
attrcont++;
//POR seguridad y depuración comprobacion si pasa de LCEC_CONF_ATTR_MAX
if (attrcont >= LCEC_CONF_ATTR_MAX){
fprintf(stderr, "%s: ERROR: Mas de LCEC_CONF_ATTR_MAX atributos para el esclavo\n", modname);
XML_StopParser(parser, 0);
return;
}

continue;

}
// handle error
fprintf(stderr, "%s: ERROR: Invalid slave attribute %s\n", modname, name);
XML_StopParser(parser, 0);
Expand Down
8 changes: 8 additions & 0 deletions src/lcec_conf.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#define LCEC_CONF_STR_MAXLEN 48

#define LCEC_CONF_ATTR_MAX 3

#define LCEC_CONF_SDO_COMPLETE_SUBIDX -1
#define LCEC_CONF_GENERIC_MAX_SUBPINS 32
#define LCEC_CONF_GENERIC_MAX_BITLEN 255
Expand Down Expand Up @@ -141,6 +143,11 @@ typedef struct {
char name[LCEC_CONF_STR_MAXLEN];
} LCEC_CONF_MASTER_T;

typedef struct {
char attr[LCEC_CONF_STR_MAXLEN];
float val;
} LCEC_CONF_ATTR_T;

typedef struct {
LCEC_CONF_TYPE_T confType;
int index;
Expand All @@ -154,6 +161,7 @@ typedef struct {
unsigned int pdoMappingCount;
size_t sdoConfigLength;
char name[LCEC_CONF_STR_MAXLEN];
LCEC_CONF_ATTR_T attrs[LCEC_CONF_ATTR_MAX];
} LCEC_CONF_SLAVE_T;

typedef struct {
Expand Down
Empty file modified src/lcec_deasda.c
100644 → 100755
Empty file.
Empty file modified src/lcec_deasda.h
100644 → 100755
Empty file.
Empty file modified src/lcec_ek1100.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el1252.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el1252.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el1xxx.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el1xxx.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el2202.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el2202.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el2521.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el2521.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el2xxx.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el2xxx.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el31x2.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el31x2.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el40x1.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el40x1.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el40x2.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el40x2.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el41x2.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el41x2.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el5101.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el5101.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el5151.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el5151.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el5152.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el5152.h
100644 → 100755
Empty file.
17 changes: 15 additions & 2 deletions src/lcec_el7041_1000.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int lcec_el7041_1000_init(int comp_id, struct lcec_slave *s, ec_pdo_entry_reg_t
lcec_master_t *m = s->master;
lcec_el7041_1000_data_t *hd;
int err;

int i;
// initialize callbacks
s->proc_read = lcec_el7041_1000_read;
s->proc_write = lcec_el7041_1000_write;
Expand All @@ -253,7 +253,20 @@ int lcec_el7041_1000_init(int comp_id, struct lcec_slave *s, ec_pdo_entry_reg_t
}
memset(hd, 0, sizeof(lcec_el7041_1000_data_t));
s->hal_data = hd;


for (i=0; i<LCEC_CONF_ATTR_MAX;i++){
if (strcmp(s->attrs[i].attr,"maxCurrent")==0){
if (ecrt_slave_config_sdo16(s->config, 0x8010, 0x01, s->attrs[i].val) != 0) {
rtapi_print_msg (RTAPI_MSG_ERR, LCEC_MSG_PFX "fail to configure slave %s.%s sdo 8010 01\n", m->name, s->name);
}
}
else if (strcmp(s->attrs[i].attr,"nomVoltage")==0){
if (ecrt_slave_config_sdo16(s->config, 0x8010, 0x03, s->attrs[i].val) != 0) {
rtapi_print_msg (RTAPI_MSG_ERR, LCEC_MSG_PFX "fail to configure slave %s.%s sdo 8010 03\n", m->name, s->name);
}
}
}

// initialize sync info
s->sync_info = lcec_el7041_1000_syncs;

Expand Down
Empty file modified src/lcec_el7041_1000.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el7342.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el7342.h
100644 → 100755
Empty file.
Empty file modified src/lcec_el95xx.c
100644 → 100755
Empty file.
Empty file modified src/lcec_el95xx.h
100644 → 100755
Empty file.
Empty file modified src/lcec_em7004.c
100644 → 100755
Empty file.
Empty file modified src/lcec_em7004.h
100644 → 100755
Empty file.
Empty file modified src/lcec_generic.c
100644 → 100755
Empty file.
Empty file modified src/lcec_generic.h
100644 → 100755
Empty file.
32 changes: 28 additions & 4 deletions src/lcec_main.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "lcec_el2xxx.h"
#include "lcec_el2202.h"
#include "lcec_el31x2.h"
#include "lcec_el3255.h"
#include "lcec_el40x1.h"
#include "lcec_el40x2.h"
#include "lcec_el41x2.h"
Expand Down Expand Up @@ -96,6 +97,8 @@ static const lcec_typelist_t types[] = {
{ lcecSlaveTypeEL2798, LCEC_EL2xxx_VID, LCEC_EL2798_PID, LCEC_EL2798_PDOS, lcec_el2xxx_init},
{ lcecSlaveTypeEL2809, LCEC_EL2xxx_VID, LCEC_EL2809_PID, LCEC_EL2809_PDOS, lcec_el2xxx_init},

{ lcecSlaveTypeEP2028, LCEC_EL2xxx_VID, LCEC_EP2028_PID, LCEC_EP2028_PDOS, lcec_el2xxx_init},

// analog in, 2ch, 16 bits
{ lcecSlaveTypeEL3102, LCEC_EL31x2_VID, LCEC_EL3102_PID, LCEC_EL31x2_PDOS, lcec_el31x2_init},
{ lcecSlaveTypeEL3112, LCEC_EL31x2_VID, LCEC_EL3112_PID, LCEC_EL31x2_PDOS, lcec_el31x2_init},
Expand All @@ -104,6 +107,9 @@ static const lcec_typelist_t types[] = {
{ lcecSlaveTypeEL3152, LCEC_EL31x2_VID, LCEC_EL3152_PID, LCEC_EL31x2_PDOS, lcec_el31x2_init},
{ lcecSlaveTypeEL3162, LCEC_EL31x2_VID, LCEC_EL3162_PID, LCEC_EL31x2_PDOS, lcec_el31x2_init},

// analog in, 5ch, 16 bits
{ lcecSlaveTypeEL3255, LCEC_EL3255_VID, LCEC_EL3255_PID, LCEC_EL3255_PDOS, lcec_el3255_init},

// analog out, 1ch, 12 bits
{ lcecSlaveTypeEL4001, LCEC_EL40x1_VID, LCEC_EL4001_PID, LCEC_EL40x1_PDOS, lcec_el40x1_init},
{ lcecSlaveTypeEL4011, LCEC_EL40x1_VID, LCEC_EL4011_PID, LCEC_EL40x1_PDOS, lcec_el40x1_init},
Expand Down Expand Up @@ -464,6 +470,7 @@ int lcec_parse_config(void) {
master->name[LCEC_CONF_STR_MAXLEN - 1] = 0;
master->mutex = 0;
master->app_time = 0;
master->reference_time = 0;
master->app_time_period = master_conf->appTimePeriod;
master->sync_ref_cnt = 0;
master->sync_ref_cycles = master_conf->refClockSyncCycles;
Expand Down Expand Up @@ -761,7 +768,6 @@ int lcec_parse_config(void) {
generic_hal_data->dir = generic_hal_dir;
generic_hal_data->pdo_idx = pe_conf->index;
generic_hal_data->pdo_sidx = pe_conf->subindex;
generic_hal_data->pdo_len = pe_conf->bitLength;
generic_hal_data++;
}

Expand Down Expand Up @@ -799,7 +805,6 @@ int lcec_parse_config(void) {
generic_hal_data->dir = generic_hal_dir;
generic_hal_data->pdo_idx = pe_conf->index;
generic_hal_data->pdo_sidx = pe_conf->subindex;
generic_hal_data->pdo_len = pe_conf->bitLength;
generic_hal_data++;
}
break;
Expand Down Expand Up @@ -1110,7 +1115,11 @@ void lcec_write_master(void *arg, long period) {

// send process data
rtapi_mutex_get(&master->mutex);



// update application time
master->app_time += master->app_time_period;
/*
// update application time
master->app_time += master->app_time_period;
ecrt_master_application_time(master->master, master->app_time);
Expand All @@ -1126,7 +1135,22 @@ void lcec_write_master(void *arg, long period) {

// sync slaves to ref clock
ecrt_master_sync_slave_clocks(master->master);

*/if (master->reference_time == 0)
{
ecrt_master_reference_clock_time(master->master, &master->reference_time); //consigo el tiempo del reference clock y lo guardo en master->reference_time
master->app_time = master->reference_time;
}
else
{
ecrt_master_reference_clock_time(master->master, &master->reference_time); //consigo el tiempo del reference clock y lo guardo en master->reference_time
}
ecrt_master_sync_slave_clocks(master->master); // sync slaves to ref clock
ecrt_master_application_time(master->master, master->reference_time+master->app_time_period);





// send domain data
ecrt_domain_queue(master->domain);
ecrt_master_send(master->master);
Expand Down
Empty file modified src/lcec_rtapi.h
100644 → 100755
Empty file.
Empty file modified src/lcec_rtapi_kmod.h
100644 → 100755
Empty file.
Empty file modified src/lcec_rtapi_user.h
100644 → 100755
Empty file.
Empty file modified src/lcec_stmds5k.c
100644 → 100755
Empty file.
Empty file modified src/lcec_stmds5k.h
100644 → 100755
Empty file.
Empty file modified src/realtime.mk
100644 → 100755
Empty file.
Empty file modified src/user.mk
100644 → 100755
Empty file.