Serial port mirroring method and system based on P2P network
By adopting a serial port mirroring method based on P2P network in the automotive industry, using bridges and cloud servers to realize remote connection between upper and lower computers, the problem of increased development costs and time costs caused by geographical distance is solved, and the difficulty of transporting lower computers is reduced.
Patent Information
- Application Number
- CN202510250475.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-05-09
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the automotive industry, the serial communication between the upper and lower computers increases the development cost and time cost due to geographical distance, and the lower computers are large in size and weight, making transportation difficult.
The serial port mirroring method based on P2P network is adopted, and the lower computer is identified through a bridge and added to the cloud. The lower computer status is displayed using the cloud server, and the lower computer's serial port is mirrored to the upper computer through a P2P network connection.
The remote connection between the upper and lower computers is realized, saving time and labor costs, and reducing transportation difficulties.
Smart Images

Figure CN119967002A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of network serial ports, and in particular to a serial port mirroring method and system based on a P2P network. Background Art
[0002] In the automotive industry, both the host computer and the slave computer are important components of the automotive bus software tool chain. The host computer is mainly used to test, debug and monitor the automotive bus to ensure the stability and reliability of the automotive bus system. The slave computer is mainly used to collect, process and transmit data on the automotive bus to realize the functions of the automotive bus system.
[0003] Since the host computer is a software and the slave computer is a hardware, the host computer and the slave computer need to communicate through the serial port. In many cases, the host computer development team and the slave computer development team are in different places, which requires developers to travel to the place where the slave computer development team is located for debugging, increasing development costs and time costs. In addition, when sales staff promote products, they often need to take the slave computer to the customer site for debugging, which increases travel costs and time costs, or customers need to go to the company for debugging in order to understand the product, which invisibly increases the threshold for customers to understand the product. Some slave computers are too large and heavy, which is very troublesome to carry and has transportation difficulties.
[0004] P2P (Peer-to-Peer) is a network architecture and communication mode that allows nodes (computers or other devices) in the network to communicate with each other directly and share resources without the need for data transfer through a central server. In a P2P network, each node can act as a client to request resources or as a server to provide resources. The nodes are equal in status and there is no central control node.
[0005] Therefore, it is urgent to provide a method and system solution for serial port mirroring based on a P2P network. Summary of the invention
[0006] In order to solve the above problems, the technical solution of the present invention provides a serial port mirroring method and system based on a P2P network, which can solve the communication distance problem between a host computer and a slave computer.
[0007] According to a first aspect of the technical solution of the present invention, a serial port mirroring method based on a P2P network is provided, comprising:
[0008] S1. Identify the lower computer through the bridge and add the lower computer to the cloud;
[0009] S2, display the status of all slave computers currently added to the cloud through the cloud server;
[0010] S3. Select to establish a P2P network connection with the upper computer according to the status of the connected lower computer, and mirror the serial port of the lower computer to the upper computer through the P2P network connection.
[0011] In the above solution, in step S1, the bridge has multiple serial ports connected to the lower computer.
[0012] In the above solution, in step S1, the bridge has a device identification module, and the identification module identifies the lower computer by scanning each interface.
[0013] In the above solution, in step S2, the status of the lower computer includes: idle, in use, offline and under maintenance.
[0014] In the above solution, in step S3, the cloud server assists the upper computer and the lower computer in connecting.
[0015] In the above scheme, in step S3, the serial port of the lower computer is mirrored to the upper computer through the P2P network connection, including:
[0016] Creating a virtual serial port driver on the host computer, wherein the virtual serial port driver establishes a network connection through P2P and a bridge;
[0017] The data from the host computer is forwarded to the serial port of the bridge, and the data from the serial port on the bridge connected through the P2P network is forwarded to the host computer.
[0018] In the above solution, the assistance provided by the cloud server includes:
[0019] Obtain the IP address of the host computer and the IP address of the slave computer mapped to the public network address and port;
[0020] Exchanging the public network mapping address and port information of the serial port of the upper computer and the serial port of the lower computer through the server;
[0021] The upper computer and the lower computer send UDP data packets to each other;
[0022] The UDP data packet creates mappings on the host computer and the slave computer respectively;
[0023] If the mapping is created successfully, the host computer and the slave computer communicate via the UDP data packet.
[0024] In the above solution, the server includes a signal server.
[0025] According to a second aspect of the technical solution of the present invention, a serial port mirroring system based on a P2P network is provided, the system is used to implement the serial port mirroring method based on a P2P network in the above solution, and the system includes:
[0026] An identification and adding module, used for identifying a lower computer through a bridge and adding the lower computer to the cloud;
[0027] The display module is used to display the status of all slave computers currently added to the cloud through the cloud server;
[0028] The connection module is used to select and establish a P2P network connection with the upper computer according to the state of the connected lower computer, and mirror the serial port of the lower computer to the upper computer through the P2P network connection.
[0029] According to a third aspect of the technical solution of the present invention, there is provided an electronic device, the electronic device comprising:
[0030] A memory storing executable instructions;
[0031] A processor runs the executable instructions in the memory to implement the method described in the above scheme.
[0032] Beneficial effects of the present invention:
[0033] The present invention discloses a serial port mirroring method and system based on a P2P network. Since the lower computer does not have the ability to access the network and cannot establish communication with the server, a bridge is added. The bridge is used to realize the remote connection between the upper computer and the lower computer, and the remote debugging of the lower computer in the cloud is realized, which saves time and labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0035] Figure 1 The present invention provides a flow chart of a serial port mirroring method based on a P2P network.
[0036] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0037] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0038] The terms "first", "second", etc. in the specification and claims of the present disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein, for example.
[0039] In addition, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or elements is not necessarily limited to those steps or elements explicitly listed, but may include other steps or elements not explicitly listed or inherent to such process, method, product, or apparatus.
[0040] Multiple includes two or more.
[0041] It should be understood that the term "and / or" used in this disclosure is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone.
[0042] like Figure 1 As shown, an embodiment of the technical solution of the present invention provides a serial port mirroring method based on a P2P network, comprising:
[0043] S1, identify the lower computer through the bridge and add the lower computer to the cloud;
[0044] The bridge has multiple serial ports connected to the lower computers, so it can connect to multiple lower computers at the same time. Specifically, the bridge has a device identification module, which scans periodically (such as one cycle per second) to identify the lower computers by scanning each interface. If a new lower computer is connected, it will be scanned and identified through the identification module.
[0045] S2, display the status of all slave computers currently added to the cloud through the cloud server;
[0046] The states of the lower machine include: idle, in use, offline and maintenance. Specifically, the lower machine in the idle state is considered to be usable, the offline state means that the lower machine is disconnected from the bridge, and the maintenance state means that the lower machine has a fault and needs to be repaired.
[0047] S3. Select to establish a P2P network connection with the upper computer according to the status of the connected lower computer, and mirror the serial port of the lower computer to the upper computer through the P2P network connection.
[0048] Specifically, the cloud server assists the connection between the host computer and the slave computer, including:
[0049] Get the public network mapping address and port of the host computer's IP address and the slave computer's IP address on NAT (Network Address Translation);
[0050] Exchange the public network mapping address and port information of the serial port of the upper computer and the serial port of the lower computer through an accessible server;
[0051] The upper computer uses the public network mapping address and port information of the serial port of the lower computer obtained from the server to send a UDP data packet to the lower computer; similarly, the lower computer also uses the public network mapping address and port information of the serial port of the upper computer obtained from the server to send a UDP data packet to the upper computer;
[0052] When the data packet sent by the upper computer reaches the NAT of the lower computer, if the NAT of the lower computer is a cone NAT, then this data packet will trigger NAT to create a mapping, allowing the data packet with the public network mapping address and port information from the serial port of the upper computer to directly reach the lower computer; similarly, when the data packet sent by the lower computer reaches the NAT of the upper computer, if the NAT of the upper computer is a cone NAT, then the data packet with the public network mapping address and port information from the serial port of the lower computer is allowed to directly reach the upper computer;
[0053] If the mapping is created successfully, the upper computer and the lower computer communicate through UDP data packets.
[0054] The accessible server includes a signal server, through which the public network mapping address and port information of the serial port of the upper computer and the serial port of the lower computer are exchanged.
[0055] Mirror the serial port of the lower computer to the upper computer through the P2P network connection, including:
[0056] Create a virtual serial port driver on the host computer, and the virtual serial port driver establishes a network connection through P2P and a bridge;
[0057] The data from the host computer is forwarded to the serial port of the bridge, and the data from the serial port on the bridge connected through the P2P network is forwarded to the host computer.
[0058] In this way, the host computer will think that it is communicating with the real lower computer, thereby realizing the operation of mirroring the serial port of the lower computer to the host computer.
[0059] According to a second aspect of the technical solution of the present invention, a serial port mirroring system based on a P2P network is provided, which is used to implement the serial port mirroring method based on a P2P network of the present invention, and the system includes:
[0060] Identification and adding module, used to identify the lower computer through the bridge and add the lower computer to the cloud;
[0061] The display module is used to display the status of all slave computers currently added to the cloud through the cloud server;
[0062] The connection module is used to select and establish a P2P network connection with the upper computer according to the state of the connected lower computer, and mirror the serial port of the lower computer to the upper computer through the P2P network connection.
[0063] According to a third aspect of the technical solution of the present invention, there is provided an electronic device, comprising:
[0064] A memory storing executable instructions;
[0065] The processor runs the executable instructions in the memory to implement the above method.
[0066] Example
[0067] This embodiment provides an automobile test platform, which is divided into a lower computer and an upper computer, and the upper computer and the lower computer are connected via a serial port.
[0068] Furthermore, the test platform can connect multiple slave computers through serial ports to form a more powerful test cluster. The original requirement that these slave computers must be connected in a physical space is no longer limited by this implementation. The specific serial port connection method is as follows:
[0069] Physical Connections
[0070] 1. Find the serial port interface: Determine the location of the serial port on both devices.
[0071] 2. Connect the cables: Use a serial cable (such as a DB-9 or DB-25 connector) to connect the serial ports of the two devices. If they are different types of ports, you may need an adapter.
[0072] 3. Check the connection: Make sure the cable is firmly connected and not loose.
[0073] Configure serial port parameters
[0074] 1. Set the baud rate: The baud rate is the number of symbols transmitted per second. The baud rates of the two devices must match.
[0075] 2. Set the data bits: usually set to 7 or 8 bits.
[0076] 3. Set the stop bit: usually 1 or 2 bits.
[0077] 4. Set the parity bit: it can be none, odd or even.
[0078] 5. Set flow control: it can be no flow control, hardware flow control (RTS / CTS) or software flow control (XON / XOFF).
[0079] Establish communication
[0080] 1. Open the serial port: Open the serial port in the software and prepare for communication.
[0081] 2. Configure the serial port: configure the serial port parameters in the software.
[0082] 3. Test connection: You can send test data (such as a string) to check whether the other device has received the data.
[0083] Data Transfer
[0084] 1. Send data: Send data through the serial port. The data can be text, binary or specific commands.
[0085] 2. Receive data: monitor the serial port and receive data from the other device.
[0086] 3. Data verification: Verify the received data to ensure data integrity.
[0087] End of communication
[0088] 1. Close the serial port: After the communication is completed, close the serial port in the software.
[0089] 2. Disconnect: Unplug the serial cable to end the physical connection.
[0090] A key feature of serial communication is that data is transmitted sequentially in bit order, so it is slower than parallel communication (such as parallel ports), but it can transmit data reliably over longer distances, and the interface and cables are relatively simple and inexpensive.
[0091] The lower computer of the test platform can be connected to a variety of tested devices (tested equipment, such as car lights, steering wheels, etc.) through CAN interface protocol, LIN interface, etc.
[0092] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0093] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0094] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0095] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A serial port mirroring method based on a P2P network, characterized in that: include: S1. Identify the lower computer through the bridge and add the lower computer to the cloud; S2, display the status of all slave computers currently added to the cloud through the cloud server; S3. Select to establish a P2P network connection with the upper computer according to the status of the connected lower computer, and mirror the serial port of the lower computer to the upper computer through the P2P network connection.
2. The serial port mirroring method based on P2P network according to claim 1, characterized in that: In step S1, the bridge has multiple serial ports connected to the lower computer.
3. The serial port mirroring method based on P2P network according to claim 1, characterized in that: In step S1, the bridge has a device identification module, and the identification module identifies the lower computer by scanning each interface.
4. The serial port mirroring method based on P2P network according to claim 1, characterized in that: In step S2, the status of the slave computer includes: idle, in use, offline and under maintenance.
5. The serial port mirroring method based on P2P network according to claim 1, characterized in that: In step S3, the cloud server assists the upper computer and the lower computer in connecting.
6. The serial port mirroring method based on P2P network according to claim 1, characterized in that: In step S3, the serial port of the lower computer is mirrored to the upper computer through the P2P network connection, including: Creating a virtual serial port driver on the host computer, wherein the virtual serial port driver establishes a network connection through P2P and a bridge; The data from the host computer is forwarded to the serial port of the bridge, and the data from the serial port on the bridge connected through the P2P network is forwarded to the host computer.
7. The serial port mirroring method based on P2P network according to claim 5, characterized in that: Assistance provided by the cloud server includes: Obtain the IP address of the host computer and the IP address of the slave computer mapped to the public network address and port; Exchanging the public network mapping address and port information of the serial port of the upper computer and the serial port of the lower computer through the server; The upper computer and the lower computer send UDP data packets to each other; The UDP data packet creates mappings on the host computer and the slave computer respectively; If the mapping is created successfully, the host computer and the slave computer communicate via the UDP data packet.
8. The serial port mirroring method based on P2P network according to claim 7, characterized in that: The server comprises a signal server.
9. A serial port mirroring system based on a P2P network, characterized in that: The system is used to implement the serial port mirroring method based on a P2P network according to any one of claims 1 to 8, and the system includes: An identification and adding module, used for identifying a lower computer through a bridge and adding the lower computer to the cloud; The display module is used to display the status of all slave computers currently added to the cloud through the cloud server; The connection module is used to select and establish a P2P network connection with the upper computer according to the state of the connected lower computer, and mirror the serial port of the lower computer to the upper computer through the P2P network connection.
10. An electronic device, characterized in that: The electronic device comprises: A memory storing executable instructions; A processor, wherein the processor runs the executable instructions in the memory to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method for implementing serial port networking on basis of network transmission
CN104506407A
Method for updating PowerPC motherboard guide chip online
CN106598654A
Remote system for PLC equipment debugging and method thereof
CN109884978A
PLC equipment remote data communication implementation method based on virtual serial port
CN111506013A
Verification method and verification system of multi-board multi-channel serial port card
CN113868063A