| | |
RS232 File Transfer Problems
![]() |
•
•
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.
My NewYear's resolution is to lose weight.
Weight Lost since 1 Jan 2010: 8.7 lbs
Weight Lost since 1 Jan 2010: 8.7 lbs
•
•
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
My NewYear's resolution is to lose weight.
Weight Lost since 1 Jan 2010: 8.7 lbs
Weight Lost since 1 Jan 2010: 8.7 lbs
•
•
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.
My NewYear's resolution is to lose weight.
Weight Lost since 1 Jan 2010: 8.7 lbs
Weight Lost since 1 Jan 2010: 8.7 lbs
![]() |
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
Views: 3218 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access accessdenied administrator application array arrays basic browser build button buttons c# captcha center check client code combobox component connection control convert cpu crystal crystalreport data database datagrid datagridview date datetimepicker design designer dissertation dissertations dropdownlist error excel file folder google image images insert lib listview login mobile ms msaccess net path picturebox port print printing printpreview problem problemwithinstallation read regex release save searchbox security serial server settings sharepoint sms socket sorting sql statement studio syntax textbox time timer upload user validation vb vb.net vb2008 vbnet view visual visualbasic visualbasic.net visualstudio2008 web webbrowser windows wpf xml






