Connecting computers via serial ports




















This code is similar to the code used to transmit the size of the file name shown in the section above. To transmit the actual file, a function was written. First the file is opened in binary mode on the local computer. Then it is sent bytes at a time to the receiving computer. After each byte block is transmitted, a progress indicator is updated and printed to the screen to tell the user how many bytes have been transmitted so far. First, a handle to the serial port is opened and then the properties of the serial port are set.

This code is identical to the code for the transmitter. The next step is to receive the file name. First, the length of the file name is received. Then, the file name itself is received. The ReadFile function is used to receive the data. To receive the file, first the size of the file is received, so that the program knows how many bytes to expect over the serial port. After this, the file is created and the data is received in byte increments until there is no more to receive.

As the data is received, it is written to the file on the receiving computer. First, the program serrecv. This program will just display a blank screen until it receives some data. Then the program sertrans. Both computers will show progress as bytes are received until the file transmission is finished. The syntax for sertrans. If this switch is omitted, the program will execute at a baud rate of For example, to transmit a file called text.

The file to transmit should be located in the same directory as the program, and you can copy and paste it there if it isn't there already. The syntax for serrecv. If the baud rate is omitted, the program will operate at a default baud rate of The file transmitted over the serial cable will be stored in the directory where the program is located.

You can then copy and paste the file to the desired directory. The most important thing in selecting a baud rate is to make sure that both the transmitting and receiving computers are using the same baud rate. If not, the file transmission will fail.

One important consideration is the length of the serial cable. If it is very long, a high baud rate may not produce reliable communication, and you may be forced to reduce the baud rate. On most computers, the serial port is COM This program assumes that you want to use COM1: as your serial port, which is fine for most computers.

If the program doesn't seem to be working, it may be that you need to change the serial port. Go under Control Panel on your computer and click on System to determine which serial ports are installed on your computer. Then recompile and try the program again.

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below. Sign in Email. Forgot your password? Search within: Articles Quick Answers Messages. Tagged as VC6. Stats How to use serial port to communicate between two computers. Please Sign up or sign in to vote. Using the serial port and cable to send a file from one computer to another.

Download demo project - Background In order to hook up two computers using the serial port, it is necessary to have a null modem cable. Using the code Transmitting There are two source files included.

The voltage difference between them is what matters. Modern computers have USB instead of serial ports. Check your cable carefully before using it. A miswired cable could fry the RS ports on either end.

I have made a cable using this information. I have tried to make it correct. I am grateful for their help but any mistakes are mine. Almost nothing in computer interfacing is more confusing than selecting the right RS serial cable.

The RS connector was originally developed to use 25 pins. In this DB25 connector pinout provisions were made for a secondary serial RS communication channel. In practice, only one serial communication channel with accompanying handshaking is present. Only very few computers have been manufactured where both serial RS channels are implemented.

Also on a number of Telebit modem models the secondary channel is present. It can be used to query the modem status while the modem is on-line and busy communicating.

On personal computers, the smaller DB9 version is more commonly used today. The diagrams show the signals common to both connector types in black. The defined pins only present on the larger connector are shown in red. Note, that the protective ground is assigned to a pin at the large connector where the connector outside is used for that purpose with the DB9 connector version. The pinout is also shown for the DEC modified modular jack.

Choose serial and type the path for the serial port e. The main thing to consider is the baud rate e. On the windows PC, open up a putty session and setup a serial port connection click on serial , and specify the name of the port where the serial device is connected to e.

Then once the connection is established you can type in the windows putty display and can then read it from the Linux putty display and vice versa. Active Oldest Votes. Improve this answer.

I am trying to emulate a device which outputs some data on the serial so the application running on Windows Machine can interpret it. I know I can use a virtual serial driver to emulate the serial port on the windows machine but I tought it will be nice — opc0de. I'd use an emulator when possible - less chances you burn something : — abolotnov. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.



0コメント

  • 1000 / 1000