cosmetics

This commit is contained in:
Ulrich Mohr 2020-04-15 17:50:30 +02:00
parent 93a02c8db2
commit ffc7e7eb7a

View File

@ -4,6 +4,8 @@
#include "helper/DleEncoder.h" #include "helper/DleEncoder.h"
#include "helper/crc_ccitt.h" #include "helper/crc_ccitt.h"
#include <avr/io.h>
//SPI is formally a library, so it is not part of the objects compiled //SPI is formally a library, so it is not part of the objects compiled
//from the core and we need to include it explicitly //from the core and we need to include it explicitly
#include "arduino_core/ArduinoCore-avr/libraries/SPI/src/SPI.h" #include "arduino_core/ArduinoCore-avr/libraries/SPI/src/SPI.h"
@ -35,7 +37,8 @@ void sendData(uint8_t *data, size_t len) {
uint8_t buffer[2 * len + 2]; uint8_t buffer[2 * len + 2];
buffer[0] = DleEncoder::STX; buffer[0] = DleEncoder::STX;
size_t writtenLen; size_t writtenLen;
ReturnValue_t result = DleEncoder::encode(data,len,buffer,sizeof(buffer),&writtenLen, true); ReturnValue_t result = DleEncoder::encode(data, len, buffer, sizeof(buffer),
&writtenLen, true);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return; return;
} }
@ -63,10 +66,9 @@ void handlePacket(uint8_t *packet, size_t packetLen) {
return; return;
} }
uint16_t payloadLen = (packet[2] << 8) | packet[3]; uint16_t payloadLen = (packet[2] << 8) | packet[3];
if (payloadLen + 6 != packetLen) { if (payloadLen != packetLen - 6) {
//Serial.println("invalid len"); //Serial.println("invalid len");
return; return;
} }
@ -104,7 +106,6 @@ void handleNewData() {
if (rawData[firstSTXinRawData] != DleEncoder::STX) { if (rawData[firstSTXinRawData] != DleEncoder::STX) {
//there is no STX in our data, throw it away... //there is no STX in our data, throw it away...
Serial.println(firstSTXinRawData);
ringBuffer.deleteData(rawDataSize); ringBuffer.deleteData(rawDataSize);
return; return;
} }
@ -144,7 +145,6 @@ void setup() {
CS_PORT = 0xff; CS_PORT = 0xff;
Serial.begin(9600); Serial.begin(9600);
SPI.begin(); SPI.begin();
pinMode(LED_BUILTIN, OUTPUT);
} }
void loop() { void loop() {