LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading as binary file from Cloud downloaded error

Solved!
Go to solution

I tried to use a Cloud Server to update soft components remotely,After I manually(drag to update in web) update a wav file and download it by Cloud Server's C# DLL,it can be smoothly played,everything seems well.

 

but after I created a binary file by labview and manually update it , and then download it by the Cloud Server's C# DLL,and read the binary file by LaBVIEW, things turn worse.

 

I created the binary file as below,it's function is to pack the files and the files' names in a folder into one file,the subvi's function is to make binary data which resembles the TCP message,4 bytes length and the others are data.

微信截图_20180927093214.png

then I update the file to Cloud Server manually.

then I download it by C# DLL(provided by the Clould Server),I delieverd a path and name into DLL's method,the file-write part is as below:

 微信图片_20180927093803.png

these codes is almost directly copied from Cloud Server's demo.

 

then I try to read and recovery the files ,see as below:

微信截图_20180927094720.png

but it is very difficult , It seems my computer suddenly truns from a sport man to a dying patient,becomes very very slows,after about 30 seconds, the read procedure suceed(and it seems,just seems, I am not sure, labview get the binary data), but my computer did not came back to a sport man,and I had to restart my PC.

 

What shall I do?!???  cry…cry…cry

0 Kudos
Message 1 of 12
(2,648 Views)

Your description has a whole lot of different things going on, and I have no idea why you are doing all those steps.  What makes you think this is a LabVIEW problem.  Perhaps the problem is with the C# dll?  Why do you need that dll?

0 Kudos
Message 2 of 12
(2,636 Views)

Let us ignore the Cloud and the C# dll,I can not even encode and decode the files on local machine,you can try the VIs attached.

 

 

Download All
0 Kudos
Message 3 of 12
(2,621 Views)

Hi ali,

 

several notes on your images:

- your packing routine packs the filename with the file content into one string. How do you split those two data later on?

- there is NO error handling in your image implemented…

- there are just generic VI icons, so how should we (and others) understand your code (in a week, in a month, in a year)?

 

Now I saw your VIs:

- it's really annoying for users of "standard" English Windows installations to handle files with Unicode names (like Chinese). When attaching files to a public forum you should use only (pure) English filenames!

- When you want to learn about "packing" files into an archive you should read Wikipedia about TAR and ZIP file formats!

- Now I see the length of all strings is added in front of their content: why don't you use the FlattenToString function? (And its counterpart UnflattenFromString for unpacking.)

- Implement error handling. In all parts of your code!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 12
(2,620 Views)

ok, I am sorry,Smiley Sad

 

making string array into a string is a privite function in many of my code ,such as setting information\license etc,so I want to reuse it here. It is beyond my exception that it does not work normal ,this may push down some of my work, so I need to get out the reason.

 

your answer intend me that I can FlatToString of that , but I am not quite understand, because all my data are strings already, I just want to combine and split them.

0 Kudos
Message 5 of 12
(2,611 Views)

Hi ali,

 

your answer intend me that I can FlatToString of that , but I am not quite understand, because all my data are strings already, I just want to combine and split them.

You could use them because they

- attach the string length in front of the string (by default) when flattening

- use that string length when unflattening the string

So those functions basically can replace your (kinda Rube-Goldberg) packing/unpacking routine.

 

They also provide errorIO so you can easily detect problems in this process. Did you start to implement error handling yet?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(2,605 Views)

HI,GerdW,

捕获1.PNG

 

 

follow your idea, I changed some of the block,right? I am afraid the unpack function must keep the same, because I need first get the size and then get the data and continue.

 

But I think reasons caused my PC and the code extremely slow are not here , not so simple. Have you tried my VIs?

0 Kudos
Message 7 of 12
(2,602 Views)

Hi ali,

 

see this:

check.png

You can replace that whole FOR loop by a single function…

(String3 is slightly different as the array size information is also packed into the string.)

 

I am afraid the unpack function must keep the same, because I need first get the size and then get the data and continue.

No, when unpacking with UnflattenFromString that function will automatically parse those additional length data, no need to do that on your own!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(2,592 Views)

thank you,

but ,  are the two VIs attached work smoothly on your PC ?

0 Kudos
Message 9 of 12
(2,588 Views)

dear GerdW,   the unpacked file must be absolutely the same at byte level with the original file. because my file may be an exe file or excel file or even VI file.

 

I tried to unpack the string to a string array, but failed . I have to stay these code the same.Smiley Happy

0 Kudos
Message 10 of 12
(2,584 Views)