Serial Port Communication Between Two Pc
- discballrenosandss
- Aug 20, 2023
- 7 min read
Identify the COM port that the cable has been connected to on each system. For a dual serial cable, the odd-numbered pins on the header correspond to the lower-numbered COM port. (Using this example, the odd-numbered pins correspond to COM3 and the even-numbered pins to COM4.)
Very often it is necessary to send a file from one computer to another. There are several ways to do this: you could put it on a disk or send it over a LAN. If the computers are relatively close together and the file is fairly small, it may be quickest to send the file over a serial cable connected to each computer's serial port.
Serial Port Communication Between Two Pc
The next step is to set up the properties of the serial port. The most important properties are parity, byte size, stop bits, and baud rate. For this project, I have set the properties to no parity, 8 bits per byte, and one stop bit. The baud rate is 9600 by default, but can be changed by a command line switch to 1200, 2400, 4800, 9600, 14400, 19200, or 38400. The function set_up_serial_port does this. First, the function GetCommState is called to fill in a DCB structure that contains the current properties of the serial port. Most of these properties are advanced and don't need to be messed with. However, we will set the parity, byte size, stop bits, and baud rate. After setting these properties, the SetCommState function is called.
Now the name of the file is transmitted over the serial port so that the receiving computer knows the name of the file. To do this, the length of the file name is first transmitted and then the file name itself is transmitted. The transmission over the serial port is done using the WriteFile function.
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 200 byte increments until there is no more to receive. As the data is received, it is written to the file on the receiving computer.
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 COM1:. 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. For instance, if you discover that you need to use COM2:, change the text char port_name[] = "COM1:"; to char port_name[] = "COM2:";. Then recompile and try the program again.
step 1. The physical connection can be tested (and hardware settings controlled such as port selected, baud rate, parity, etc.) with utilities like: moserial, gtkterm, minicom, putty, ... with elementary data and file transfer capabilities.
step 2. To actually use the connection to control the host from the client requires a command interface on the host using utilities like: getty, screen, ... . Here are basic descriptions of using getty or the screen Ubuntu lucid manpages to do it. The client can often use just a "simple" serial port communication utility as in step 1. Programs such as screen or kermit are usually run on both host and client machines. If using gkermit on the host though, a console communication session must already be established, such as with getty.
EDIT: To connect two computers together via serial port requires a null modem cable. It's a serial cable that has the inputs and outputs crossed (similar to a Ethernet Crossover Cable). This enables the two computers to talk to each other.
Today's microcomputers often lack RS232 9 pin (let alone 25 pin) interfaces but Ubuntu seamlessly supports common USB to 9 pin serial adapters. Currently, a circa 1980 Atari ST with a 25 pin serial port is connected to a 2011 model netbook with only USB serial ports using such an adapter with a 25 to 9 pin adapter and a null modem adapter. The Atari came with a VT52 terminal emulator accessory to control a Lucid getty to start gkermit. The VT52 emulator is then stopped and the Atari version of kermit is then run to complete file transfers.
Computers must be running a PPP daemon, service, or software that is bound to the serial port. PPP is what lets you do IP over the serial port. It's needed if you want to do standard TCP/IP telnet, ssh, or anything else TCP/UDP/IP over a serial port. Windows supports this, but read on.
In the case of Windows, you have additional work to do since Windows does not support PPP unless you have a modem connected to that serial port. Windows sends out AT commands trying to talk to a modem before it starts PPP. So you need something on the other end that can respond as if it were a 56k modem and emit the expected chat text to the Windows system. On Linux, it's easy to tell pppd to do that. Don't know how to do that if the "remote" system is also a Windows system.
If you have an old computer with 2 serial ports, you could slap Linux on that, connect each system to the intermediary computer, start up ppp (with the Windows chat text support) on each serial port, make sure ipv4 forwarding is enabled, and it would work well.
I hope someone can help me. I am trying to make a serial ports comunication in an ARM (I am working with Linux). The thing is that I am using program called terminal in windows which I use for see the output.
Now in one of the windows I have the ARM console (this is the ttymxc1 serial port) in which I write for example "echo hello > /dev/ttymxc2" (the ttymxc2 is the other port in the other windows). When I executed it somenthing appear, somenthing like this : "". I was reading and I found out that it usually is a baud rate problem, so I change the baud rate of the "ttymxc2" to 115200 like the "ttymxc1" both with the same speed. Once I did that and I tried to send again the same echo, appear this: ::*ë so, somenthig was changing.
Based on the positive results of the /proc/tty/driver/IMX-uart tests and the garbage data received, it seems safe to assume that Linux on your ARM board is sending output when you issue the shell command echo hello > /dev/ttymxc2. And we know that you have a good serial link between the host PC and /dev/ttymxc2, the serial console.
In that situation I had, one serial port (on the SoC) was fixed at 115200 baud.But you have full control of your situation.So when you are receiving garbage data, one test to try is to reduce the baud rate (at both ends of the serial link) to 9600 or even 1200.
An inexpensive processor can be used as an interface between a PC's RS-232 port and any Maxim or Dallas 2-wire device. This allows manipulation of the 2-wire device for evaluation (during prototype) or for use during some testing procedures. The application note contains block diagrams and links to the Dallas FTP site where software and firmware examples may be downloaded to implement the application note. It is presented as a reference for customers wanting to build their own interface and is not presented as a finished product.
IntroductionThis application note discusses how to build an inexpensive microprocessor circuit to allow a PC to communicate with a 2-wire device using its serial port. In addition to providing general insight on designing hardware, firmware and software to enable PCs to communicate with ICs, a complete PIC microprocessor reference design is presented to show how PC applications can be built around 2-wire devices. The reference design includes a complete schematic, firmware, and a low level C++ serial port code to jump-start any application that would like to incorporate 2-wire devices. The schematic, firmware, and software can be downloaded from Dallas Semiconductor's FTP site.
OverviewGenerally, when customers provide feedback related to Dallas Semiconductor's evaluation kits, they indicate they are using them as a way to evaluate Dallas Semiconductor IC's without having to exert their efforts writing software to exercise the parts during the process. However, one trend that seems to be becoming more prevalent in the last couple of years is customers are using the evaluation kits to communicate with the parts during prototyping stages of the design. In the past, this has meant living with both the graphical user interface (GUI) Dallas Semiconductor has written for the product they are using, and the DS9123 serial port adapter, which is a slow method of communicating with 2-wire devices.
This application note has been written to aid customers who would like to build their own circuit to facilitate communications between a PC and 2-wire devices, and to show them how to generate their own custom software specific to their application. It is broken up into four sections that concentrate on hardware design, firmware, software, and a final section that provides a step-by-step walk-through showing how to build the reference design, program the PIC, and begin writing custom software for a 2-wire application.
The major disadvantage of choosing the serial port is it will definitely require a microprocessor to translate the RS232 data format to the 2-wire protocol, where it is possible with some other I/O devices to perform the task without the addition of a microprocessor. Additionally, the serial port uses 12V signals for communications. This will require an IC to translate the signal levels to levels a microprocessor can handle. Although it is possible to operate at data rates > 115.2kbps, both the PC and the microprocessor need to have the ability to operate at the chosen speed. Generally PCs are able to support all standard baud rates, but the microprocessor may present some limitations with respect to the speed it can send and receive data. 2ff7e9595c
Comments