Jump to content

Creat a data packet in serial communication


hannibal

Recommended Posts

Hi Hannibal,

Serial communication isn't really packet based unless you make it so. Use the LabVIEW example finder and do a search for "serial." Open the "Basic Serial Write and Read.vi" example to check out how to work with a serial port.

Once you get the basics down, if you still think you need "packets" you can create your own serial "packets" by transmitting some kind of header and footer like this:

"<Packet>your data here</Packet>"

Your reader can then be polling the serial port for available bytes at a pace that doesn't eat up the cpu but fast enough not to let the serial port hardware buffer overflow. When bytes are available, read them and append the read data to a string buffer. Scan the string buffer for "<Packet>" followed by "</Packet>." If both are found, remove that part of the string from the buffer, and process it for your data.

You can do the same kind of markup with TCP/IP. This is a great way of sending large amounts of data, like flattened custom data types etc.

Hope this helps.

Link to comment
Thanks Petr. I'll try it.

Hihi, Neville, I know, it's really like your homework but as for me, it's a problem.

Thanks anyway

Well Hannibal,

if it really is a "problem" for you, take a look at this link:

How to ask Questions the smart way

People are more than willing to help each other on this forum. But if you want help, explain your application, post some code, show us what you have already tried before posting a question here.

Another good place for help is the Examples that already ship with LabVIEW.

Neville.

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
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.