Quote Originally Posted by Lesiok View Post
Yes, and now you have to analyze whether the data are complete or not.

This is normal. Serial port knows nothing about packets. Serial port is a stream of bytes. You have to divide the stream into packets and handle them. It should look something like this
Qt Code:
  1. void MyObject::toReadThePort()
  2. {
  3.  
  4. if(serial->isReadable())
  5. {
  6.  
  7. ArrayBuffer.append(serial->readAll());
  8. while(ArrayBuffer.size() >= ExpectedPacketLength)
  9. {
  10. QByteArray one_packet = ArrayBuffer.left(ExpectedPacketLength);
  11. // Here processing of one_packet
  12. ArrayBuffer.remove(0,ExpectedPacketLength);//delete processed packet
  13. }
  14. receiveData();
  15. }
  16. }
To copy to clipboard, switch view to plain text mode 
Of course I not tried to compile it - it is only a sketch.
I did what you said. And it became more stable. Actually it is working at lower frequency. But i need 2.5kHz. It's working at 500 Hz now.

I changed my code like this :

Qt Code:
  1. while(ArrayBuffer.size() >= ExpectedPacketLength)
  2. {
  3. indexOfType = ArrayBuffer.indexOf('s');
  4.  
  5. if(indexOfType >= 1)
  6. {
  7. ArrayBuffer.remove(0,indexOfType);
  8. }
  9.  
  10. QByteArray one_packet = ArrayBuffer.left(ExpectedPacketLength);
  11. ArrayBuffer.remove(0,ExpectedPacketLength);
  12.  
  13. if(one_packet[0] == 's') // 's' buldur kodu yaz dene!
  14. {
  15. for(dummyCounter=0;dummyCounter<ExpectedPacketLength;dummyCounter++)
  16. {
  17.  
  18. dummyArray[dummyCounter] = one_packet[dummyCounter];
  19. shortArray[dummyCounter] = one_packet[dummyCounter];
  20. }
  21.  
  22. CRCValue = crcsum(&dummyArray[0],ExpectedPacketLength,CRC_INIT); // Just Checking the CRCValue. not gonna use anywhere.
  23. ReceiveIsSuccessful = crcverify(&dummyArray[0],ExpectedPacketLength);
  24.  
  25. if(ReceiveIsSuccessful == 1) // Checking if CRC is OK or not
  26. { .. parse and logging process is here..}
To copy to clipboard, switch view to plain text mode 

Now here is the other problem:

When i'm trying to get data at 2.5kHz terminal goes like this :

Everything is okay to some point. But when any error occurs (like CRC can be wrong) QT cant keep the data instaneously at that time.
https://postimg.org/image/ilb3tg0d5/

So i added to my code this :

Qt Code:
  1. if(ArrayBuffer.size() >= 20000){
  2. .. then the code is the same i wrote above..
To copy to clipboard, switch view to plain text mode 

Now it's getting better:

https://postimg.org/image/iml1mv26x/

But as we can see suddenly data are escaping from the buffer after its full. When i increment the 20000 to 100000 or much far away its getting better. However board will always send data constantly.

How can i solve this ? I tried to clear the ArrayBuffer after a chunk of data (20000) have been processed. But it didnt fix it. Any idea about this ?

Because i'm thinking QSerialPort cant handle the high frequency communication. Maybe internal read buffer size isn't enough ?

Thanks for help.