RS232 File Transfer Problems

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: May 2008
Posts: 10
Reputation: Kumar Arun is an unknown quantity at this point 
Solved Threads: 0
Kumar Arun Kumar Arun is offline Offline
Newbie Poster

Re: RS232 File Transfer Problems

 
0
  #1
May 10th, 2008
Originally Posted by Kumar Arun View Post
I am exploring the RS232 communication possibilities. I am faced with problems when i try to send file across the rs232 port. Please help...
I am really sorry if i was not expressive enough. I will explain the situation.

I have implemented the RS232 communication, At System A, i am having the program developed using Visual Basic and on System B I have another program written using C++. The two programs already communicates using the RS232 port and it is currently works like a chat utility. To enhance the work i want to add an additional module to send files. Here i am faced with problems.

To be specific, i tried to send a text file across the port. The data is being received at the other end and saved to the file also. But when i open the file at the received end i observed that additional enter has been saved. After an analysis i found out that it was not exactly an enter (chr(13)) but chr(10) that appearing on the output file.

If somebody could clarify, it would be highly helpful....

>> zandiago Glad to have you with us! Please place question in correct section of Forum!

So since i am using both Visual Basic and C++, i was not sure where to make the post. Sorry About that..
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,141
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1433
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: RS232 File Transfer Problems

 
0
  #2
May 10th, 2008
You need to be careful about transferring files from MS-Windows platform to *nix or other platforms. MS-Windows uses two bytes to indicate end-of-line while *nix, MAC and others use only one character. So if you read text files in binary mode and send that to other operating systems the receiving program has to translate the CR/LF pair to whatever the target os expects.

File transfer programs, the receiving program does the translations because the sending program may or may not know what platform it is communicating with. So, the receiving program on *nix platforms need to translate 0x0a 0x0d pair to just 0x0a and on MAC they would be translated to 0x0d (unless I have that backwards).
Last edited by Ancient Dragon; May 10th, 2008 at 1:21 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 10
Reputation: Kumar Arun is an unknown quantity at this point 
Solved Threads: 0
Kumar Arun Kumar Arun is offline Offline
Newbie Poster

Re: RS232 File Transfer Problems

 
0
  #3
May 10th, 2008
Originally Posted by Ancient Dragon View Post
You need to be careful about transferring files from MS-Windows platform to *nix or other platforms. .......
Under Stood. You reply has been very clear. But what if i want to transfer a executable file.
if any translation (as mentioned in the case of Text File) takes place, the exe will become unusable. Pls advise.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,141
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1433
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: RS232 File Transfer Problems

 
0
  #4
May 10th, 2008
you don't do anything with files that are saved as binary files on the disk, such as executable files. Only do the translation of text files. BTW: it will do no good to transfer an executable file from MS-Windows to *nix anyway because it won't run on *nix
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 10
Reputation: Kumar Arun is an unknown quantity at this point 
Solved Threads: 0
Kumar Arun Kumar Arun is offline Offline
Newbie Poster

Re: RS232 File Transfer Problems

 
0
  #5
May 10th, 2008
Originally Posted by Ancient Dragon View Post
you don't do anything with files that are saved as binary files on the disk, such as executable files. Only do the translation of text files. BTW: it will do no good to transfer an executable file from MS-Windows to *nix anyway because it won't run on *nix
I think the scenario is still not clear. I will try to make it clear.
Today there are so many medium for file transfer like 1. Internet, 2. Pen Drive, 3. CD ...and so on.....and so there may not be much scope for file transfer through RS232. I want to do this to supplement my learning curve.

So i want to transfer an executable ( or for that matter an image file ) file byte by byte from System A to System B using RS232. Of course if System B is a *nix it won't run and that does not matter at all.

NB: Actually what i plan to implement is a cross platform file transfer utility using RS232.

Please Advise...
Last edited by Kumar Arun; May 10th, 2008 at 12:13 pm. Reason: add Content
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,141
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1433
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: RS232 File Transfer Problems

 
0
  #6
May 10th, 2008
Originally Posted by Kumar Arun View Post
To be specific, i tried to send a text file across the port. The data is being received at the other end and saved to the file also. But when i open the file at the received end i observed that additional enter has been saved. After an analysis i found out that it was not exactly an enter (chr(13)) but chr(10) that appearing on the output file.
Originally Posted by Kumar Arun View Post
I think the scenario is still not clear. I will try to make it clear.
Today there are so many medium for file transfer like 1. Internet, 2. Pen Drive, 3. CD ...and so on.....and so there may not be much scope for file transfer through RS232. I want to do this to supplement my learning curve.

So i want to transfer an executable ( or for that matter an image file ) file byte by byte from System A to System B using RS232. Of course if System B is a *nix it won't run and that does not matter at all.

NB: Actually what i plan to implement is a cross platform file transfer utility using RS232.

Please Advise...
So does that mean your original post is wrong ? You don't want to transfer a text file but a binary file such as image or executable? Or both types ?

Again, if transfering a binary file neither the client nor the server should do anything at all with the data types -- no translation should take place. Open the files in binary mode, not text mode, like this in c++. VB has similar capability to open a file in binary mode.
  1. // open the file for input
  2. ifstream in("filename", ios::binary);
  3.  
  4. unsigned char* buf = 0;
  5. // get file size
  6. in.seekg(0, ios::end);
  7. size_t filesize = in.tellg();
  8. // back to beginning of the file
  9. in.seekg(0,ios::beg);
  10. // allocate memory for the file
  11. buf = new unsigned char[filesize];
  12. // read the file
  13. in.read(buf, filesize);
  14. // close the file
  15. in.close();
  16. // now send buf to the other computer over rs232 port.
Last edited by Ancient Dragon; May 10th, 2008 at 10:44 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 10
Reputation: Kumar Arun is an unknown quantity at this point 
Solved Threads: 0
Kumar Arun Kumar Arun is offline Offline
Newbie Poster

Re: RS232 File Transfer Problems

 
0
  #7
May 11th, 2008
Originally Posted by Ancient Dragon View Post
So does that mean your original post is wrong ? ....

Thank you for the reply, i will attempt the file file transfer and get back to you.
Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC