Commit fdd289fe authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Various ethercat fixes and printf -> log

parent 794d2601
......@@ -25,6 +25,7 @@
#include "block_ec.h"
#include "ec.h"
#include "log.h"
static struct controller_block *ec_block = NULL;
......@@ -72,9 +73,10 @@ struct controller_block * block_ec_create(char *name, va_list ap)
while ((ret = ec_slave_count()) != nr_slaves) {
if (ret == -1) {
printf("Error counting slaves\n");
log_send(LOG_T_ERROR, "Error counting slaves");
} else {
printf("Found only %d slaves, waiting for %d.\n",
log_send(LOG_T_ERROR,
"Found only %d slaves, waiting for %d.",
ret, nr_slaves);
}
sleep(10);
......
......@@ -271,9 +271,11 @@ struct controller_block *block_stoeber_create(char *name, va_list ap)
private->stbr.canopen_dev->logname = stoeber->name;
printf("Drive serial number: %d\n", private->stbr.serial_number);
log_send(LOG_T_DEBUG, "Drive serial number: %d",
private->stbr.serial_number);
if (serial_number && serial_number != private->stbr.serial_number) {
printf("Serial number of drive (%d) does not match requested number (%d)\n",
log_send(LOG_T_ERROR,
"Serial number of drive (%d) does not match requested number (%d)",
private->stbr.serial_number, serial_number);
goto err_stoeber_init;
}
......
......@@ -34,6 +34,8 @@
#define CANOPEN_E 0x02
#define CANOPEN_S 0x01
struct timespec canopen_timeout = { 1, 0 };
ssize_t canopen_write_param(struct canopen_dev *dev,
unsigned index, unsigned subindex,
void *data, ssize_t bytes)
......@@ -52,9 +54,9 @@ ssize_t canopen_write_param(struct canopen_dev *dev,
pthread_mutex_lock(&dev->lock);
ret = dev->send_request(dev, cmd, 8);
ret = dev->send_request(dev, cmd, 8, &canopen_timeout);
if (ret == 8)
ret = dev->recv_response(dev, cmd, 8);
ret = dev->recv_response(dev, cmd, 8, &canopen_timeout);
pthread_mutex_unlock(&dev->lock);
......@@ -83,10 +85,10 @@ ssize_t canopen_read_param(struct canopen_dev *dev,
pthread_mutex_lock(&dev->lock);
ret = dev->send_request(dev, cmd, 8);
ret = dev->send_request(dev, cmd, 8, &canopen_timeout);
if (ret == 8)
ret = dev->recv_response(dev, cmd, 8);
ret = dev->recv_response(dev, cmd, 8, &canopen_timeout);
pthread_mutex_unlock(&dev->lock);
......
......@@ -24,8 +24,10 @@
#include <stdint.h>
struct canopen_dev {
ssize_t (*send_request)(struct canopen_dev *dev, void *req, size_t len);
ssize_t (*recv_response)(struct canopen_dev *dev, void *res, size_t len);
ssize_t (*send_request)(struct canopen_dev *dev, void *req, size_t len,
struct timespec *timeout);
ssize_t (*recv_response)(struct canopen_dev *dev, void *res, size_t len,
struct timespec *timeout);
void (*emergency_handler)(struct canopen_dev *dev, uint16_t code, uint8_t reg, uint8_t vendor[5]);
char *logname;
......
......@@ -106,7 +106,8 @@ int ec_stoeber_init(struct ec_stoeber *stbr)
vendorid = esc_esi_vendorid_get(&stbr->addr);
productcode = esc_esi_productcode_get(&stbr->addr);
serialno = esc_esi_serialno_get(&stbr->addr);
printf("VendorId: 0x%04x, ProductCode: 0x%04x, SerialNo: 0x%04x\n",
log_send(LOG_T_DEBUG,
"VendorId: 0x%04x, ProductCode: 0x%04x, SerialNo: 0x%04x",
vendorid, productcode, serialno);
/* TODO: check values */
......@@ -115,14 +116,14 @@ int ec_stoeber_init(struct ec_stoeber *stbr)
status = esc_al_status_code_get(&stbr->addr);
if (status != 0) {
printf("status code: 0x%x\n", status);
log_send(LOG_T_DEBUG, "status code: 0x%x", status);
esc_al_error_ack(&stbr->addr);
}
if (esc_al_state_set(&stbr->addr, ESC_AL_STATE_INIT, &timeout) < 0)
return -1;
printf("Initializing mailbox\n");
log_send(LOG_T_DEBUG, "Initializing mailbox");
esc_dc_init(&stbr->addr);
......@@ -155,7 +156,7 @@ int ec_stoeber_init(struct ec_stoeber *stbr)
stbr->canopen_dev = canopen_dev;
}
printf("Going to state pre-operational\n");
log_send(LOG_T_DEBUG, "Going to state pre-operational");
if (esc_al_state_set(&stbr->addr, ESC_AL_STATE_PRE_OPERATIONAL, &timeout) < 0)
return -1;
......@@ -274,9 +275,9 @@ int ec_stoeber_init(struct ec_stoeber *stbr)
/* B17 Torque M0 */
canopen_read_param(canopen_dev, STOEBER_PARAM2INDEX('B', 17), 0x0, &leval32, 4);
printf("B17: %08x %d\n", le32toh(leval32), le32toh(leval32));
log_send(LOG_T_DEBUG, "B17: %08x %d", le32toh(leval32), le32toh(leval32));
stbr->standstill_torque = (float)(le32toh(leval32)) / 1000.0;
printf("Standstill torque: %f\n", stbr->standstill_torque);
log_send(LOG_T_DEBUG, "Standstill torque: %f", stbr->standstill_torque);
/* C03 max pos torque 150% of standstill */
leval32 = htole32(150);
......@@ -355,7 +356,7 @@ int ec_stoeber_init(struct ec_stoeber *stbr)
canopen_write_param(canopen_dev, STOEBER_PARAM2INDEX('A', 225), 0x5, &leval32, 4);
printf("Setup PDOs\n");
log_send(LOG_T_DEBUG, "Setup PDOs");
/* sm2 tx pdo (master->slave) @0x1600 */
......@@ -372,12 +373,12 @@ int ec_stoeber_init(struct ec_stoeber *stbr)
esc_pdo_tx_set(&stbr->addr, &pdo_tx, &stbr->tx_buffer, false);
esc_pdo_rx_set(&stbr->addr, &pdo_rx, &stbr->rx_buffer);
printf("going to safe operational\n");
log_send(LOG_T_DEBUG, "going to safe operational");
if (esc_al_state_set(&stbr->addr, ESC_AL_STATE_SAFE_OPERATIONAL, &timeout) < 0)
return -1;
printf("Done\n");
log_send(LOG_T_DEBUG, "ec_stoeber: Done");
return 0;
}
......@@ -26,6 +26,7 @@
#include "esc.h"
#include "ec.h"
#include "canopen.h"
#include "log.h"
struct esc_mailbox {
struct ec_dgram_addr status_rd;
......@@ -239,7 +240,7 @@ int esc_al_state_set(struct ec_dgram_addr *addr, enum esc_al_state newstate,
ret = ec_datagram_write(&state_add, &state, sizeof(uint16_t));
} while (ret == 0);
printf("set state: %d datagram write: %d\n", newstate, ret);
log_send(LOG_T_DEBUG, "set state: %d datagram write: %d", newstate, ret);
if (ret == 2) {
clock_gettime(CLOCK_MONOTONIC, &t_start);
while (!esc_timeout_expired(&t_start, timeout)) {
......@@ -249,17 +250,20 @@ int esc_al_state_set(struct ec_dgram_addr *addr, enum esc_al_state newstate,
if (state == newstate)
return newstate;
else
printf("state: %d != %d\n", state, newstate);
log_send(LOG_T_DEBUG, "state: %d != %d",
state, newstate);
status = esc_al_status_code_get(addr);
if (status != 0) {
printf("state now: %d status code: 0x%x\n",
log_send(LOG_T_DEBUG,
"state now: %d status code: 0x%x",
state, status);
esc_al_error_ack(addr);
return -1;
}
}
printf("Timeout while trying to set state %d, stuck in state %d\n",
log_send(LOG_T_ERROR,
"Timeout while trying to set state %d, stuck in state %d",
newstate, state);
/* timeout... */
return state;
......@@ -324,11 +328,11 @@ int esc_init(struct ec_dgram_addr *addr)
addr->addr.position.off = ESC_ADDR_MAP_SYNCMANAGERS_SUPPORTED;
ret = ec_datagram_read(addr, &nr_syncmgr, 1);
if (ret != 1) {
printf("Could not read ESC information\n");
log_send(LOG_T_ERROR, "Could not read ESC information");
return -1;
}
printf("ESC supports %d SyncManagers\n", nr_syncmgr);
log_send(LOG_T_DEBUG, "ESC supports %d SyncManagers", nr_syncmgr);
/* De-activate all sync managers. */
for (i = 0; i < nr_syncmgr; i++) {
uint16_t off = ESC_ADDR_MAP_SYNCMANAGER_NR(i);
......@@ -340,7 +344,8 @@ int esc_init(struct ec_dgram_addr *addr)
ret = ec_datagram_write(addr, &val8, 1);
if (ret != 1) {
printf("Could not deactivate sync manager %d\n", i);
log_send(LOG_T_ERROR,
"Could not deactivate sync manager %d", i);
return -1;
}
......@@ -361,7 +366,7 @@ int esc_syncmanager_claim(struct ec_dgram_addr *addr)
addr->addr.position.off = ESC_ADDR_MAP_SYNCMANAGERS_SUPPORTED;
ret = ec_datagram_read(addr, &nr_syncmgr, 1);
if (ret != 1) {
printf("Could not read ESC information\n");
log_send(LOG_T_ERROR, "Could not read ESC information");
return -1;
}
......@@ -373,7 +378,8 @@ int esc_syncmanager_claim(struct ec_dgram_addr *addr)
ret = ec_datagram_read(addr, &val8, 1);
if (ret != 1) {
printf("Could not read syncmanger%d activate register\n", i);
log_send(LOG_T_ERROR,
"Could not read syncmanger%d activate register", i);
return -1;
}
if (!(val8 & ESC_SYNCMANAGER_ACTIVATE_ENABLE)) {
......@@ -396,12 +402,14 @@ static void esc_error_handler_default(void *msg, size_t len)
{
unsigned char *msgb = msg;
int i;
char msgstr[100 + len];
int pos = 0;
printf("Mailbox error message:");
pos = sprintf(msgstr, "Mailbox error message:");
for (i = 0; i < len; i++) {
printf(" 0x%02x", msgb[i]);
pos += sprintf(msgstr + pos, " 0x%02x", msgb[i]);
}
printf("\n");
log_send(LOG_T_ERROR, msgstr);
}
struct esc_mailbox *esc_mailbox_create(struct ec_dgram_addr *node,
......@@ -427,7 +435,8 @@ struct esc_mailbox *esc_mailbox_create(struct ec_dgram_addr *node,
len_write = wr->len;
}
printf("Claiming syncmanager %d for mailbox write\n", sync_manager_write);
log_send(LOG_T_DEBUG, "Claiming syncmanager %d for mailbox write",
sync_manager_write);
/* mailbox write (master->slave) */
......@@ -442,7 +451,7 @@ struct esc_mailbox *esc_mailbox_create(struct ec_dgram_addr *node,
ESC_ADDR_MAP_SYNCMANAGER_PHYSICAL_START;
leval16 = htole16(start_write);
ec_datagram_write(node, &leval16, 2);
printf("write address: %04zx\n", start_write);
log_send(LOG_T_DEBUG, "write address: %04zx", start_write);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_write) |
ESC_ADDR_MAP_SYNCMANAGER_LENGTH;
......@@ -456,14 +465,14 @@ printf("write address: %04zx\n", start_write);
ESC_SYNCMANAGER_CONTROL_MAILBOX |
ESC_SYNCMANAGER_CONTROL_WRITE |
ESC_SYNCMANAGER_CONTROL_INT_PDI;
printf("Write Control byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Write Control byte: 0x%02x", val8);
ec_datagram_write(node, &val8, 1);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_write) |
ESC_ADDR_MAP_SYNCMANAGER_STATUS;
ec_datagram_read(node, &val8, 1);
printf("Write status byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Write status byte: 0x%02x", val8);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_write) |
......@@ -485,7 +494,8 @@ printf("Write status byte: 0x%02x\n", val8);
len_read = rd->len;
}
printf("Claiming syncmanager %d for mailbox read\n", sync_manager_read);
log_send(LOG_T_ERROR, "Claiming syncmanager %d for mailbox read",
sync_manager_read);
/* mailbox read (slave->master) */
......@@ -500,7 +510,7 @@ printf("Write status byte: 0x%02x\n", val8);
ESC_ADDR_MAP_SYNCMANAGER_PHYSICAL_START;
leval16 = htole16(start_read);
ec_datagram_write(node, &leval16, 2);
printf("read address: %04zx\n", start_read);
log_send(LOG_T_DEBUG, "read address: %04zx", start_read);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_read) |
......@@ -514,7 +524,7 @@ printf("read address: %04zx\n", start_read);
val8 =
ESC_SYNCMANAGER_CONTROL_MAILBOX |
ESC_SYNCMANAGER_CONTROL_INT_PDI;
printf("Read Control byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Read Control byte: 0x%02x", val8);
ec_datagram_write(node, &val8, 1);
......@@ -522,7 +532,7 @@ printf("Read Control byte: 0x%02x\n", val8);
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_read) |
ESC_ADDR_MAP_SYNCMANAGER_STATUS;
ec_datagram_read(node, &val8, 1);
printf("Read status byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Read status byte: 0x%02x", val8);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_read) |
......@@ -596,7 +606,8 @@ void esc_mailbox_reinit(struct ec_dgram_addr *node,
len_write = wr->len;
}
printf("Claiming syncmanager %d for mailbox write\n", sync_manager_write);
log_send(LOG_T_DEBUG, "Claiming syncmanager %d for mailbox write",
sync_manager_write);
/* mailbox write (master->slave) */
......@@ -611,7 +622,7 @@ void esc_mailbox_reinit(struct ec_dgram_addr *node,
ESC_ADDR_MAP_SYNCMANAGER_PHYSICAL_START;
leval16 = htole16(start_write);
ec_datagram_write(node, &leval16, 2);
printf("write address: %04zx\n", start_write);
log_send(LOG_T_DEBUG, "write address: %04zx", start_write);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_write) |
ESC_ADDR_MAP_SYNCMANAGER_LENGTH;
......@@ -625,14 +636,14 @@ printf("write address: %04zx\n", start_write);
ESC_SYNCMANAGER_CONTROL_MAILBOX |
ESC_SYNCMANAGER_CONTROL_WRITE |
ESC_SYNCMANAGER_CONTROL_INT_PDI;
printf("Write Control byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Write Control byte: 0x%02x", val8);
ec_datagram_write(node, &val8, 1);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_write) |
ESC_ADDR_MAP_SYNCMANAGER_STATUS;
ec_datagram_read(node, &val8, 1);
printf("Write status byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Write status byte: 0x%02x", val8);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_write) |
......@@ -654,7 +665,8 @@ printf("Write status byte: 0x%02x\n", val8);
len_read = rd->len;
}
printf("Claiming syncmanager %d for mailbox read\n", sync_manager_read);
log_send(LOG_T_DEBUG, "Claiming syncmanager %d for mailbox read",
sync_manager_read);
/* mailbox read (slave->master) */
......@@ -669,7 +681,7 @@ printf("Write status byte: 0x%02x\n", val8);
ESC_ADDR_MAP_SYNCMANAGER_PHYSICAL_START;
leval16 = htole16(start_read);
ec_datagram_write(node, &leval16, 2);
printf("read address: %04zx\n", start_read);
log_send(LOG_T_DEBUG, "read address: %04zx", start_read);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_read) |
......@@ -683,7 +695,7 @@ printf("read address: %04zx\n", start_read);
val8 =
ESC_SYNCMANAGER_CONTROL_MAILBOX |
ESC_SYNCMANAGER_CONTROL_INT_PDI;
printf("Read Control byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Read Control byte: 0x%02x", val8);
ec_datagram_write(node, &val8, 1);
......@@ -691,7 +703,7 @@ printf("Read Control byte: 0x%02x\n", val8);
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_read) |
ESC_ADDR_MAP_SYNCMANAGER_STATUS;
ec_datagram_read(node, &val8, 1);
printf("Read status byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "Read status byte: 0x%02x", val8);
node->addr.position.off =
ESC_ADDR_MAP_SYNCMANAGER_NR(sync_manager_read) |
......@@ -726,19 +738,19 @@ void esc_mailbox_destroy(struct esc_mailbox *mailbox)
}
ssize_t esc_mailbox_write(struct esc_mailbox *mailbox, int type,
void *data, size_t len)
void *data, size_t len, struct timespec *timeout)
{
struct esc_mailbox_hdr *hdr;
uint8_t val8;
int ret;
time_t start = time(NULL);
struct timespec t_start;
if (mailbox->len_wr == 0) {
printf("len_wr == 0\n");
log_send(LOG_T_ERROR, "len_wr == 0");
return -1;
}
if (mailbox->len_wr < sizeof(struct esc_mailbox_hdr) + len ) {
printf("mailbox->len_wr to small: %d < %zu\n",
log_send(LOG_T_ERROR, "mailbox->len_wr to small: %d < %zu",
mailbox->len_wr, sizeof(struct esc_mailbox_hdr) + len);
return -1;
}
......@@ -753,14 +765,15 @@ ssize_t esc_mailbox_write(struct esc_mailbox *mailbox, int type,
mailbox->ctr++;
/* wait till mailbox is empty */
clock_gettime(CLOCK_MONOTONIC, &t_start);
do {
ret = ec_datagram_read(&mailbox->status_wr, &val8,
sizeof(val8));
if (ret != sizeof(val8)) {
printf("could not read mailbox status\n");
log_send(LOG_T_ERROR, "could not read mailbox status");
return -1;
}
} while ((val8 & 0x08) && (time(NULL) - start < ESC_COE_TIMEOUT));
} while ((val8 & 0x08) && !esc_timeout_expired(&t_start, timeout));
if (!(val8 & 0x08)) {
/* write mailbox contents */
......@@ -769,26 +782,29 @@ ssize_t esc_mailbox_write(struct esc_mailbox *mailbox, int type,
if (ret != mailbox->len_wr) {
return -1;
}
ret = len;
} else {
ret = 0;
}
return len;
return ret;
}
ssize_t esc_mailbox_read(struct esc_mailbox *mailbox, int *type,
void *data, size_t len)
void *data, size_t len, struct timespec *timeout)
{
struct esc_mailbox_hdr *hdr;
int ret;
size_t clen;
uint8_t val8;
time_t start = time(NULL);
struct timespec t_start;
if (mailbox->len_rd == 0) {
printf("len_rd == 0\n");
log_send(LOG_T_ERROR, "len_rd == 0");
return -1;
}
if (mailbox->len_rd < sizeof(struct esc_mailbox_hdr) + len ) {
printf("len_rd to short %d < %zu\n",
log_send(LOG_T_ERROR, "len_rd to short %d < %zu",
mailbox->len_rd, sizeof(struct esc_mailbox_hdr) + len);
return -1;
}
......@@ -796,13 +812,18 @@ ssize_t esc_mailbox_read(struct esc_mailbox *mailbox, int *type,
hdr = (struct esc_mailbox_hdr *)mailbox->buffer_rd;
/* wait untill mailbox full */
clock_gettime(CLOCK_MONOTONIC, &t_start);
do {
ret = ec_datagram_read(&mailbox->status_rd, &val8, sizeof(val8));
if (ret != sizeof(val8)) {
printf("Could not read mailbox status\n");
log_send(LOG_T_ERROR, "Could not read mailbox status");
return -1;
}
} while (!(val8 & 0x08) && (time(NULL) - start < ESC_COE_TIMEOUT));
} while (!(val8 & 0x08) && !esc_timeout_expired(&t_start, timeout));
if (!(val8 & 0x08)) {
return 0;
}
/* read mailbox contents */
ret = ec_datagram_read(&mailbox->data_rd, mailbox->buffer_rd,
......@@ -833,7 +854,8 @@ struct canopen_dev_priv {
int refcount;
};
static ssize_t esc_coe_send(struct canopen_dev *dev, void *req, size_t len)
static ssize_t esc_coe_send(struct canopen_dev *dev, void *req, size_t len,
struct timespec *timeout)
{
int ret;
unsigned char coereq[10];
......@@ -843,21 +865,25 @@ static ssize_t esc_coe_send(struct canopen_dev *dev, void *req, size_t len)
coereq[0] = 0x00;
coereq[1] = coe_type << 4;
ret = esc_mailbox_write(dev->priv->mbox, ESC_MAILBOX_TYPE_COE, coereq, len+2);
ret = esc_mailbox_write(dev->priv->mbox, ESC_MAILBOX_TYPE_COE, coereq,
len+2, timeout);
if (ret > 2)
return ret - 2;
return ret;
}
static ssize_t esc_coe_recv(struct canopen_dev *dev, void *res, size_t len)
static ssize_t esc_coe_recv(struct canopen_dev *dev, void *res, size_t len,
struct timespec *timeout)
{
int type;
int ret;
unsigned char coeres[10];
int coe_type;
ret = esc_mailbox_read(dev->priv->mbox, &type, coeres, len + 2);
ret = esc_mailbox_read(dev->priv->mbox, &type, coeres, len + 2, timeout);
if (ret == 0)
return 0;
if (type != ESC_MAILBOX_TYPE_COE) {
return -1;
}
......@@ -881,13 +907,16 @@ static void *esc_coe_emergency_poll(void *arg)
{
struct canopen_dev *dev = arg;
unsigned char cmd[8];
struct timespec timeout = { 0, 0 };
log_send(LOG_T_DEBUG, "Emergency poll thread started for CoE device %p",
dev);
while (1) {
sleep(1);
pthread_mutex_lock(&dev->lock);
dev->recv_response(dev, cmd, 8);
dev->recv_response(dev, cmd, 8, &timeout);
pthread_mutex_unlock(&dev->lock);
}
......@@ -1009,7 +1038,7 @@ int esc_pdo_tx_set(struct ec_dgram_addr *addr,
ESC_SYNCMANAGER_CONTROL_INT_PDI;
if (watchdog)
val8 |= ESC_SYNCMANAGER_CONTROL_WATCHDOG_ENABLE;
printf("PDO tx Control byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "PDO tx Control byte: 0x%02x", val8);
ec_datagram_write(addr, &val8, 1);
......@@ -1054,7 +1083,7 @@ int esc_pdo_rx_set(struct ec_dgram_addr *addr,
addr->addr.position.off = ESC_ADDR_MAP_SYNCMANAGER_NR(sm->sm) |
ESC_ADDR_MAP_SYNCMANAGER_CONTROL;
val8 = ESC_SYNCMANAGER_CONTROL_INT_PDI;
printf("PDO rx Control byte: 0x%02x\n", val8);
log_send(LOG_T_DEBUG, "PDO rx Control byte: 0x%02x", val8);
ec_datagram_write(addr, &val8, 1);
if (sm->len) {
......
......@@ -251,9 +251,9 @@ struct esc_mailbox *esc_mailbox_create(struct ec_dgram_addr *node,
void esc_mailbox_reinit(struct ec_dgram_addr *node,
struct esc_syncmanager_info *rd, struct esc_syncmanager_info *wr);
ssize_t esc_mailbox_read(struct esc_mailbox *mailbox, int *type,
void *data, size_t len);
void *data, size_t len, struct timespec *timeout);
ssize_t esc_mailbox_write(struct esc_mailbox *mailbox, int type,
void *data, size_t len);
void *data, size_t len, struct timespec *timeout);
void esc_mailbox_destroy(struct esc_mailbox *mailbox);
struct canopen_dev *esc_coe_create(struct esc_mailbox *mailbox);
......
......@@ -14,8 +14,9 @@
#include <netinet/in.h> // for ntohs()
#include <net/ethernet.h> // for struct ether_header
#include "ec_bsd.h"
//#include "ec_bsd.h"
#include "ec_int.h"
#include "log.h"
struct sockaddr_ll {
uint16_t sll_family;
......@@ -51,7 +52,7 @@ int bpf_open(void)
i++;
}
printf("fd: %d\n", fd);
log_send(LOG_T_DEBUG, "bpf_open() fd: %d", fd);
return fd;
}
......@@ -72,9 +73,9 @@ int bpf_set_write_filter(int bpf_fd)
wfilter.bf_len = 1;
wfilter.bf_insns = pass_all_filt;
printf("fdd: %d\n", bpf_fd);
log_send(LOG_T_DEBUG, "bpf_fd: %d", bpf_fd);
if (ioctl(bpf_fd, BIOCSETWF, &wfilter) < 0)
err(1, "bpf_set_write_filter(): BIOCSETWF");
log_send(LOG_T_ERROR, "bpf_set_write_filter(): BIOCSETWF");
return 0;
}
......@@ -115,8 +116,8 @@ int eth_open(char *if_name)
if (bpf_buf == NULL)
err(1, "couldn't allocate bpf_buf memory");
printf("cap_len: %d\n", bpf_buf_len);
printf("ec_sock: %d\n", ec_sock);
log_send(LOG_T_DEBUG, "cap_len: %d", bpf_buf_len);
log_send(LOG_T_DEBUG, "ec_sock: %d", ec_sock);
sockaddr_ll.sll_addr[0] = 0xff;
sockaddr_ll.sll_addr[1] = 0xff;
......