reparied arduino stuff

This commit is contained in:
2020-12-21 18:14:03 +01:00
parent 2372ddef78
commit b0434a3d72
4 changed files with 82 additions and 13 deletions

View File

@ -1,5 +1,6 @@
#include <bsp_hosted/comIF/ArduinoComIF.h>
#include <bsp_hosted/comIF/ArduinoCookie.h>
#include "ArduinoComIF.h"
#include "ArduinoCookie.h"
#include <fsfw/globalfunctions/DleEncoder.h>
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
@ -7,6 +8,8 @@
// This only works on Linux
#ifdef LINUX
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#elif WIN32
#include <windows.h>
#include <strsafe.h>
@ -254,7 +257,7 @@ ReturnValue_t ArduinoComIF::sendMessage(uint8_t command,
encodedLen = sizeof(sendBuffer) - remainingLen;
#ifdef LINUX
ssize_t writtenlen = write(serialPort, sendBuffer, encodedLen);
ssize_t writtenlen = ::write(serialPort, sendBuffer, encodedLen);
if (writtenlen < 0) {
//we could try to find out what happened...
return RETURN_FAILED;
@ -285,7 +288,7 @@ void ArduinoComIF::handleSerialPortRx() {
rxBuffer.writeData(dataFromSerial, bytesRead);
uint8_t dataReceivedSoFar[rxBuffer.maxSize()];
uint8_t dataReceivedSoFar[rxBuffer.getMaxSize()];
uint32_t dataLenReceivedSoFar = 0;
@ -295,11 +298,11 @@ void ArduinoComIF::handleSerialPortRx() {
//look for STX
size_t firstSTXinRawData = 0;
while ((firstSTXinRawData < dataLenReceivedSoFar)
&& (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX)) {
&& (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR)) {
firstSTXinRawData++;
}
if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX) {
if (dataReceivedSoFar[firstSTXinRawData] != DleEncoder::STX_CHAR) {
//there is no STX in our data, throw it away...
rxBuffer.deleteData(dataLenReceivedSoFar);
return;