LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial communication without string

I believe the confusion comes from not specifying exactly what the definiton of hex is in this context. If my assumptions are correct the professor is giving the students hex values. In writen form on the assignment (or wherever the description of the problem is) they would appear as something like 0x12AB. THe OP is entering this into a string display. What needs to be done is to convert the ASCII representation of the ASCII hex representation to the actual numeric form. There are tons of examples on the forums. This would then need to be convert back to a string. The opposite would have to occur on the receive side. Since this is a homework assignment and I don't know the exact assignment I am hesitant to provide example code. Part of teh assignment could be the actual conversions.

 

Anyway, as others have pointed out a string is nothing more than a series of bytes.

 

I included a image showing the difference using controls and indicators to help illustrate the differences. Again, I will leave teh actual conversions to the OP.

 

String Representations.PNG



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 11 of 13
(545 Views)

i am obsessed with this topic more and when i read the data from serial port which sends hex values not hex string. So, in that case weather read visa will be able to take those hex numbers(let say 25 is the decimal voltage which is 19 in hex) rather to hex strings. Basicalli read visa will look for strings. so, how it will take the hex values.

 

Or it takes the coming hex numbers as string. So, that i need to use converstions to display the exact value.

0 Kudos
Message 12 of 13
(525 Views)

 


@shjukheter wrote:

i am obsessed with this topic more


That much is obvious. That's because you keep forgetting the fundamental part of this: you're dealing with bytes, not strings, numbers, or anything else. As soon as you accept that, it becomes quite clear.

 

 

 


i am obsessed with this topic more and when i read the data from serial port which sends hex values not hex string. So, in that case weather read visa will be able to take those hex numbers(let say 25 is the decimal voltage which is 19 in hex) rather to hex strings. Basicalli read visa will look for strings. so, how it will take the hex values.

As has been noted numerous times. The serial port sends/receives bytes. They're not strings, numbers, or anything else. The designers of the API can choose to provide inputs that are strings or an array of bytes. The NI designers chose a string for the VISA functions because it's quite easy to deal with it. A string is just a sequence of bytes. See how I keep saying bytes? Are you getting this yet? You can take that "string" (sequence of bytes) and make it look like something else by simply reinterpreting the sequence of bytes. For example, you can use the String to Byte Array and get an array of unsigned 8-bit integers, which you be the individual bytes that were sent. Or, you can use the Type Case function to cast the sequence of bytes into a floating point value if the number of bytes you received corresponds to the number of bytes that a floating point value takes up. For instance, a single-precision floating point value is 32 bits. That's 4 bytes. Thus, if VISA Read returns a "string" that is 4 characters (bytes) long, you can convert it to an SGL by simply doing this:

 

 

Hopefully, this will make things clearer.

Message 13 of 13
(512 Views)