forked from mohr/ArduinoIO
cosmetics
This commit is contained in:
parent
93a02c8db2
commit
ffc7e7eb7a
10
main.cpp
10
main.cpp
@ -4,6 +4,8 @@
|
||||
#include "helper/DleEncoder.h"
|
||||
#include "helper/crc_ccitt.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
//SPI is formally a library, so it is not part of the objects compiled
|
||||
//from the core and we need to include it explicitly
|
||||
#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];
|
||||
buffer[0] = DleEncoder::STX;
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
@ -63,10 +66,9 @@ void handlePacket(uint8_t *packet, size_t packetLen) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint16_t payloadLen = (packet[2] << 8) | packet[3];
|
||||
|
||||
if (payloadLen + 6 != packetLen) {
|
||||
if (payloadLen != packetLen - 6) {
|
||||
//Serial.println("invalid len");
|
||||
return;
|
||||
}
|
||||
@ -104,7 +106,6 @@ void handleNewData() {
|
||||
|
||||
if (rawData[firstSTXinRawData] != DleEncoder::STX) {
|
||||
//there is no STX in our data, throw it away...
|
||||
Serial.println(firstSTXinRawData);
|
||||
ringBuffer.deleteData(rawDataSize);
|
||||
return;
|
||||
}
|
||||
@ -144,7 +145,6 @@ void setup() {
|
||||
CS_PORT = 0xff;
|
||||
Serial.begin(9600);
|
||||
SPI.begin();
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
Loading…
Reference in New Issue
Block a user