Commit 5319a9bf authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Fix BSD ethernet code

parent f9559d7f
......@@ -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++) {
......
Supports Markdown
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