LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display exact string data from file as hex display

Solved!
Go to solution

I am sending control messages via a serial port which are constructed in a series of bytes.  Currently I have all these messages in an excel file which is 8 columns of 224 rows.  The messages are the exact hex display I need for my program to work.  To verify my setup I tested a few messages by manually typing in the messages using a string constant and set to hex display and everything works fine.  How can I get the strings from my file to be recognized as they are using hex display. 

 

Thanks for any suggestions.  

0 Kudos
Message 1 of 6
(3,563 Views)

Setting hex display it's a matter of convenience. It doesn't change a string content at all.

So the program would work whether you set hex display or not.

If you show some example of what you should send and what is written in the file (text? numbers?), we may better understand the problem.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 6
(3,556 Views)

When I use a probe and view the output this is what I get.  The picture on top would be the manuaul entry and my device will recognize the message.  Then the bottom is trying to read the message in from a .csv file and it displays the exact string that is in file but device does not respond.  As you will see I will be putting these values in an array and reading, so the first string input would be the same value as the bottom example.

0 Kudos
Message 3 of 6
(3,542 Views)
Solution
Accepted by topic author JM29

So if I correctly understood you're reading an ASCII representation in hex format of the command strings.

You need to convert ASCII to bytes and then to string, this way:

 

hex-ascii-to-string.png

 

The input string on the left should be read from your file, of course.

Remark that the integer constant's representation must be U8.

You don't need the Trim whitespace function if you are sure that the string doesn't contain extra characters beyond the last hex number.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 4 of 6
(3,529 Views)

You must be doing something different within your VI for your two modes of entry, assuming the strings are the same. Could you upload the VIs (at least until the string gets transmitted to your device) for both cases so we could see?

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 5 of 6
(3,528 Views)

The solution you offered was perfect, thanks for the quick response!!Smiley Happy

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