LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex data to file jpg

Dear GerdW,

 

Thank you very much for your kind replies. I will check it out.

 

-Praveen

0 Kudos
Message 11 of 27
(1,372 Views)

@GerdW wrote:

 

No need to convert to "binary" or something else - just save the data to a file!

 


While the data is just a string, you need to make sure to use the binary file IO and not the text file IO tools. While both can be used if done right, you need to be more careful with the text tools, because there are options such as "convert EOL", which could make a mess out of binary data.

0 Kudos
Message 12 of 27
(1,365 Views)

I tried saving the string file directly to the binary file. When i open the file its not opening. The VI attached with this.

0 Kudos
Message 13 of 27
(1,354 Views)

What's the point of the FOR loop that iterates only once? You currently read only a few bytes from the serial buffer, you probably need to read the entire image data before saving it.

0 Kudos
Message 14 of 27
(1,347 Views)

Yes, you are correct. I used FOR loop for no reason. It won't affect the result too. (Can modify while sync condition).

 

The thing is while reading the image data I am not exactly getting 512 bytes. It's changing every time. (I think because of the delay time).

 

1. I am struck here to receive the full image. 512 byte

2. Even I received 512 bytes sometimes I am not sure to convert into image (jpeg type).

 

Totally confused.

0 Kudos
Message 15 of 27
(1,345 Views)

Hi praveen,

 

- those 512 bytes are just an example in your manual, you might change the block size to other numbers as is described in the flowchart for reading JPEG Snapshots…

- you surely need to read more than just one block of 512 bytes to recevie your full JPG image: do you change the package ID as is described in the flowchart for reading JPEG Snapshots?

- just save the received bytes to a file using WriteBinaryFile…

Best regards,
GerdW


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

Yes. you are correct. I flush the buffer using the VISA flush IO buffer.vi. 

 

Now I can receive 512-byte data (actually those are HEX but received in String).

 

If I saved this directly in "Write to binary file" in Big-endian - network order (in jpg or jpeg format) the result is not openable.

 

I think I am near to the solution. Needs to find how to save the file and its format.

 

Thank you once again for your valuable feedback.

0 Kudos
Message 17 of 27
(1,340 Views)

I acquired all the image byte packets and joined together. (To get the whole image)

 

when I save in "write text file" as well as"write binary file" (saved as .jpg). It doent work.

 

 

0 Kudos
Message 18 of 27
(1,315 Views)

Hi praveen,

 

we told you NOT to use WriteText - only use WriteBinary!

 

What didn't work?

Is the data you got from your device as expected?

Can you attach such a data file (after saving it with WriteBinary with "Prepend Array Size" set to FALSE)?

Best regards,
GerdW


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

Yep. I saved "write binary file" (in suffix .jpg) 

as you said I made "Prepend Array Size" set to FALSE.

When I open it in paint shows error in format (error snapshot image attached)

I also attached the saved jpg file and the LabVIEW code for your reference.

 

Download All
0 Kudos
Message 20 of 27
(1,307 Views)