Timing Problem dummy solution

This commit is contained in:
Lukas Loidold 2020-04-23 14:39:34 +02:00
parent 39c171c186
commit 8536d04868

View File

@ -43,12 +43,7 @@ void sendData(uint8_t *data, size_t len) {
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return; return;
} }
for (size_t i = 0; i < writtenLen; i++)
{
Serial.print("buffer is: ");Serial.println(buffer[i]);
}
Serial.write(buffer, writtenLen); Serial.write(buffer, writtenLen);
} }
@ -59,9 +54,9 @@ void transferSPI(uint8_t address, uint8_t *data, size_t datalen) {
//included //included
for (size_t i = 0; i < datalen; i++) for (size_t i = 0; i < datalen; i++)
{ {
Serial.print("SentData is: ");Serial.println(data[i]); //Serial.print("SentData is: ");Serial.println(data[i]);
data[i] = SPI.transfer(data[i]); data[i] = SPI.transfer(data[i]);
Serial.print("Back from n-1 ");Serial.println(data[i]); //Serial.print("Back from n-1 ");Serial.println(data[i]);
} }
//SPI.transfer(data, datalen); //SPI.transfer(data, datalen);
@ -83,14 +78,14 @@ void handlePacket(uint8_t *packet, size_t packetLen) {
if (crc != 0) { if (crc != 0) {
Serial.println("invalid Checksum"); //Serial.println("invalid Checksum");
return; return;
} }
uint16_t payloadLen = (packet[2] << 8) | packet[3]; uint16_t payloadLen = (packet[2] << 8) | packet[3];
if (payloadLen != packetLen - 6) { if (payloadLen != packetLen - 6) {
Serial.println("invalid len"); //Serial.println("invalid len");
return; return;
} }
@ -105,14 +100,11 @@ void handlePacket(uint8_t *packet, size_t packetLen) {
//echo the data back, no need to change the header fields, they are the same //echo the data back, no need to change the header fields, they are the same
//checksum will be written by sendData() //checksum will be written by sendData()
//check reply: //check reply:
Serial.println("Data response check: ");
for(size_t i =0; i< packetLen; i++){
Serial.print("packet nr ");Serial.print(i);Serial.print(" ");Serial.println(packet[i]);
}
sendData(packet, packetLen); sendData(packet, packetLen);
break; break;
default: default:
Serial.println("invalid command"); //Serial.println("invalid command");
break; break;
} }
@ -129,13 +121,13 @@ void handleNewData() {
size_t firstSTXinRawData = 0; size_t firstSTXinRawData = 0;
while ((firstSTXinRawData < rawDataSize) while ((firstSTXinRawData < rawDataSize)
&& (rawData[firstSTXinRawData] != DleEncoder::STX)) { && (rawData[firstSTXinRawData] != DleEncoder::STX)) {
Serial.println(rawData[firstSTXinRawData]); //Serial.println(rawData[firstSTXinRawData]);
firstSTXinRawData++; firstSTXinRawData++;
} }
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("NO STX"); //Serial.println("NO STX");
ringBuffer.deleteData(rawDataSize); ringBuffer.deleteData(rawDataSize);
return; return;
} }