03-23-2023 11:06 AM
Hello,
I'm having difficulty writing and reading back hex data to and from an ini file. I don't think I'm writing the data correctly hence the incorrect data that I was reading. What is correct way to store or write hex data to ini file and read it back correctly? I have attached a vi I created to read the file. See also the screenshots of the ini file data.
Any suggestion will be appreciated.
Thanks
Solved! Go to Solution.
03-23-2023 11:38 AM
Hi IPS,
@SolPS wrote:
What is correct way to store or write hex data to ini file and read it back correctly?
Any suggestion will be appreciated.
There is no "correct way", there only is the way "fulfilling your requirements"…
I think the way you stored those data is quite ok. Which results do you get when you read your INI file?
Comments on the VI:
03-23-2023 12:05 PM
Hi GerdW,
I'm trying to convert the data that I read from the file to an unsigned 16bit integer before I writing it to my serial port device. The problem was that I get an error at the "scan from string" function. When I tried to use the "Hexadecimal string to number" function in the loop so I can obtain a u16 array at the end of the loop iteration, all the output array values turned out to be zero. That was why I felt I was doing something wrong.
Regarding opening the INI during each iteration, that was an omission. It is just a troubleshooting VI that I was using to look at my data values. It was an oversight. I used the first loop to generate the keys. I copied data into the control.
03-23-2023 12:07 PM
Do you know why I would be getting zeroes in the output of a u16 array?
03-23-2023 01:09 PM
If your Scan from String function is erroring out, look at its inputs, because your format code is correct.
I believe your issue is that your "Keys" array (which is actually the Default Values array) has a typo- there's a space before the 0x0003. When that space gets fed into Scan from String, it errors out because you're telling it to look for the EXACT string "0x" at the start. Instead, it finds " 0x" at the start, which is not what you need.
03-23-2023 01:33 PM
Hello BertMahan,
You are correct. That was the problem. Thanks so much..