This affords remote capabilities that increase the value of your company’s serial peripheral devices. Devices connected through virtual ports provide the VMs with full control over the peripherals, just as if a direct physical connection had been established. Simply unplugging and connecting a different device to the local machine makes it available to any network-connected virtual session.
How to setup serial port in VirtualBox
VirtualBox Serial Port machines also offer support for virtual serial ports in a virtual machine. When the virtual serial port becomes enabled, the guest OS is presented with a UART device that is standard compatible. Here, both the reception and transmission of data is possible. The connection between the host and the virtual serial port can be configured. However, the exact details are dependent on the host OS.
You can use the VBoxManage command or the Settings tab to command the establishment of virtual serial ports. In one of the methods, you can configure a maximum of 4 virtual serial ports for each virtual machine.
This means setting things such as Port Mode and Port Number.
The Port Number is what determines the serial port that the virtual machine sees. Traditional values need to be used for best results. A user-defined serial port can also be configured. Enter an I/O base address and IRQ.
- Port Mode refers to what the virtual port is connected to. Port Mode can be Disconnected, Connected to Host Device, or Connected to Host Pipe.
- Disconnected means the device will be visible to the guest, but will function as though no cable has been connected.
- The Host Device Connection entails physically connecting the serial port to serial pot on the host. In Windows, this will, typically, be denoted by a name like COM1. On Linux, you’ll find something like /dev/ttyS0. VirtualBox will then just redirect all the data (received from and sent to the virtual port) to the physical device.
- In the Host Pipe connection, the Oracle VM VirtualBox is configured to connect the virtual serial port to one of the host’s software pipe. This is done in accordance with the host OS:
- On Windows, the data is sent/received via a named pipe. The pipe name is registered as \\.\pipe\ where is used to identify the machine, but may be chosen on a whim.
- In a Mac, a local domain socket comes into play. The socket filename is chosen in a way that allows the VirtualBox user to enjoy certain privileges with regards to creating and writing it. The tmp is a common choice.
- In Linux, some multiples tools connect to a local domain socket or develop one in server mode. Socat is the most usable and is available across distributions.
In this scenario, the VirtualBox can be configured to create the local domain socket non-Windows hosts, the named pipe, or itself, etc. Also, the VirtualBox must assume that the socket or pipe is in existence already.
In the case of a direct connection between two virtual machines, configure one virtual machine to develop a socket or pipe and the other one to attach to it.
Raw File: The virtual serial port output can be sent to a file. This is helpful for collecting diagnostic output. Any file can be used. The only requirement is that VirtualBox users has enough privileges to write and create.
TCP Socket: This helps forward serial traffic over TCP/IP. It can act as a TCP client that connects to servers or a server itself. The option allows for the direct connection between the remote machine and the guest's serial port via TCP.
1. TCP Server: The current Pipe/Socket checkbox needs to be deselected and the port number specified in the address/path field. The port number can be 23 or 2023. In the case of UNIX-like systems, the port number has to be more than 1024.
2. TCP Client: For the purpose of creating virtual null-modem cable over the LAN/Internet, the other end should connect via TCP, while specifying the hostname: port in the Path/Address field. When the "Connect to Existing Pipe/Socket" box is ticked, the TCP socket will go into client mode.
As you can see, 4 serial ports can be configured or each virtual machine. However, multiple port numbers can be picked.