LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ASCII Formatting Issue with Read text File and Sending to Visa Write function for RS232 comms

Solved!
Go to solution

Thanks Paolo. 

 

0 Kudos
Message 11 of 17
(1,297 Views)

Hi GerdW. 

 

From what Paolo mentioned it should be possible to use a property node to reformat the way the file path is sent before it is opened? 

 

When right clicking the write buffer it doesn't offer Property/Invoke Nodes. 

 

The only successful result is achieved as I previously mentioned whereby the string file constant is connected using Hex Format: 0430 3030 3002 4141 3E30 030D

 

When placing the exact same Hex Format in a text file it is now being read 3034 3330 2033 3033 3032 2034 3134 3120 3345 3330 2030 3330 44 which appears in Hex Format under the text indicator in the front panel. So in that case I'm trying to compare apples to apples. But clearly the apples I'm creating are becoming oranges once the file is opened. 

 

Therefore the desired response from RS-232 is no longer achieved when being read through the text file.

 

I also attempted to convert the text file as suggested to no avail. - I tried to place Hex String To Number and then Byte Array To String in my code but they are causing breaks and not connecting. 

 

I am trying to find a solution and will continue to try, I will make sure to post the solution if I get there before you do!

 

Many Thanks

0 Kudos
Message 12 of 17
(1,291 Views)
Solution
Accepted by topic author neunited

Hi neunited,

 

you need to use a string control/indicator to use that property node.

 

Or you follow crossrulz' suggestion:

check.png

Whatever is easier for you…

 

the string file constant is connected using Hex Format: 0430 3030 3002 4141 3E30 030D

When placing the exact same Hex Format in a text file it is now being read 3034 3330 2033 3033 3032 2034 3134 3120 3345 3330 2030 3330 44 which appears in Hex Format

That's the point I made before: you need to use the very same display format in all places - even in your text editor!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 13 of 17
(1,285 Views)

Hi GerdW, 

 

The example you provided has worked (the working VI has been attached for reference). Thank you for your example. 

 

I simply inserted GerdW suggestion (placed into a subVI) and the Hex values were read and provide the correct Hex response of 06. Also keep in mind that the text file should be saved as Encoding: Ansii 


So now that this has been accomplished I need to create the reverse process in order to write the Hex response of 06 into a new text file, as shown in the response tab. 

 

Would appreciate any further advice

 

Many Thanks

0 Kudos
Message 14 of 17
(1,267 Views)
Solution
Accepted by topic author neunited

String To Byte Array

Number To Hexidecimal String (make sure the width is set to 2, this function will work with the array of bytes)

Concatenate String (combine the resulting string array into a single string)

Write To Text File


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 15 of 17
(1,258 Views)

Hello again, 

 

I would like to note that GerdW illustration does work. But please note if you wish to send a "Write" as a control with the Hexadecimal command, it needs to be set to Normal Display mode rather than Hex Display. The Read indicator remains as Hex display.

 

Not sure if there is any logical reasoning for this approach but this is the workaround for LabVIEW 2017 Smiley Wink.

 

Many thanks 

0 Kudos
Message 16 of 17
(1,212 Views)

Hi neunited,

 

GerdW illustration does work

Sure it works as intended: convert a string in normal display, holding hexadecimal numbers, into a string consisting of the byte values corresponding to those hexadecimal numbers…

That's what you asked for!

 

this approach but this is the workaround

It's not a "workaround"! It's a simple conversion as per your requirements!

There were also other solutions shown, but when mine is ok for then it's ok for me too! 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 17
(1,209 Views)