Jump to content

Serial port streaming data


johnbrowning

Recommended Posts

Ok I’m a total newb at labview, having said that the only things I’ve done in it is play with dials reading from daq and what not. I have been beating my head against a wall for 2 weeks trying to read a continuous stream of serial data from a port. Everybody keeps telling me just use VB but I really want to learn this program so any help will be greatly appreciated. I will post the vi’s some of which i got here and screen caps at end of post. First let me tell you what I’m trying to do and got working. In hyperterminal I open com port 40 hit enter then a message appears with some setting information, then I hit ctrl-g (hex 07 the bel command) which starts the stream there is no need to send anything else it just keeps streaming. In labview I was able to finally get the ctrl-g to send correctly which starts the stream, but I’m only able to receive 500 bytes or so. I’m sure I have to create a loop of some kind which clears the buffer for the next line of characters but I don’t know how. I’m including a comport capture of the data in the text file, “A 496 512 504 496Z” as you can see those three digit numbers can be anywhere between 1 to 4 numbers long. If you don’t know how long there going to be how can you set the length of the buffer? As you can see I tried to use IO assistant which again only received about 500 bytes. When I try to auto parse or even add it somehow, it looks for a certain number of packets but it never stops sending so it just locks up. Anyway please take a look at his and tell me the obvious thing I must be overlooking.

Link to comment

After 500 ms it is not unreasonable that you've only received 500 bytes, at least if the device has a delay in its response...so if the message is longer you could just wait a bit more prior to checking how many bytes you have received.

The buffer length can be adjusted, however it's a good idea to not rely on the buffer. A general receiver (when no termination chars are used) checks the number of bytes in a loop. After each check wait a certain time prior to the next check and if no more data has been received terminate the loop. This "interbyte" wait should at least be longer than the transmission time for a single byte (preferably a bit longer, I typically use 20-50 ms) . It can also be a good idea to have a timeout so that the loop will stop if no reply ever comes and/or if the reply turns out to be continous....

Attached is a VI (SerialIO) for such serial communication (it can be used for read, write and read&write operations).

Regards,

Mads

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.