Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket_zep: properly implement the radio HAL #19213

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
fixup! socket_zep: simulate RSSI
  • Loading branch information
benpicco committed Feb 2, 2025
commit f1ba2ef9e20d7c6945df0c692d4a4e49dd30be2d
16 changes: 10 additions & 6 deletions cpu/native/socket_zep/socket_zep.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,14 @@
uint8_t ack[3];
zep_v2_data_hdr_t hdr;

/* sending ACK should only happen if we received a frame */
assert(zepdev->state == ZEPDEV_STATE_RX_RECV);
/* ACK request bit should be set if we get here */
assert((rxbuf[0] & IEEE802154_FCF_ACK_REQ) != 0);
benpicco marked this conversation as resolved.
Show resolved Hide resolved

DEBUG("socket_zep::send_ack: seq_no: %u\n", rxbuf[2]);

_zep_hdr_fill(zepdev, &hdr.hdr, sizeof(ack) + 2);
_zep_hdr_fill(zepdev, &hdr.hdr, sizeof(ack) + IEEE802154_FCF_LEN);

ack[0] = IEEE802154_FCF_TYPE_ACK; /* FCF */
ack[1] = 0; /* FCF */
Expand Down Expand Up @@ -320,7 +322,7 @@
DEBUG("socket_zep::_socket_isr: %d bytes on %d\n", res, fd);

if (res < (int)sizeof(zep_v2_data_hdr_t)) {
DEBUG("socket_zep::_socket_isr: frame too short %d < %zu\n", res, sizeof(zep_v2_data_hdr_t));

Check warning on line 325 in cpu/native/socket_zep/socket_zep.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
benpicco marked this conversation as resolved.
Show resolved Hide resolved
benpicco marked this conversation as resolved.
Show resolved Hide resolved
goto out;
}

Expand Down Expand Up @@ -581,21 +583,20 @@
ieee802154_rx_info_t *info)
{
socket_zep_t *zepdev = dev->priv;
int res = 0;
size_t res;

DEBUG("socket_zep::read: reading up to %zu bytes into %p\n", max_size, buf);

if (buf == NULL || zepdev->rcv_len == 0) {
goto out;
return 0;
}

DEBUG("socket_zep::read: %zu/%zu bytes into %p\n",
max_size, zepdev->rcv_len - sizeof(zep_v2_data_hdr_t) - IEEE802154_FCS_LEN, buf);

if (max_size != zepdev->rcv_len - sizeof(zep_v2_data_hdr_t) - IEEE802154_FCS_LEN) {
DEBUG("socket_zep::read: size mismatch!\n");
res = -EINVAL;
goto out;
return -EINVAL;
}

zep_v2_data_hdr_t *zep = (zep_v2_data_hdr_t *)zepdev->rcv_buf;
Expand All @@ -609,9 +610,12 @@

/* return payload size without frame checksum */
res = zep->length - IEEE802154_FCS_LEN;
if (res > max_size) {
return -ENOBUFS;
}

/* skip the ZEP header, just copy payload without FCS */
memcpy(buf, zep + 1, res);
out:
return res;
}

Expand Down
Loading