LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Missing HEX characters from scanned string

Hi everyone,
I have a program which scans a continuous string of serial data which is divided into header, data and checksum. I have replaced the serial part of my code with a simple string input to simulate the data input for testing and as in the diagram below you can see 0A, 0C and 0D are missing and I can't figure out why. Currently it is an exercise to parse out all the data I need for a data aquisition system. If anyone can help me out with this I would greatly appreciate it. This was in a different thread but it has dissapeared into the ether. Here is the picture illustrating the problem.

Thanks again
Stirling

Message Edited by stirlsilver on 04-09-2007 06:17 PM

Message 1 of 6
(3,108 Views)

The reason it is not working the way you expect is that the scan from screen function only scans up to the next white space character.  (Look up "Format Specifiers Syntax Elements" in help.  I'll quote

"s—String (for example, abc). When scanning, s matches only up to the next white-space character. A space matches one or more consecutive white-space characters."

That led me to the question what is a white space character?  I found in the help for White Space? function

"Returns TRUE if char represents a white space character, such as Space, Tab, Newline, Carriage Return, Form Feed, or Vertical Tab."

Well 0A is 10 for line feed or new line, 0C is 12 or form feed, 0D is 13 or carriage return.

I would recommend eliminating the scan from string function since it won't work with these special hex characters.  Perhaps other functions such as string subset will work better.  Or convert the string to a byte array, and index the array accordingly to get the various components.

0 Kudos
Message 2 of 6
(3,096 Views)
If you still want to use the scan from string function, use the wild card char (^) in the format sting : %3[^ ] %1[^ ] %2[^ ] %2[^ ]...
Chilly Charly    (aka CC)
Message 3 of 6
(3,091 Views)

You are doing all this way too complicated. There is absolutely no need to use "scan from string" to simply chop up a string into parts. Use string subset instead (in a loop).

You also have way too much duplicate code. You can operate on arrays directly and use array indicators for the channels. This reduces the complexity of your diagram 10 fold!!!

I don't have your serial hardware, but attached is a small code fragment (LV 8.0) that seems to do about the same thing with your string using 10% of your code. Modify as needed. Let me know if anything is not clear.

0 Kudos
Message 4 of 6
(3,085 Views)
Wow,
Thanks for all your replies! I can't get over how much simpler this other code is! I'm going to have to sit down and actually figure out how it all works! I didn't know that the scan from string function eliminated all the white space characters. It's good to know. I'm very  new to the labView scene so I really do have a lot to learn.
Stirling
0 Kudos
Message 5 of 6
(3,073 Views)

Message Edited by stirlsilver on 04-10-2007 04:33 AM

0 Kudos
Message 6 of 6
(3,068 Views)