Serial not reading entire line

Typically: "How do I... ", "How can I... " questions
Post Reply
jlouis2k4
Posts: 13
Joined: 29 Sep 2013, 06:03

Serial not reading entire line

Post by jlouis2k4 » 21 Feb 2018, 22:27

Hello there,

I am sending v-rep a line of data, but it is only being read in chunks when I use simSerialRead. The differnece in input and output data are shown in the link below:
https://imgur.com/a/HyOXN

The code used to read and print the serial data is provided below:

Code: Select all

if (sim_call_type==sim_childscriptcall_actuation) then
    countReadChar=simSerialCheck(serial)
    if countReadChar>0 then
        str=simSerialRead(serial,5000,false,'\n',0) 
        simAddStatusbarMessage(str)
    end
end
Please let me know if I need to reconstruct the data myself or if there is an easier inbuilt way to do that.

Thanks!

coppelia
Site Admin
Posts: 6625
Joined: 14 Dec 2012, 00:25

Re: Serial not reading entire line

Post by coppelia » 22 Feb 2018, 07:50

Hello,

yes, you will have to assemble the chuncks yourself, or at least wait until the serial buffer has enough data to read and only read as many chars as one line contains.
If you operate from a threaded child script, you could read in a blocking fashion, and use * as the closing string.

Cheers

Post Reply