Program: 5516
Project: 5516
Buggy source:
private boolean setState(RadioState state){
  if (DEBUG)   log("String_Node_Str" + stateMachine + "String_Node_Str"+ state);
  stateMachine=state;
  registers[REG_FSMSTAT0]=(registers[REG_FSMSTAT0] & 0x3f);
switch (stateMachine) {
case VREG_OFF:
    if (DEBUG)     log("String_Node_Str");
  flushRX();
flushTX();
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
registers[REG_RSSISTAT]=0;
crcOk=false;
reset();
setMode(MODE_POWER_OFF);
updateCCA();
break;
case POWER_DOWN:
rxFIFO.reset();
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
registers[REG_RSSISTAT]=0;
crcOk=false;
reset();
setMode(MODE_POWER_OFF);
updateCCA();
break;
case RX_CALIBRATE:
setSymbolEvent(12);
setMode(MODE_RX_ON);
break;
case RX_SFD_SEARCH:
zeroSymbols=0;
if ((status & STATUS_RSSI_VALID) == 0) {
setSymbolEvent(8);
}
updateCCA();
setMode(MODE_RX_ON);
break;
case TX_CALIBRATE:
setSymbolEvent(12 + 2);
setMode(MODE_TXRX_ON);
break;
case TX_PREAMBLE:
shrPos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case TX_FRAME:
txfifoPos=0;
crcOk=false;
txNext();
break;
case RX_WAIT:
setSymbolEvent(8);
setMode(MODE_RX_ON);
break;
case IDLE:
status&=~STATUS_RSSI_VALID;
registers[REG_RSSISTAT]=0;
setMode(MODE_TXRX_OFF);
updateCCA();
break;
case TX_ACK_CALIBRATE:
status|=STATUS_TX_ACTIVE;
setSymbolEvent(12 + 2 + 2);
setMode(MODE_TXRX_ON);
break;
case TX_ACK_PREAMBLE:
shrPos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case TX_ACK:
ackPos=0;
crcOk=false;
ackNext();
break;
case RX_FRAME:
rxFIFO.mark();
rxread=0;
frameRejected=false;
shouldAck=false;
crcOk=false;
break;
}
stateChanged(stateMachine.state);
return true;
}

Fixed version (ground truth):
private boolean setState(RadioState state){
  if (DEBUG)   log("String_Node_Str" + stateMachine + "String_Node_Str"+ state);
  stateMachine=state;
  memory[REG_FSMSTAT0]=(memory[REG_FSMSTAT0] & 0x3f);
switch (stateMachine) {
case VREG_OFF:
    if (DEBUG)     log("String_Node_Str");
  flushRX();
flushTX();
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
memory[REG_RSSISTAT]=0;
crcOk=false;
reset();
setMode(MODE_POWER_OFF);
updateCCA();
break;
case POWER_DOWN:
rxFIFO.reset();
status&=~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE);
memory[REG_RSSISTAT]=0;
crcOk=false;
reset();
setMode(MODE_POWER_OFF);
updateCCA();
break;
case RX_CALIBRATE:
setSymbolEvent(12);
setMode(MODE_RX_ON);
break;
case RX_SFD_SEARCH:
zeroSymbols=0;
if ((status & STATUS_RSSI_VALID) == 0) {
setSymbolEvent(8);
}
updateCCA();
setMode(MODE_RX_ON);
break;
case TX_CALIBRATE:
setSymbolEvent(12 + 2);
setMode(MODE_TXRX_ON);
break;
case TX_PREAMBLE:
shrPos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case TX_FRAME:
txfifoPos=0;
crcOk=false;
txNext();
break;
case RX_WAIT:
setSymbolEvent(8);
setMode(MODE_RX_ON);
break;
case IDLE:
status&=~STATUS_RSSI_VALID;
memory[REG_RSSISTAT]=0;
setMode(MODE_TXRX_OFF);
updateCCA();
break;
case TX_ACK_CALIBRATE:
status|=STATUS_TX_ACTIVE;
setSymbolEvent(12 + 2 + 2);
setMode(MODE_TXRX_ON);
break;
case TX_ACK_PREAMBLE:
shrPos=0;
SHR[0]=0;
SHR[1]=0;
SHR[2]=0;
SHR[3]=0;
SHR[4]=0x7A;
shrNext();
break;
case TX_ACK:
ackPos=0;
crcOk=false;
ackNext();
break;
case RX_FRAME:
rxFIFO.mark();
rxread=0;
frameRejected=false;
shouldAck=false;
crcOk=false;
break;
}
stateChanged(stateMachine.state);
return true;
}