Click here to Skip to main content
15,885,985 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: Data packet was cut when sending from Arduino Uno to Raspberry Pi 3 in C++ Pin
leon de boer25-Apr-18 15:05
leon de boer25-Apr-18 15:05 
QuestionFrom framebuffer to SPI via ioctl in Linux Pin
Vaclav_23-Apr-18 3:16
Vaclav_23-Apr-18 3:16 
AnswerRe: From framebuffer to SPI via ioctl in Linux Pin
Jochen Arndt23-Apr-18 3:59
professionalJochen Arndt23-Apr-18 3:59 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Vaclav_23-Apr-18 4:17
Vaclav_23-Apr-18 4:17 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Jochen Arndt23-Apr-18 4:24
professionalJochen Arndt23-Apr-18 4:24 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Vaclav_23-Apr-18 8:08
Vaclav_23-Apr-18 8:08 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Jochen Arndt23-Apr-18 10:28
professionalJochen Arndt23-Apr-18 10:28 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Vaclav_23-Apr-18 13:39
Vaclav_23-Apr-18 13:39 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Jochen Arndt23-Apr-18 21:21
professionalJochen Arndt23-Apr-18 21:21 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Vaclav_24-Apr-18 12:16
Vaclav_24-Apr-18 12:16 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Jochen Arndt24-Apr-18 21:07
professionalJochen Arndt24-Apr-18 21:07 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Vaclav_25-Apr-18 3:36
Vaclav_25-Apr-18 3:36 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Jochen Arndt25-Apr-18 4:20
professionalJochen Arndt25-Apr-18 4:20 
GeneralRe: From framebuffer to SPI via ioctl in Linux Pin
Vaclav_25-Apr-18 9:11
Vaclav_25-Apr-18 9:11 

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.