06-15-2016 12:40 PM
Hello all,
I'm currently working on a program that query's an SQL database for sensor data and converts that data to a spreadsheet for future use.
My problem is as follows:
I can access and read the database just fine; however, the data I'm after is stored in the database as a hex number (example: "0X5727000....". When I pass this through this "DB Tools Fetch Element Data" vi, it grabs the data and autoconverts it to ascii. This is a huge problem as the data contains several pieces of information and needs to be parsed before it's converted in order to attain the correct value (and ascii's the wrong format anyway).
Is there any way to grab the data as a string containing just the hex information? I already have code that converts it; I just need it as the hex values and not the ascii it's trying to autoformat it to.
Solved! Go to Solution.
06-15-2016 12:48 PM
Wire a string to the type terminal
06-15-2016 12:59 PM - edited 06-15-2016 01:03 PM
Did not work. Returns " W' ..." Instead of "0x5..."
I wish to continue using this function as the DB I'm reading is going to have data being written to it as I'm reading. I see a possible solution with an alternative (dB tool sselect data -> Database Variant to data), but that will slow down the program immensely as the dB gets larger.
06-15-2016 01:12 PM
Just tried what I mentioned in the last post, did not solve the problem. It still outputs "W' ♦..." instead of the data I want.
06-15-2016 01:24 PM
Attach an example of how the data looks in the database. Attach how it shows up in LabVIEW.
saying 0x5... isn't very helpful, that is only one hexadecimal digit. The letter "W" is x57. So I'm wondering if that is that you are seeing. But you didn't give enough detail.
My guess is that you just aren't selecting the correct display style. Set the display style for that string to be in Hex Display.
06-15-2016 01:26 PM
What happens if you set the type input string to display as Hex? This may cause the output of the VI to also output Hex.
06-15-2016 01:31 PM
Attached pictures.
I wasn't being specific as specifics really don't buy anything, but if it helps explain what the problem is, why not?
Hex display doesn't really fix the issue either (I tried that. Included a picture if you wanna see), plus labview won't use the Hex Display format to do further work on the string anyway.
06-15-2016 01:41 PM
Your data is definitely binary. And how it is stored in the database is a function of whatever program put it in there. It is not a case of LabVIEW doing any "autoconverting".
"plus labview won't use the Hex Display format to do further work on the string anyway"
So the next question is what is the further work you want to do on this data? There is a function call "String to Byte Array" that converts the characters to an array of U8's. So now you have an array of U8 numbers. What you do next with that depends on what all of this data is supposed to represent.
06-15-2016 01:42 PM
OK...in the select data VI, use the convert command....similar to this.
06-15-2016 01:48 PM
Actually, that will not do what you are asking.