09-26-2018 08:49 PM
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.
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:
these codes is almost directly copied from Cloud Server's demo.
then I try to read and recovery the files ,see as below:
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
Solved! Go to Solution.
09-26-2018 09:35 PM
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?
09-27-2018 01:31 AM
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.
09-27-2018 01:33 AM - edited 09-27-2018 01:41 AM
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!
09-27-2018 02:07 AM
ok, I am sorry,
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.
09-27-2018 02:14 AM - edited 09-27-2018 02:15 AM
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?
09-27-2018 02:31 AM - edited 09-27-2018 02:42 AM
HI,GerdW,
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?
09-27-2018 02:43 AM - edited 09-27-2018 02:45 AM
Hi ali,
see this:
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!
09-27-2018 02:53 AM - edited 09-27-2018 02:59 AM
thank you,
but , are the two VIs attached work smoothly on your PC ?
09-27-2018 03:08 AM
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.