LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Read Garbage

If you read binary data you should turn of software flow control and disable terminal characters!

 

If you use the approach BrokenArrow posted, make shure your input buffer is configured big enough 😉

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 11 of 14
(1,063 Views)

My first code did similar to what you suggest.  I was basically writing the command to our device asking it to spit back the EE data, waiting a set amount of time (more than enough to get it all), and then reading.  It had the same issue.  I moved to the continuous read because I thought the amount of data I was transmitting might have been too large and messing it up.  There are 1024 data locations so I thought it might just be too much to wait as it filled the buffer.

 

I just find it odd that the only place this occurs is at the start of the data.  It is always in the first of the 4 blocks (they all come at once though).  I wondered if it might be something where it gets out of sync for a bit but not sure the best way to avoid it.  I may try to go back to checking for a full buffer before reading the data.  Anything is worth a shot right now.

 

My current solution is to allow 10 attempts at a good read.  Usually by attempts 4-6 I get a complete valid set of data.  Another option would be to read each location individually, or at least some of them indifidually, but that would take awhile even skipping the unused areas.

0 Kudos
Message 12 of 14
(1,042 Views)

 


 

Jshu23 wrote:

[...]

There are 1024 data locations so I thought it might just be too much to wait as it filled the buffer.

[...]

Another option would be to read each location individually,...[...]


 

If I understand, 1024 data locations would be 2048 bytes. The default buffer size is 4096.

 

Yep, one-character-at-a-time is another idea. There are posts about how to do that.

 

BTW, on that little PIC I was reading (and I forgot how much EEPROM it had) my notes say it took 3.5 seconds to read all the data with that 35mS timer. I forgot why I chose 35ms. Probably pulled it out of my Smiley Surprised

 

Richard






0 Kudos
Message 13 of 14
(1,033 Views)

Thats a good point about the buffer size relative to amount of data I read.  There are a few more bytes than 2048 when considering the echo of my command to read and then all the spaces and EOL's (I think they count too).  Either way it should still be enough not to fill up.

 

The one character idea is just slower because I need to ask for each location (000 thru 3FF) by name rather than just saying "give me the EE data" and letting the whole thing spit back to me.  1024 read/writes to the device rather than 1.

0 Kudos
Message 14 of 14
(1,026 Views)