LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with reading information coming from a software into LabVIEW through Serial port

I think I must have missed something along the way. Are you sure you're not dealing with characters? 0x30313230 implies that if you look at the values as hexadecimal representations of the ASCII codes for the character 0 (zero), 1, 2, and zero, then the number you have is 0120. So, are you expecting the number 120 decimal? If so, then the function you should be using is Hexadecimal String to Number function as Alex mentioned before. But my understanding through all this was that you were getting hex values, not characters.
0 Kudos
Message 41 of 66
(1,437 Views)

The documentation says that the command 0x is followed by 4 bytes of ASCII data (so is this a character, I mean each ASCII data a charater?), hence here in this example, 0x followed by 30313230 in hex (0120 ASCII). You are right there. But, the 0120 implies that there is 12% elevation, 0100 is 10%, 0140 is 14% etc. But, having 0120, 0140 etc in decimal would make more sense at this point I guess.

 

Q) how to determine what I am getting are characters? The documentation says I get ASCII codes..

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 42 of 66
(1,433 Views)

Ok. What I get from the read buffer is 0120. Sorry. Does this change anything? How do I use this 0120 to get 0120 decimal?

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 43 of 66
(1,431 Views)
Based on this latest information then just use the Fract/Exp String to Number function if you want a floating point number. If the number is supposed to be an integer value then use the Decimal String to Number function.
Message 44 of 66
(1,427 Views)

Thanks! Smercurio_fc... ur last reply was very helpful.

 

Another question regarding case structures. Can I use "Use default if unwired" if I need a value out of just one case out of a case structure? What would that default value be? Would it pertain to the Default case of the structure or something else?

 

I may not be perfect, but I'm all I got!
0 Kudos
Message 45 of 66
(1,397 Views)
It would be the default value for whatever the datatype is. E.g., for numbers it would be zero, for strings it would be an empty string. Any case that does not explicitly wire a value would spit out the default value for the datatype. The "Default" case, if it exists, has no bearing on this. The "Default" case is the one that gets executed if the value wired to the selection terminal has no corresponding case to handle that specific value.
Message 46 of 66
(1,395 Views)

Also, how do I do the reverse of your previous conversion. like 120 decimal number to 0120 ASCII string or 120 decimal number to 30 31 32 30 hex ASCII string.

 

I may not be perfect, but I'm all I got!
0 Kudos
Message 47 of 66
(1,386 Views)

I mean i get how to convert to decimal string 120, But how do I get the additional zero in the beginning to make it 4 bytes as 0120 rather than 120 which will be 3 bytes in my application.

 

I may not be perfect, but I'm all I got!
0 Kudos
Message 48 of 66
(1,385 Views)

Sorry for posting as three separate messages.... I am concatenating a "0" infront of the "120" string. Is there a better way is my questin 🙂 Sorry for multiple posts... I didnt know how to delete my previous posts....

 

I may not be perfect, but I'm all I got!
0 Kudos
Message 49 of 66
(1,384 Views)
You can just use the Format Into String function. Check the Help on the various formatting strings that can be used.
Message 50 of 66
(1,381 Views)