Browse Source

if pkt too large, ignore, restart rx on err/timeout, loop processing schedule..

The first one is just more defensive programming, not sure if I'd seen
this failure..

The middle one did fix some hangs...

Last one is to ensure that the schedule processes more quickly and
not enforce each command to take one ms...
irr_shared
John-Mark Gurney 3 years ago
parent
commit
e77c0edcdc
1 changed files with 21 additions and 6 deletions
  1. +21
    -6
      irr_main.c

+ 21
- 6
irr_main.c View File

@@ -82,25 +82,29 @@ void
rxdone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) rxdone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
{ {


if (rxpktavail) {
memcpy(rxpkt, payload, MIN(sizeof rxpkt, size));
if (rxpktavail && size <= sizeof rxpkt) {
memcpy(rxpkt, payload, size);
rxpktbuf = (struct pktbuf){ rxpktbuf = (struct pktbuf){
.pkt = rxpkt, .pkt = rxpkt,
.pktlen = size, .pktlen = size,
}; };
rxpktavail = false; rxpktavail = false;
} }
Radio.Rx(0);
} }


void void
rxtimeout(void) rxtimeout(void)
{ {


Radio.Rx(0);
} }


void void
rxerr(void) rxerr(void)
{ {

Radio.Rx(0);
} }


RadioEvents_t revents = { RadioEvents_t revents = {
@@ -225,16 +229,26 @@ start_sched(struct sched *sched)
set_chan(sched->chan, 1); set_chan(sched->chan, 1);
} }


static void
process_sched()
static bool
canproc_sched()
{ {


/* nothing to do? */ /* nothing to do? */
if (schedcnt == 0) if (schedcnt == 0)
return;
return false;


/* not yet expired */ /* not yet expired */
if (uwTick < SCHED_HEAD.end_wait_tick) if (uwTick < SCHED_HEAD.end_wait_tick)
return false;

return true;
}

static void
process_sched()
{

if (!canproc_sched())
return; return;


if (SCHED_HEAD.cmd == CMD_RUNFOR) if (SCHED_HEAD.cmd == CMD_RUNFOR)
@@ -390,7 +404,8 @@ main()
//Radio.Rx(0); //Radio.Rx(0);


loop: loop:
process_sched();
while (canproc_sched())
process_sched();


BoardLowPowerHandler(); BoardLowPowerHandler();
if (Radio.IrqProcess != NULL) if (Radio.IrqProcess != NULL)


Loading…
Cancel
Save