Skip to content
Draft
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
23 changes: 14 additions & 9 deletions drivers/ethos/ethos.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@

static void _end_of_frame(ethos_t *dev)
{
switch(dev->frametype) {

Check warning on line 137 in drivers/ethos/ethos.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'switch' not followed by a single space
case ETHOS_FRAME_TYPE_DATA:
netdev_trigger_event_isr(&dev->netdev);
break;
Expand Down Expand Up @@ -233,7 +233,7 @@
const uint8_t *out;
int n;

switch(c) {

Check warning on line 236 in drivers/ethos/ethos.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'switch' not followed by a single space
case ETHOS_FRAME_DELIMITER:
out = _esc_delim;
n = 2;
Expand Down Expand Up @@ -266,7 +266,7 @@
}

/* send frame content */
while(len--) {

Check warning on line 269 in drivers/ethos/ethos.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'while' not followed by a single space
_write_escaped(dev->uart, *data++);
}

Expand All @@ -278,14 +278,14 @@

static int _send(netdev_t *netdev, const iolist_t *iolist)
{
ethos_t * dev = (ethos_t *) netdev;
(void)dev;
ethos_t * dev = container_of(netdev, ethos_t, netdev);

/* count total packet length */
size_t pktlen = iolist_count_total(iolist);

/* lock line in order to prevent multiple writes */
mutex_lock(&dev->out_mutex);
dev->tx_result = -EAGAIN;

/* send start-frame-delimiter */
uint8_t frame_delim = ETHOS_FRAME_DELIMITER;
Expand All @@ -295,16 +295,18 @@
for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {
size_t n = iol->iol_len;
uint8_t *ptr = iol->iol_base;
while(n--) {

Check warning on line 298 in drivers/ethos/ethos.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'while' not followed by a single space
_write_escaped(dev->uart, *ptr++);
}
}

uart_write(dev->uart, &frame_delim, 1);

dev->tx_result = (int)pktlen;
mutex_unlock(&dev->out_mutex);

return pktlen;
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
return 0;
}

static void _get_mac_addr(netdev_t *encdev, uint8_t* buf)
Expand Down Expand Up @@ -356,8 +358,8 @@

static int _recv(netdev_t *netdev, void *buf, size_t len, void* info)
{
(void) info;
ethos_t * dev = (ethos_t *) netdev;
(void)info;
ethos_t * dev = container_of(netdev, ethos_t, netdev);
int res = 0;

if (buf) {
Expand Down Expand Up @@ -417,7 +419,10 @@
res = (int)tsrb_avail(&dev->inbuf);
}
}
return res;

dev->tx_result = res;
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
return 0;
}

static int _get(netdev_t *dev, netopt_t opt, void *value, size_t max_len)
Expand All @@ -442,11 +447,11 @@
return res;
}

static int _confirm_send(netdev_t *dev, void *info)
static int _confirm_send(netdev_t *netdev, void *info)
{
(void)dev;
(void)info;
return -EOPNOTSUPP;
ethos_t * dev = container_of(netdev, ethos_t, netdev);
return dev->tx_result;
}

/* netdev interface */
Expand Down
1 change: 1 addition & 0 deletions drivers/include/ethos.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ typedef struct {
line_state_t state; /**< Line status variable */
unsigned frametype; /**< type of currently incoming frame */
mutex_t out_mutex; /**< mutex used for locking concurrent sends */
int tx_result; /**< result to report in confirm_send() */
} ethos_t;

/**
Expand Down