Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer an image through serial port from PC to PC

Solved!
Go to solution

Hi everybody,

can anyone help me to transfer an image file to another PC through Labview through serial port?

I tried using IMAQ functions to decode the image to a string. but there is a problem at the receiving end to get back the image.

is there any easy way to just sent and receive an image file through serial port??

 

Thanking you in advance.

shanaka 

0 Kudos
Message 1 of 22
(8,719 Views)

1) remove endcharacter enable from serial init

2) take the picture and use flatten to string

3) on the other pc unflatten from string

greetings from the Netherlands
Message 2 of 22
(8,706 Views)

Thank you very much for your help....i guess i don't have to go to IMAQ functions for just to copy an image file from one PC to another through serial.i read and write the file as binary. but there is a limitation for that.if the file size is more than 10KB then it will not work.

is it because of not synchronizing  the transmitter and receiver? i will add my reader.vi and write.vi for your consideration.

please there will be a lot of errors in programming side because i'm still new to labview.

by the way i don't know how to give kudos, n i rated you as 1.how to increase the rating?

 

thanks,

regards

shanaka 

Download All
0 Kudos
Message 3 of 22
(8,663 Views)

thanks for the kudo, you can only give one per userid.

If I supply the accepted solution you can click on that  button.

 

I'll look at your vi's tonight.

It probably is nicer for the serial line to set up a bit of handshake.

send 10k, and wait for an acknowledgement from the other pc., something like send new data.

On the receiver side you have to add all the received characters until complete and then  unflatten again.

Don't try to unflatten partly data, it does not work.

greetings from the Netherlands
Message 4 of 22
(8,655 Views)

You do very well for a beginner in LabVIEW.

Your solution in sending a file and saving a file romves the problem from flatten to and unflatten from string.

 

You may add a specification for the first write in how many blocks you write. Say one word extra, for the number of blocks.

Furthermore I personally never use waituntil next ms multiple, most important reason that you cannot trust the first wait, and second I don't want all waits to hogg the cpu at the same time.

 

Also file handling can be a bit cleaner but is OK.

I would not check filesize against a constant but received bytes against expected size.

 

I'll try to find some time to clean up the diagrams, maybe tomorrow.

greetings from the Netherlands
Message 5 of 22
(8,635 Views)

thank you Mr.Albert for giving me such advices. its really nice to get advices from a person like u.i will try using  flatten to and unflatten from string.and also il try to include a handshake after every 10KB. that constant file size was i just put there to check... and forgot to remove it before sending it to you.i get the first 4 bytes to read the size of the file and then take that size to the receiver end.

i will complete those problems and update you.thank you for your time.

regards,

shanaka 

0 Kudos
Message 6 of 22
(8,620 Views)
Solution
Accepted by topic author shanaka

Hi

 

I like people that like to learn. Thank you for listening.

 

I modfied both read and write subvi's because I beleive in keeping it simple and the straighter the wires the better readable the program and less bugs remain.

Even better, wtith straight lines my eyes don't get tired too soon.

 

good luck with your program.

greetings from the Netherlands
Download All
Message 7 of 22
(8,605 Views)

Hi albert,

thank you for modifying my VIs, yeah now those are working properly and also looking good.but i should include handshaking and also have to increase the buffer size.i found if the file is not divisible by the buffer size then receiver will not get the whole file.so i guess i need to add some dummy bytes to get the file divisible by the buffer size and transmit. i will make it working properly and contact you.  

 

Thanking you,

Regards,

shanaka 

0 Kudos
Message 8 of 22
(8,597 Views)

the reader may use the same algoritm as the writer as you already know the size to read.

So in case less data has to be read use for the last read the smaller number.

greetings from the Netherlands
Message 9 of 22
(8,575 Views)

Hi Albert,

once again i need your help...

now i have developed that reader/writer VIs using Xmodem protocol for a reliable communication. and now i have another issue.say if my transmitter side connection is lost,so how do i detect it from the transmitter side and pause the transmission until the link is ready?

 

i  simulated the scenario by using a pause in transmitter side.but now i need to detect the serial connection from the transmitter side.

it would be grateful if you can give me any kind of advise to do this.

thanking you,

regards,

shanaka 

0 Kudos
Message 10 of 22
(8,455 Views)