| | |
RS232 File Transfer Problems
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: May 2008
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
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 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..
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).
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.
•
•
Join Date: May 2008
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
You need to be careful about transferring files from MS-Windows platform to *nix or other platforms. .......
if any translation (as mentioned in the case of Text File) takes place, the exe will become unusable. Pls advise.
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.
•
•
Join Date: May 2008
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
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
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
•
•
•
•
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.
•
•
•
•
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...
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.
VB.NET Syntax (Toggle Plain Text)
// open the file for input ifstream in("filename", ios::binary); unsigned char* buf = 0; // get file size in.seekg(0, ios::end); size_t filesize = in.tellg(); // back to beginning of the file in.seekg(0,ios::beg); // allocate memory for the file buf = new unsigned char[filesize]; // read the file in.read(buf, filesize); // close the file in.close(); // 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.
![]() |
Similar Threads
- Application software problems (Windows Software)
Other Threads in the VB.NET Forum
- Previous Thread: RE: Changing the size of a file.
- Next Thread: Need Help
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account add arithmetic array assignment basic box button buttons center check code component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp generatetags hardcopy image images insert intel isnumericfuntioncall math monitor mssqlbackend mysql navigate net networking opacity output passingparameters peertopeervideostreaming picturebox1 port printpreview problem problemwithinstallation project record reports" reuse savedialog searchvb.net select serial storedprocedure string tcp temp text textbox timer toolbox trim updown user useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf






