06-18-2009 06:17 AM
Solved! Go to Solution.
06-18-2009 08:53 AM
Yes, it is possible to transfer files with the serial port using LabVIEW. Files are just collections of bytes and the serial port is pretty good at shipping bytes from one PC to another. You need to connect the serial ports together with a null modem cable.
First, take a look at the example for serial communication. In LabVIEW, go to the Help menu and select "Find Examples...". From there you can search for "serial" or navigate to Hardware Input and Output >> Serial. Select the "Basic Serial Write and Read.vi". Experiment with that example to gain confidence on the serial communication methods.
Next, it's time to learn about how to read and write files. For that, the examples could be somewhat confusing since they all deal with files that are presumed to have data of a specific type in them. I would recommend just getting familiar with the functions on the File I/O palette. Specifically, get to know the following functions.
OK, so once you are able to create files, write bytes to them, and read bytes from existing files you can move on to transferring.
The basic method I would suggest is to have the user specify a source file on the source PC and a destination folder on the destination PC. Then, find out the size of the source file using number 5. Divide that size number by the number of bytes you feel like transferring at once. The serial buffers are usually around 32k (if I remember correctly) so do not exceed that. Now begin sending data by reading some number of bytes and wiring that string output to the VISA Write function. On the destination side, you'll want to be monitoring the serial port for bytes and reading them when they arrive. Wire that string to the Write to Binary File function to add them to your destination file.
That is the basic outline of how to do it. You have to be careful not to overload the write and read buffers on the serial ports. Initially you can use delays on the sending side to make sure the reading side has enough time to digest. To get things moving faster, you can bring in some flow control.
If all that sounds a bit intimidating, there are Alliance Member companies out there (such as PrimeTest Automation) who can write such code for you and even provide a turnkey solution for you.
Happy wiring,
Dan Press
Certified LabVIEW Architect
06-20-2009 07:21 AM
Hi thanks for the solution suggested.
But already i am aware of serial port communication. I even achieved character transfer from PC to PC using LabVIEW software. I face no problems in that. Also i am aware of File I/O palette functions too. But then i suffer in sending already existing file on the PC. I want to know exactly how to convert the existing files into binary bytes and then how to send that data via serial port. If u can give me some procedure to be followed to achieve file transfer or if any sample program available let me know.
Padhu.
06-20-2009 11:17 AM
06-20-2009 11:36 AM
06-22-2009 06:12 AM
Hi
I have few queries on this binary file conversion. While writing the data into binary file using "write to Binary file" i am getting few space at the begining of my data. how to avoid that blank space. For reference i have attached the text file with this.
Second query: during binay file read operation the size of the file can be known through "Get File Size", after that why we need to divide and give the quotion to the count of "read from binary file". We can even give the file size directly to count of "read from binary file"
Padhu.
06-22-2009 09:27 AM
The text file is pretty worthless. What about the file that you read and the VI you use? Are you prepending the array or string size? That's the default.
I don't understand your second question. I thought you wanted to read the entire file. You would use the file size and divide by the byte count if you wanted to read x number of bytes.
06-23-2009 06:04 AM
Hi,
Here by i have attached vi with write to binary file operation. Create a new text file with extension ".txt" and then run this VI, enter some text on string control. after exeution open and see the text file saved you could find few blank space before the string you have entered which you could also refer with my text file attached along with this. My doubt is this why this blank space is getting created. Is it possible to avoid it and how to avoid it.
Secong Doubt: I have attached vi with read from binary file operation. I need to read the complete file for which i suppose that i should connect the complete file size to the byte count of the read icon. the division is required only if i need to read only few bytes from the file. (I guess i am right in my understanding).
Note: Run the write to binary file vi first and save it as text file. then you read the same text file using read from binary file VI. here u can notice few blank spaced occured before your string typed because of write to binary file operation.
Padhu.
06-23-2009 07:13 AM
Technical,
Have you tried the VISA Write From File.vi and VISA Read to File.vi ?
06-23-2009 09:25 AM