From a800031b0ad2d065c4f12fd9fdf02395d62e3e09 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Thu, 26 Oct 2017 13:51:34 +0200 Subject: [PATCH] close #15 --- .vscode/arduino.json | 2 +- README.md | 4 +--- crossbow.ino | 1 - qsp.cpp | 22 ---------------------- qsp.h | 1 - variables.h | 2 -- 6 files changed, 2 insertions(+), 30 deletions(-) diff --git a/.vscode/arduino.json b/.vscode/arduino.json index e0b924b..8b7bafb 100644 --- a/.vscode/arduino.json +++ b/.vscode/arduino.json @@ -1,6 +1,6 @@ { "board": "bsfrance:avr:lora32u4", "sketch": "crossbow.ino", - "port": "COM17", + "port": "COM15", "output": "./build" } \ No newline at end of file diff --git a/README.md b/README.md index e101224..b2f59f2 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,8 @@ Development, not yet functional | 1 | Preamble | "Q" 0x51 | | 2 | Channel ID | channel used for comunication between TX and RX | | 3 | Frame type & Length | bits 7-5 defines frame, bits 4-0 payload length | -| 4 | Packet ID | | | 5 - 36 | Payload | 32 bytes max | -| payload length + 5 | CRC | XOR of all previous bytes | +| payload length + 4 | CRC | XOR of all previous bytes | ## Frame types @@ -48,7 +47,6 @@ Total length of `RC_DATA` payload is 9 bytes | 3 | RX supply volatage, sent in 0,1V | | 4 | RX analog input 1 sent in 0,1V | | 5 | RX analog input 2 sent in 0,1V | -| 6 | Last received packet ID | ### `PING` and `PONG` frames diff --git a/crossbow.ino b/crossbow.ino index 56a89bf..ea48a69 100644 --- a/crossbow.ino +++ b/crossbow.ino @@ -11,7 +11,6 @@ // #define WAIT_FOR_SERIAL #include -// #include #include "variables.h" #include "sbus.h" #include "qsp.h" diff --git a/qsp.cpp b/qsp.cpp index 54b0454..07a0978 100644 --- a/qsp.cpp +++ b/qsp.cpp @@ -60,7 +60,6 @@ void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSta qsp->payload[2] = rxDeviceState->rxVoltage; qsp->payload[3] = rxDeviceState->a1Voltage; qsp->payload[4] = rxDeviceState->a2Voltage; - qsp->payload[5] = qsp->lastReceivedPacketId; qsp->payloadLength = 6; } @@ -71,7 +70,6 @@ void decodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceSta rxDeviceState->rxVoltage = qsp->payload[2]; rxDeviceState->a1Voltage = qsp->payload[3]; rxDeviceState->a2Voltage = qsp->payload[4]; - // rxDeviceState->rssi = qsp->payload[0]; //TODO we skipped decoding this byte, figure it out } /** @@ -127,13 +125,6 @@ void encodeRcDataPayload(QspConfiguration_t *qsp, PPMReader *ppmSource, uint8_t qsp->payloadLength = 9; } -uint8_t qspGetPacketId() -{ - static uint8_t packetId = 0; - - return packetId++; -} - void qspClearPayload(QspConfiguration_t *qsp) { for (uint8_t i = 0; i < QSP_PAYLOAD_LENGTH; i++) @@ -148,7 +139,6 @@ void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int p static uint8_t frameId; static uint8_t payloadLength; static uint8_t receivedPayload; - static uint8_t packetId; //TODO move this to global scope maybe? if (qsp->protocolState == QSP_STATE_IDLE && incomingByte == QSP_PREAMBLE) { @@ -169,7 +159,6 @@ void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int p qspClearPayload(qsp); receivedPayload = 0; - packetId = 0; } else { @@ -188,12 +177,6 @@ void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int p } else if (qsp->protocolState == QSP_STATE_FRAME_TYPE_RECEIVED) { - qsp->crc ^= incomingByte; - packetId = incomingByte; - qsp->protocolState = QSP_STATE_PACKET_ID_RECEIVED; - } - else if (qsp->protocolState == QSP_STATE_PACKET_ID_RECEIVED) - { //Now it's time for payload qsp->crc ^= incomingByte; @@ -221,8 +204,6 @@ void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int p qsp->lastFrameReceivedAt[frameId] = millis(); } - qsp->lastReceivedPacketId = packetId; - if (qsp->debugConfig & DEBUG_FLAG_SERIAL) { Serial.print("Frame "); Serial.print(frameId); @@ -299,9 +280,6 @@ void qspEncodeFrame(QspConfiguration_t *qsp) { data |= (qsp->frameToSend << 4) & 0xf0; qsp->hardwareWriteFunction(data, qsp); - //Write packet ID - qsp->hardwareWriteFunction(qspGetPacketId(), qsp); - //Write payload for (uint8_t i = 0; i < qsp->payloadLength; i++) { diff --git a/qsp.h b/qsp.h index aa60e94..92abe68 100644 --- a/qsp.h +++ b/qsp.h @@ -9,7 +9,6 @@ uint8_t get10bitLowShift(uint8_t channel); void qspComputeCrc(QspConfiguration_t *qsp, uint8_t dataByte); void encodeRxHealthPayload(QspConfiguration_t *qsp, RxDeviceState_t *rxDeviceState); void encodeRcDataPayload(QspConfiguration_t *qsp, PPMReader *ppmSource, uint8_t noOfChannels); -uint8_t qspGetPacketId(void); void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int ppm[], RxDeviceState_t *rxDeviceState); void qspClearPayload(QspConfiguration_t *qsp); void qspEncodeFrame(QspConfiguration_t *qsp); diff --git a/variables.h b/variables.h index ab48bde..4769f95 100644 --- a/variables.h +++ b/variables.h @@ -41,7 +41,6 @@ enum dataStates { QSP_STATE_PREAMBLE_RECEIVED, QSP_STATE_CHANNEL_RECEIVED, QSP_STATE_FRAME_TYPE_RECEIVED, - QSP_STATE_PACKET_ID_RECEIVED, QSP_STATE_PAYLOAD_RECEIVED, QSP_STATE_CRC_RECEIVED }; @@ -79,7 +78,6 @@ struct QspConfiguration_t { uint32_t lastFrameTransmitedAt[QSP_FRAME_COUNT] = {0}; uint8_t deviceState = DEVICE_STATE_OK; void (* hardwareWriteFunction)(uint8_t, QspConfiguration_t*); - uint8_t lastReceivedPacketId = 0; bool canTransmit = false; bool forcePongFrame = false; uint8_t debugConfig = 0;