Avoid some harsh, inappropriate DEBUGASSERT's.

This commit is contained in:
Gregory Nutt 2017-08-05 12:32:31 -06:00
parent 7ed665833f
commit 2947ca06c9
3 changed files with 53 additions and 13 deletions

View File

@ -686,6 +686,9 @@ Configurations
some additional fixes for byte ordering in 16-bit and 64-bit some additional fixes for byte ordering in 16-bit and 64-bit
compressed IPv6 addresses, then all tests are working as expected: compressed IPv6 addresses, then all tests are working as expected:
TCP, UDP, Telnet. TCP, UDP, Telnet.
2017-08-5: It looks like I have lost one of my Clicker2-STM32 boards.
This means that I will not be able to do any regression testing as
changes are made to the radio interfaces and 6LoWPAN :(
nsh: nsh:

View File

@ -959,9 +959,22 @@ static void spirit_interrupt_work(FAR void *arg)
if (irqstatus.IRQ_RX_FIFO_ERROR != 0) if (irqstatus.IRQ_RX_FIFO_ERROR != 0)
{ {
wlwarn("WARNING: Rx FIFO Error\n"); wlwarn("WARNING: Rx FIFO Error\n");
DEBUGVERIFY(spirit_command(spirit, CMD_FLUSHRXFIFO));
/* Discard RX data */
DEBUGVERIFY(spirit_command(spirit, CMD_FLUSHRXFIFO));
irqstatus.IRQ_RX_DATA_READY = 0;
irqstatus.IRQ_VALID_SYNC = 0;
/* Revert the receiving state */
if (priv->state == DRIVER_STATE_RECEIVING)
{
priv->state = DRIVER_STATE_IDLE; priv->state = DRIVER_STATE_IDLE;
}
/* Update error statistics */
NETDEV_RXERRORS(&priv->radio.r_dev); NETDEV_RXERRORS(&priv->radio.r_dev);
NETDEV_ERRORS(&priv->radio.r_dev); NETDEV_ERRORS(&priv->radio.r_dev);
@ -976,9 +989,21 @@ static void spirit_interrupt_work(FAR void *arg)
irqstatus.IRQ_MAX_RE_TX_REACH != 0) irqstatus.IRQ_MAX_RE_TX_REACH != 0)
{ {
wlwarn("WARNING: Tx FIFO Error/Max retries\n"); wlwarn("WARNING: Tx FIFO Error/Max retries\n");
DEBUGVERIFY(spirit_command(spirit, COMMAND_FLUSHTXFIFO));
/* Discard TX data */
DEBUGVERIFY(spirit_command(spirit, COMMAND_FLUSHTXFIFO));
irqstatus.IRQ_TX_DATA_SENT = 0;
/* Revert the sending state */
if (priv->state == DRIVER_STATE_SENDING)
{
priv->state = DRIVER_STATE_IDLE; priv->state = DRIVER_STATE_IDLE;
}
/* Update error statistics */
NETDEV_TXERRORS(&priv->radio.r_dev); NETDEV_TXERRORS(&priv->radio.r_dev);
NETDEV_ERRORS(&priv->radio.r_dev); NETDEV_ERRORS(&priv->radio.r_dev);
@ -1031,9 +1056,17 @@ static void spirit_interrupt_work(FAR void *arg)
if (irqstatus.IRQ_VALID_SYNC != 0) if (irqstatus.IRQ_VALID_SYNC != 0)
{ {
wlinfo("Valid sync\n"); wlinfo("Valid sync\n");
/* I have seen multiple Valid Sync interrupts following an RX error
* condition.
*/
if (priv->state != DRIVER_STATE_RECEIVING)
{
DEBUGASSERT(priv->state == DRIVER_STATE_IDLE); DEBUGASSERT(priv->state == DRIVER_STATE_IDLE);
priv->state = DRIVER_STATE_RECEIVING; priv->state = DRIVER_STATE_RECEIVING;
} }
}
/* The IRQ_RX_DATA_READY notifies that a new packet has been received */ /* The IRQ_RX_DATA_READY notifies that a new packet has been received */

View File

@ -124,8 +124,6 @@
#ifdef HAVE_BYTEADDR #ifdef HAVE_BYTEADDR
static void sixlowpan_baddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *baddr) static void sixlowpan_baddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *baddr)
{ {
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
/* Big-endian uint16_t to byte order */ /* Big-endian uint16_t to byte order */
baddr[0] = ipaddr[7] >> 8 ^ 0x02; baddr[0] = ipaddr[7] >> 8 ^ 0x02;
@ -135,8 +133,6 @@ static void sixlowpan_baddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *badd
#ifdef HAVE_SADDR #ifdef HAVE_SADDR
static void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *saddr) static void sixlowpan_saddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *saddr)
{ {
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
/* Big-endian uint16_t to byte order */ /* Big-endian uint16_t to byte order */
saddr[0] = ipaddr[7] >> 8; saddr[0] = ipaddr[7] >> 8;
@ -181,7 +177,7 @@ static void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *eadd
* *
* 128 112 96 80 64 48 32 16 * 128 112 96 80 64 48 32 16
* ---- ---- ---- ---- ---- ---- ---- ---- * ---- ---- ---- ---- ---- ---- ---- ----
* fe80 0000 0000 0000 0000 00ff fe00 xx00 1-byte short address IEEE 48-bit MAC * xxxx 0000 0000 0000 0000 00ff fe00 xx00 1-byte short address IEEE 48-bit MAC
* xxxx 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC * xxxx 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short address IEEE 48-bit MAC
* xxxx 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64 * xxxx 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended address IEEE EUI-64
* *
@ -218,6 +214,16 @@ int sixlowpan_destaddrfromip(FAR struct sixlowpan_driver_s *radio,
/* Otherwise, the destination MAC address is encoded in the IP address */ /* Otherwise, the destination MAC address is encoded in the IP address */
/* Check for compressible link-local address.
* REVISIT: This should not restrict us to link-local addresses.
*/
if (ipaddr[0] != HTONS(0xfe80) || ipaddr[1] != 0 ||
ipaddr[2] != 0 || ipaddr[3] != 0)
{
return -EADDRNOTAVAIL;
}
#ifdef CONFIG_WIRELESS_PKTRADIO #ifdef CONFIG_WIRELESS_PKTRADIO
/* If this is a packet radio, then we cannot know the correct size of the /* If this is a packet radio, then we cannot know the correct size of the
* radio's MAC address without asking. The setting CONFIG_PKTRADIO_ADDRLEN * radio's MAC address without asking. The setting CONFIG_PKTRADIO_ADDRLEN
@ -242,8 +248,6 @@ int sixlowpan_destaddrfromip(FAR struct sixlowpan_driver_s *radio,
return ret; return ret;
} }
DEBUGASSERT(ipaddr[0] == HTONS(0xfe80));
#ifdef HAVE_BYTEADDR #ifdef HAVE_BYTEADDR
if (properties.sp_addrlen == 1 && if (properties.sp_addrlen == 1 &&
SIXLOWPAN_IS_IID_8BIT_COMPRESSABLE(ipaddr)) SIXLOWPAN_IS_IID_8BIT_COMPRESSABLE(ipaddr))