当前位置:网站首页>Using SylixOS virtual serial port, serial port free implementation system

Using SylixOS virtual serial port, serial port free implementation system

2022-08-10 21:28:00 ScilogyHunter

In the blog "Open the second serial port command line of the virtual machine", I talked about how to make the virtual machineThe serial port is connected to the virtual serial port or physical serial port of the Windows system.In the simulator, not all platforms have a second serial port, only bsp support is required, and at most there can only be a second serial port but not a third or fourth serial port.For an actual physical board, the number of serial ports is naturally fixed.

So, can you add any virtual serial port to SylixOS like the virtual serial port on Windows?The answer is yes, the author has recently developed a set of SylixOS virtual device related programs, one of which is to create virtual character devices.The virtual serial port is a character device, so it is natural to create a virtual serial port. In fact, the virtual character device is designed according to the character device framework, and does not care about the specific device type, and the device name can be arbitrarily specified.

Start a virtual machine and view the device list as follows. It can be seen that the system currently has only one serial port, and it has been used as a system command line.
insert image description here
Next, install the VCD virtual character device kernel module
insert image description here
Create a virtual device "dev/tty1"
insert image description here
insert image description here

Start a serial port application, the function is to return the received content as it is.At the same time, use the network debugging assistant to connect the socket of the virtual serial port, and send data to it to see if there is a response.
insert image description here
insert image description here

View the current status of the virtual device
insert image description here

The

printen command is used to dynamically enable or disable the debugging printing of the corresponding virtual device for test analysis.
insert image description here
insert image description here
This example logic diagram
insert image description here

Another practical scenario is: Originally, the device and the host computer are connected through the serial port for debugging, but the actual device development and the host computer development are not in the same city, so the same logical connection can be achieved with the help of virtual serial port and intranet penetration.

insert image description here

insert image description here

To sum up briefly, the virtual serial port (or any virtual character device) is installed and run as a kernel module (either a physical machine or a virtual machine, no difference), and the vcd command is provided, which can be freely created and viewed through command operations.Delete the virtual device.One end of the virtual device provides a standard device file interface, which can be called indiscriminately by applications (compared to the real device);Software such as application programs, virtual serial ports, or network-to-serial ports.The application is very flexible and convenient.

From now on, you can add as many virtual serial port devices as you like, no matter whether you are using SylixOS as a virtual machine or a physical machine, for application calls.

原网站

版权声明
本文为[ScilogyHunter]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208102055276869.html