1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/ieee801254_*: do not use HAL array

This commit is contained in:
Jose Alamos 2022-08-17 14:57:18 +02:00
parent 4d81677afd
commit f75631026b
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9
5 changed files with 111 additions and 94 deletions

View File

@ -1,25 +1,29 @@
include ../Makefile.tests_common
BOARD_WHITELIST := \
adafruit-clue \
adafruit-itsybitsy-nrf52 \
arduino-nano-33-ble \
cc2538dk \
feather-nrf52840 \
native \
nrf52840dk \
nrf52840dongle \
nrf52840-mdk \
omote \
openmote-cc2538 \
reel \
remote-pa \
remote-reva \
remote-revb \
pba-d-01-kw2x \
#
# Due to missing Kconfig support, whitelist boards that are known to have a
# working Kconfig dependency resolution.
# Other boards should still work when running with CONTINUE_ON_EXPECTED_ERRORS=1
DISABLE_MODULE += auto_init_at86rf2xx auto_init_nrf802154
BOARD_WHITELIST += adafruit-clue \
adafruit-itsybitsy-nrf52 \
arduino-nano-33-ble \
cc2538dk \
feather-nrf52840 \
native \
nrf52840dk \
nrf52840dongle \
nrf52840-mdk \
nucleo-l152re \
nucleo-f303re \
nucleo-wl55jc \
omote \
openmote-cc2538 \
reel \
remote-pa \
remote-reva \
remote-revb \
pba-d-01-kw2x \
#
ifeq ($(BOARD), native)
ZEP_PORT_BASE ?= 17754

View File

@ -30,10 +30,6 @@
SOCKET_ZEP_MAX + \
IS_USED(MODULE_KW2XRF)
#if RADIOS_NUMOF == 0
#error "Radio is not supported"
#endif
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -18,6 +18,7 @@
* @}
*/
#include <stdio.h>
#include "assert.h"
#include "kernel_defines.h"
#include "net/ieee802154/radio.h"
@ -54,6 +55,14 @@ void ieee802154_hal_test_init_devs(ieee802154_dev_cb_t cb, void *opaque)
* `auto_init`) */
ieee802154_dev_t *radio = NULL;
(void) radio;
(void) cb;
(void) opaque;
if (RADIOS_NUMOF == 0) {
puts("Radio is either not supported or not present");
assert(false);
}
#ifdef MODULE_CC2538_RF
if ((radio = cb(IEEE802154_DEV_TYPE_CC2538_RF, opaque)) ){
cc2538_rf_hal_setup(radio);

View File

@ -61,7 +61,7 @@ static eui64_t ext_addr;
static network_uint16_t short_addr;
static uint8_t seq;
static ieee802154_dev_t _radio[RADIOS_NUMOF];
static ieee802154_dev_t _radio;
static void _print_packet(size_t size, uint8_t lqi, int16_t rssi)
{
@ -89,7 +89,7 @@ static int print_addr(int argc, char **argv)
static void _ack_timeout(event_t *event)
{
(void) event;
ieee802154_dev_t *dev = &_radio[0];
ieee802154_dev_t *dev = &_radio;
ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACCEPT);
}
@ -112,7 +112,7 @@ void _crc_error_handler(event_t *event)
{
(void) event;
puts("Frame with invalid CRC received");
ieee802154_dev_t* dev = &_radio[0];
ieee802154_dev_t* dev = &_radio;
/* Force transition to IDLE before calling the read function */
ieee802154_radio_set_idle(dev, true);
@ -130,7 +130,7 @@ void _rx_done_handler(event_t *event)
{
(void) event;
ieee802154_rx_info_t info;
ieee802154_dev_t* dev = &_radio[0];
ieee802154_dev_t* dev = &_radio;
/* Force transition to IDLE before calling the read function */
ieee802154_radio_set_idle(dev, true);
@ -140,7 +140,7 @@ void _rx_done_handler(event_t *event)
* NOTE: It's possible to call `ieee802154_radio_len` to retrieve the packet
* length. Since the buffer is fixed in this test, we don't use it
*/
int size = ieee802154_radio_read(&_radio[0], buffer, 127, &info);
int size = ieee802154_radio_read(&_radio, buffer, 127, &info);
if (size > 0) {
/* Print packet while we wait for the state transition */
_print_packet(size, info.lqi, info.rssi);
@ -179,10 +179,10 @@ static void _tx_finish_handler(event_t *event)
(void) event;
/* The TX_DONE event indicates it's safe to call the confirm counterpart */
expect(ieee802154_radio_confirm_transmit(&_radio[0], &tx_info) >= 0);
expect(ieee802154_radio_confirm_transmit(&_radio, &tx_info) >= 0);
ieee802154_radio_set_rx(&_radio[0]);
if (!ieee802154_radio_has_irq_ack_timeout(&_radio[0]) && !ieee802154_radio_has_frame_retrans(&_radio[0])) {
ieee802154_radio_set_rx(&_radio);
if (!ieee802154_radio_has_irq_ack_timeout(&_radio) && !ieee802154_radio_has_frame_retrans(&_radio)) {
/* This is just to show how the MAC layer would handle ACKs... */
xtimer_set(&timer_ack, ACK_TIMEOUT_TIME);
}
@ -204,7 +204,7 @@ static void _tx_finish_handler(event_t *event)
puts("");
if (ieee802154_radio_has_frame_retrans_info(&_radio[0])) {
if (ieee802154_radio_has_frame_retrans_info(&_radio)) {
printf("Retransmission attempts: %i\n", tx_info.retrans);
}
@ -218,19 +218,19 @@ static event_t _tx_finish_ev = {
static void _send(iolist_t *pkt)
{
/* Request a state change to IDLE */
if (ieee802154_radio_request_set_idle(&_radio[0], false) < 0) {
if (ieee802154_radio_request_set_idle(&_radio, false) < 0) {
puts("Couldn't send frame");
return;
}
/* Write the packet to the radio while the radio is transitioning to IDLE */
ieee802154_radio_write(&_radio[0], pkt);
ieee802154_radio_write(&_radio, pkt);
/* Block until the radio confirms the state change */
while(ieee802154_radio_confirm_set_idle(&_radio[0]) == -EAGAIN);
while(ieee802154_radio_confirm_set_idle(&_radio) == -EAGAIN);
/* Set the frame filter to receive ACKs */
ieee802154_radio_set_frame_filter_mode(&_radio[0], IEEE802154_FILTER_ACK_ONLY);
ieee802154_radio_set_frame_filter_mode(&_radio, IEEE802154_FILTER_ACK_ONLY);
/* Trigger the transmit and wait for the mutex unlock (TX_DONE event).
* Spin if the radio is busy before transmission (this indicates the
@ -238,7 +238,7 @@ static void _send(iolist_t *pkt)
* This won't be necessary anymore when the upper layers take care
* of the IFS.
*/
while (ieee802154_radio_request_transmit(&_radio[0]) == -EBUSY) {}
while (ieee802154_radio_request_transmit(&_radio) == -EBUSY) {}
mutex_lock(&lock);
event_post(EVENT_PRIO_HIGHEST, &_tx_finish_ev);
@ -273,8 +273,9 @@ static ieee802154_dev_t *_reg_callback(ieee802154_dev_type_t type, void *opaque)
return NULL;
}
reg->count++;
puts("Success");
return &_radio[reg->count++];
return &_radio;
}
static int _init(void)
@ -285,7 +286,7 @@ static int _init(void)
ieee802154_hal_test_init_devs(_reg_callback, &reg);
/* Set the Event Notification */
((ieee802154_dev_t*) &_radio[0])->cb = _hal_radio_cb;
((ieee802154_dev_t*) &_radio)->cb = _hal_radio_cb;
/* Note that addresses are not kept in the radio. This assumes MAC layers
* already have a copy of the address */
@ -294,39 +295,39 @@ static int _init(void)
/* Since the device was already initialized, turn on the radio.
* The transceiver state will be "TRX_OFF" */
res = ieee802154_radio_request_on(&_radio[0]);
res = ieee802154_radio_request_on(&_radio);
expect(res >= 0);
while(ieee802154_radio_confirm_on(&_radio[0]) == -EAGAIN) {}
while(ieee802154_radio_confirm_on(&_radio) == -EAGAIN) {}
ieee802154_radio_set_frame_filter_mode(&_radio[0], IEEE802154_FILTER_ACCEPT);
ieee802154_radio_set_frame_filter_mode(&_radio, IEEE802154_FILTER_ACCEPT);
uint16_t panid = CONFIG_IEEE802154_DEFAULT_PANID;
/* Set all IEEE addresses */
res = ieee802154_radio_config_addr_filter(&_radio[0],
res = ieee802154_radio_config_addr_filter(&_radio,
IEEE802154_AF_SHORT_ADDR, &short_addr);
expect(res >= 0);
res = ieee802154_radio_config_addr_filter(&_radio[0],
res = ieee802154_radio_config_addr_filter(&_radio,
IEEE802154_AF_EXT_ADDR, &ext_addr);
expect(res >= 0);
res = ieee802154_radio_config_addr_filter(&_radio[0],
res = ieee802154_radio_config_addr_filter(&_radio,
IEEE802154_AF_PANID, &panid);
expect(res >= 0);
/* Set PHY configuration */
ieee802154_phy_conf_t conf = {.channel=CONFIG_IEEE802154_DEFAULT_CHANNEL, .page=CONFIG_IEEE802154_DEFAULT_SUBGHZ_PAGE, .pow=CONFIG_IEEE802154_DEFAULT_TXPOWER};
res = ieee802154_radio_config_phy(&_radio[0], &conf);
res = ieee802154_radio_config_phy(&_radio, &conf);
expect(res >= 0);
/* ieee802154_radio_set_cca_mode*/
res = ieee802154_radio_set_cca_mode(&_radio[0], IEEE802154_CCA_MODE_ED_THRESHOLD);
res = ieee802154_radio_set_cca_mode(&_radio, IEEE802154_CCA_MODE_ED_THRESHOLD);
expect(res >= 0);
res = ieee802154_radio_set_cca_threshold(&_radio[0], CONFIG_IEEE802154_CCA_THRESH_DEFAULT);
res = ieee802154_radio_set_cca_threshold(&_radio, CONFIG_IEEE802154_CCA_THRESH_DEFAULT);
expect(res >= 0);
/* Set the transceiver state to RX_ON in order to receive packets */
ieee802154_radio_set_rx(&_radio[0]);
ieee802154_radio_set_rx(&_radio);
return 0;
}
@ -378,17 +379,17 @@ int _cca(int argc, char **argv)
(void) argv;
int res;
if (ieee802154_radio_has_irq_cca_done(&_radio[0])) {
if (ieee802154_radio_request_cca(&_radio[0]) < 0) {
if (ieee802154_radio_has_irq_cca_done(&_radio)) {
if (ieee802154_radio_request_cca(&_radio) < 0) {
puts("Couldn't perform CCA");
return -ENODEV;
}
mutex_lock(&lock);
res = ieee802154_radio_confirm_cca(&_radio[0]);
res = ieee802154_radio_confirm_cca(&_radio);
expect(res >= 0);
}
else {
res = ieee802154_radio_cca(&_radio[0]);
res = ieee802154_radio_cca(&_radio);
}
if (res > 0) {
@ -410,12 +411,12 @@ int _test_states(int argc, char **argv)
xtimer_ticks32_t a;
/* Force transition to IDLE */
res = ieee802154_radio_set_idle(&_radio[0], true);
res = ieee802154_radio_set_idle(&_radio, true);
assert(res == 0);
printf("Testing TX<->RX transition time: ");
a = xtimer_now();
res = ieee802154_radio_set_rx(&_radio[0]);
res = ieee802154_radio_set_rx(&_radio);
assert(res == 0);
usecs = xtimer_usec_from_ticks(xtimer_diff(xtimer_now(), a));
printf("%" PRIu32 " us (%s)\n", usecs, usecs > MAX_TX_RX_TURNAROUND
@ -424,14 +425,14 @@ int _test_states(int argc, char **argv)
printf("Testing RX<->TX transition time");
a = xtimer_now();
res = ieee802154_radio_set_idle(&_radio[0], true);
res = ieee802154_radio_set_idle(&_radio, true);
assert(res == 0);
usecs = xtimer_usec_from_ticks(xtimer_diff(xtimer_now(), a));
printf("%" PRIu32 " us (%s)\n", usecs, usecs > MAX_TX_RX_TURNAROUND
? "FAIL"
: "PASS");
ieee802154_radio_set_rx(&_radio[0]);
ieee802154_radio_set_rx(&_radio);
return 0;
}
@ -478,7 +479,7 @@ static int promisc(int argc, char **argv)
puts("Disabled promiscuos mode");
}
return ieee802154_radio_set_frame_filter_mode(&_radio[0], conf);
return ieee802154_radio_set_frame_filter_mode(&_radio, conf);
}
int config_phy(int argc, char **argv)
@ -527,7 +528,7 @@ int config_phy(int argc, char **argv)
return 1;
}
ieee802154_dev_t *dev = &_radio[0];
ieee802154_dev_t *dev = &_radio;
ieee802154_radio_set_idle(dev, true);
ieee802154_phy_conf_t conf = {.phy_mode=phy_mode, .channel=channel, .page=0, .pow=tx_pow};
if (ieee802154_radio_config_phy(dev, &conf) < 0) {
@ -545,7 +546,7 @@ int config_phy(int argc, char **argv)
int txmode_cmd(int argc, char **argv)
{
ieee802154_dev_t *dev = &_radio[0];
ieee802154_dev_t *dev = &_radio;
int res = -EINVAL;
if (argc < 2) {
@ -578,7 +579,7 @@ int txmode_cmd(int argc, char **argv)
static int _config_cca_cmd(int argc, char **argv)
{
ieee802154_dev_t *dev = &_radio[0];
ieee802154_dev_t *dev = &_radio;
int res = -EINVAL;
ieee802154_cca_mode_t mode;
@ -641,63 +642,63 @@ static int _caps_cmd(int argc, char **argv)
bool has_phy_mr_ofdm = false;
bool has_phy_mr_fsk = false;
if (ieee802154_radio_has_frame_retrans(&_radio[0])) {
if (ieee802154_radio_has_frame_retrans(&_radio)) {
has_frame_retrans = true;
}
if (ieee802154_radio_has_auto_csma(&_radio[0])) {
if (ieee802154_radio_has_auto_csma(&_radio)) {
has_auto_csma = true;
}
if (ieee802154_radio_has_24_ghz(&_radio[0])) {
if (ieee802154_radio_has_24_ghz(&_radio)) {
has_24_ghz = true;
}
if (ieee802154_radio_has_sub_ghz(&_radio[0])) {
if (ieee802154_radio_has_sub_ghz(&_radio)) {
has_sub_ghz = true;
}
if (ieee802154_radio_has_irq_tx_done(&_radio[0])) {
if (ieee802154_radio_has_irq_tx_done(&_radio)) {
has_irq_tx_done = true;
}
if (ieee802154_radio_has_irq_rx_start(&_radio[0])) {
if (ieee802154_radio_has_irq_rx_start(&_radio)) {
has_irq_rx_start = true;
}
if (ieee802154_radio_has_irq_ack_timeout(&_radio[0])) {
if (ieee802154_radio_has_irq_ack_timeout(&_radio)) {
has_irq_ack_timeout = true;
}
if (ieee802154_radio_has_irq_cca_done(&_radio[0])) {
if (ieee802154_radio_has_irq_cca_done(&_radio)) {
has_irq_cca_done = true;
}
if (ieee802154_radio_has_frame_retrans_info(&_radio[0])) {
if (ieee802154_radio_has_frame_retrans_info(&_radio)) {
has_frame_retrans_info = true;
}
if (ieee802154_radio_has_phy_bpsk(&_radio[0])) {
if (ieee802154_radio_has_phy_bpsk(&_radio)) {
has_phy_bpsk = true;
}
if (ieee802154_radio_has_phy_ask(&_radio[0])) {
if (ieee802154_radio_has_phy_ask(&_radio)) {
has_phy_ask = true;
}
if (ieee802154_radio_has_phy_oqpsk(&_radio[0])) {
if (ieee802154_radio_has_phy_oqpsk(&_radio)) {
has_phy_oqpsk = true;
}
if (ieee802154_radio_has_phy_mr_oqpsk(&_radio[0])) {
if (ieee802154_radio_has_phy_mr_oqpsk(&_radio)) {
has_phy_mr_oqpsk = true;
}
if (ieee802154_radio_has_phy_mr_ofdm(&_radio[0])) {
if (ieee802154_radio_has_phy_mr_ofdm(&_radio)) {
has_phy_mr_ofdm = true;
}
if (ieee802154_radio_has_phy_mr_fsk(&_radio[0])) {
if (ieee802154_radio_has_phy_mr_fsk(&_radio)) {
has_phy_mr_fsk = true;
}

View File

@ -1,23 +1,30 @@
include ../Makefile.tests_common
#
# Due to missing Kconfig support, whitelist boards that are known to have a
# working Kconfig dependency resolution.
# Other boards should still work when running with CONTINUE_ON_EXPECTED_ERRORS=1
BOARD_WHITELIST += adafruit-clue \
adafruit-itsybitsy-nrf52 \
arduino-nano-33-ble \
cc2538dk \
feather-nrf52840 \
native \
nrf52840dk \
nrf52840dongle \
nrf52840-mdk \
nucleo-l152re \
nucleo-f303re \
nucleo-wl55jc \
omote \
openmote-cc2538 \
reel \
remote-pa \
remote-reva \
remote-revb \
pba-d-01-kw2x \
#
BOARD_WHITELIST := \
adafruit-clue \
adafruit-itsybitsy-nrf52 \
arduino-nano-33-ble \
cc2538dk \
feather-nrf52840 \
native \
nrf52840dk \
nrf52840dongle \
nrf52840-mdk \
omote \
openmote-cc2538 \
reel \
remote-pa \
remote-reva \
remote-revb \
pba-d-01-kw2x \
#
USEMODULE += od
USEMODULE += shell
USEMODULE += shell_cmds_default