Fixed bug thata was failing to process frames without preamble

This commit is contained in:
Pawel Spychalski (DzikuVx)
2017-11-09 19:52:52 +01:00
parent 1057c0995c
commit 1a031aba3f
4 changed files with 9 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
{ {
"board": "bsfrance:avr:lora32u4", "board": "bsfrance:avr:lora32u4",
"sketch": "crossbow.ino", "sketch": "crossbow.ino",
"port": "COM15", "port": "COM19",
"output": "./build" "output": "./build"
} }

View File

@@ -272,14 +272,14 @@ void loop(void)
#ifdef DEVICE_MODE_TX #ifdef DEVICE_MODE_TX
if (txDeviceState.readPacket) { if (txDeviceState.readPacket) {
int incomingByte = LoRa.read(); int incomingByte;
if (incomingByte > -1) { while (incomingByte = LoRa.read(), incomingByte > -1)
{
qspDecodeIncomingFrame(&qsp, incomingByte, ppm, &rxDeviceState, &txDeviceState); qspDecodeIncomingFrame(&qsp, incomingByte, ppm, &rxDeviceState, &txDeviceState);
} else {
txDeviceState.rssi = getRadioRssi();
txDeviceState.snr = getRadioSnr();
txDeviceState.readPacket = false;
} }
txDeviceState.rssi = getRadioRssi();
txDeviceState.snr = getRadioSnr();
txDeviceState.readPacket = false;
} }
#endif #endif

View File

@@ -161,7 +161,7 @@ void qspDecodeIncomingFrame(
{ {
qsp->frameDecodingStartedAt = millis(); qsp->frameDecodingStartedAt = millis();
qsp->protocolState = QSP_STATE_CHANNEL_RECEIVED; qsp->protocolState = QSP_STATE_CHANNEL_RECEIVED;
qsp->crc ^= incomingByte; qsp->crc = 0 ^ incomingByte;
qspClearPayload(qsp); qspClearPayload(qsp);

View File

@@ -18,7 +18,7 @@
#define CHANNEL_ID 0x01 #define CHANNEL_ID 0x01
#define QSP_PAYLOAD_LENGTH 32 #define QSP_PAYLOAD_LENGTH 32
#define QSP_MAX_FRAME_DECODE_TIME 10 //max time that frame can be decoded in ms #define QSP_MAX_FRAME_DECODE_TIME 5 //max time that frame can be decoded in ms
#define QSP_FRAME_RC_DATA 0x0 #define QSP_FRAME_RC_DATA 0x0
#define QSP_FRAME_RX_HEALTH 0x1 #define QSP_FRAME_RX_HEALTH 0x1