LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array of bytes containg punctuation

Hi, I have an array of bytes that I would like to export using the spreadsheet VI. The spreadsheet creates a file with the extension .res, which logs the array as hex values. The problem is, all my data is separated with a punctuation mark, which I guess LabView inserts into the array to separate the numbers.

 

So my question is, is there any way to convert an array of U8's into a string of pure hex or just a stream of binary data?

 

Thanks

0 Kudos
Message 1 of 8
(3,223 Views)

What is the .res file format?. You can convert the U8 value as Hex value by changing the Display format and then use the Number to Hex string function to convert that into Hex string.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 8
(3,219 Views)

Thanks alot, I'll give it a go! I think it stands for resolution. It you open one in a text editor, a line looks something like this:

 

10. FF 10 34 32 12 A9  12 42 D4 F4 09 33  (ASCII values) 

 

 It's just the file that this matlab script I found uses to process some data. I don't want to mess around with it to much so I thought it would save me alot of trouble to just keep the file format as it was.

 

Thanks again!

0 Kudos
Message 3 of 8
(3,211 Views)

Simply format the long string and write it to a plain text file. don't use the spreadsheet versions.

 

What is the representation of you "array of numbers"? Is it U8?

 

You could do something like this (note that you would delete the string input and "string to byte array" conversoin and use only the tail of the shown code)

0 Kudos
Message 4 of 8
(3,202 Views)

Thank you for your answers, I'll try your link. The first suggested solution didn't work.

 

I want to use the spreadsheet VI to make a .res file, saving as a plain text file would cause alot of extra work in MatLab.

 

I might not have explained the problem sufficiently in the first post. If my buffer containing U8s is passed in to the spreadsheet VI, the .res file saves for example the number 255 as ASCII character 2 then character 5 then 5. So 255 would be saved as 32 35 35 instead of FE.

 

Thanks again

0 Kudos
Message 5 of 8
(3,174 Views)

@q-bertsuit wrote:

Thank you for your answers, I'll try your link. The first suggested solution didn't work.


You are not giving enough information. Did the second suggestion work?

 


q-bertsuit wrote:

I want to use the spreadsheet VI to make a .res file, saving as a plain text file would cause alot of extra work in MatLab.


A "spreadsheet" in LabVIEW is nothing more than a plain text file with certain delimiters for columns and newlines delimiting rows. "Write to spreadsheeet file" is a simple tool for typical use. All the formatting can be done explicit and then written to a plain text file, the outcome is exactly the same. There is no extra work involved in Matlab.

 


@q-bertsuit wrote:

I might not have explained the problem sufficiently in the first post. If my buffer containing U8s is passed in to the spreadsheet VI, the .res file saves for example the number 255 as ASCII character 2 then character 5 then 5. So 255 would be saved as 32 35 35 instead of FE.


Again, write to spreadsheet file is not the right tool then, so don't use it.

 

It is still not clear. So you have an array of U8. How should the file look like? Should there be any delimiters?

 

Example: If you only write 255 to the file, should it contain

  • one binary, nonpritable character (xFF)
  • two charcters (two instances of the letter F)
  • Three characters (letter 2 followed by two letters 5)

 

If the array has two elements, how should the second character be stored? Should there be a delimiter (space, comma, tab, etc) or nothing separating it from the first value?

 

Once we have the specifications, the rest will be trivial.

 

Message 6 of 8
(3,160 Views)

I tried the "write to binary file" vi and it worked.

What i ment about extra work in MatLab is that I have a bunch of ready made m files that reads .res files, and so there would be quite alot of work to change them into taking text files instead.

 

Thanks for your help!

0 Kudos
Message 7 of 8
(3,133 Views)

You probably could have shown us one of the m files that reads the file and we would have immediately come up with a LabVIEW solution. We cannot efficiently work with partial, ambiguous, and conflicting information. 😉

0 Kudos
Message 8 of 8
(3,125 Views)