View Single Post
  #1   Spotlight this post!  
Unread 27-01-2014, 10:34
wre136's Avatar
wre136 wre136 is offline
Registered User
AKA: Will Edds
FRC #2461 (The METAL-SKINS)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Oklahoma City
Posts: 30
wre136 is an unknown quantity at this point
Getting Input from Serial Interface

I am looking to get data from the serial interface on the cRIO. However, I am having some issues.

I can use the open serial VI and the read serial VI (WPI Robotics Library-> Communications -> Serial Port). However, I'm not sure how to read data. The Read VI allows me to select the number of bytes I want to read. I'm not sure how much to read. We are connecting the CH Robotics UM6 Position sensor (Attached is its datasheet) to the serial and the packet lengths can be anywhere from 7 to 71 bytes in size depending on what length is given in the Packet type header of the packet.

I can say "always grab 7" but since not all packets are that length, I may not grab all the data I need and that will mess up the read of another packet. In addition to that, most of the packets I grab are not structured right. I might grab a data where the packet starts half way through the data, meaning I have an incomplete packet now. I'm not sure how to grab the bytes from the serial and have the code figure it out as I go.

To make things simple, I need to know a good strategy on how to grab the correct amount of data from a serial port and read it to decide how much more data I need to get, and then continue to get that amount.

Would a state machine do the trick or is there a better way to do this? I am a complete novice at data communications.
Attached Files
File Type: pdf UM6_datasheet.pdf (1.39 MB, 7 views)
Reply With Quote