Click here to Skip to main content
15,894,825 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMessage Closed Pin
2-May-18 23:33
Lapmangfpt2-May-18 23:33 
AnswerRe: help: list<struct> of list<string> Pin
Victor Nijegorodov2-May-18 23:57
Victor Nijegorodov2-May-18 23:57 
QuestionThe Breakpoint will not be hit the Source Code is different then the orignal Pin
ForNow30-Apr-18 16:08
ForNow30-Apr-18 16:08 
AnswerRe: The Breakpoint will not be hit the Source Code is different then the orignal Pin
Richard MacCutchan30-Apr-18 21:32
mveRichard MacCutchan30-Apr-18 21:32 
GeneralRe: The Breakpoint will not be hit the Source Code is different then the orignal Pin
ForNow1-May-18 15:53
ForNow1-May-18 15:53 
QuestionWhat are the best mocking frameworks available on Linux? Pin
Hila Berger29-Apr-18 2:13
Hila Berger29-Apr-18 2:13 
JokeRe: What are the best mocking frameworks available on Linux? Pin
Randor 29-Apr-18 15:32
professional Randor 29-Apr-18 15:32 
AnswerRe: What are the best mocking frameworks available on Linux? Pin
leon de boer29-Apr-18 17:10
leon de boer29-Apr-18 17:10 
AnswerRe: What are the best mocking frameworks available on Linux? Pin
IlanGreen1-May-18 2:37
IlanGreen1-May-18 2:37 
GeneralRe: What are the best mocking frameworks available on Linux? Pin
Hila Berger13-May-18 0:49
Hila Berger13-May-18 0:49 
GeneralRe: What are the best mocking frameworks available on Linux? Pin
IlanGreen13-May-18 1:15
IlanGreen13-May-18 1:15 
GeneralRe: What are the best mocking frameworks available on Linux? Pin
Hila Berger14-May-18 20:38
Hila Berger14-May-18 20:38 
QuestionInvalid operands to binary expression Pin
Member 1380291228-Apr-18 7:03
Member 1380291228-Apr-18 7:03 
AnswerRe: Invalid operands to binary expression Pin
Richard MacCutchan28-Apr-18 22:18
mveRichard MacCutchan28-Apr-18 22:18 
GeneralRe: Invalid operands to binary expression Pin
Member 1380291229-Apr-18 10:21
Member 1380291229-Apr-18 10:21 
GeneralRe: Invalid operands to binary expression Pin
Richard MacCutchan29-Apr-18 21:02
mveRichard MacCutchan29-Apr-18 21:02 
GeneralRe: Invalid operands to binary expression Pin
Member 1486266714-Jun-20 2:38
Member 1486266714-Jun-20 2:38 
GeneralRe: Invalid operands to binary expression Pin
Richard MacCutchan14-Jun-20 4:30
mveRichard MacCutchan14-Jun-20 4:30 
GeneralRe: Invalid operands to binary expression Pin
Member 1486266714-Jun-20 20:50
Member 1486266714-Jun-20 20:50 
GeneralRe: Invalid operands to binary expression Pin
Richard MacCutchan14-Jun-20 22:17
mveRichard MacCutchan14-Jun-20 22:17 
QuestionData packet was cut when sending from Arduino Uno to Raspberry Pi 3 in C++ Pin
Ahmad ZULKIPLEE24-Apr-18 23:26
Ahmad ZULKIPLEE24-Apr-18 23:26 
AnswerRe: Data packet was cut when sending from Arduino Uno to Raspberry Pi 3 in C++ Pin
Jochen Arndt25-Apr-18 0:17
professionalJochen Arndt25-Apr-18 0:17 
The answer is obvious:
You have to rewrite your code to be able to handle incomplete packages.

You got incomplete packets because you stop receiving if any number of data has been received (even a single byte/character). That would be the normal behaviour. The only reason why that happens not very often is that the system has to service also other tasks. And that is not done while waiting (see end of my post)!

Because you are sending only a single kind of data, you can change the data being send using a fixed length format by using leading zeroes:
C++
sprintf(dataToSend, "R%03dE T%03dE", valpotRoulis, valpotTangage);
That makes parsing much simpler (e.g. using scanf()) and you can wait for the known number of characters (11 + line feed):
const int CMD_LENGTH = 12; // Or whatever applies
while(n < CMD_LENGTH && i < 1000000);
By the way: what is the purpose of the undefined variable i here?

But when doing so you will run more into the already existing performance problem of using a polling loop. Waiting for the data wastes a lot of time (10 ms) that is not available for other tasks.

The solution is to put the receiving into an own thread and use the fine Qt signaling features. Because there are only two event data values, there is even no need to use shared variables.
GeneralRe: Data packet was cut when sending from Arduino Uno to Raspberry Pi 3 in C++ Pin
Ahmad ZULKIPLEE25-Apr-18 2:15
Ahmad ZULKIPLEE25-Apr-18 2:15 
GeneralRe: Data packet was cut when sending from Arduino Uno to Raspberry Pi 3 in C++ Pin
Jochen Arndt25-Apr-18 3:06
professionalJochen Arndt25-Apr-18 3:06 
AnswerRe: Data packet was cut when sending from Arduino Uno to Raspberry Pi 3 in C++ Pin
Richard MacCutchan25-Apr-18 0:19
mveRichard MacCutchan25-Apr-18 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.