WO2015131553A1 - 一种数据传输的方法和系统 - Google Patents

一种数据传输的方法和系统 Download PDF

Info

Publication number
WO2015131553A1
WO2015131553A1 PCT/CN2014/091392 CN2014091392W WO2015131553A1 WO 2015131553 A1 WO2015131553 A1 WO 2015131553A1 CN 2014091392 W CN2014091392 W CN 2014091392W WO 2015131553 A1 WO2015131553 A1 WO 2015131553A1
Authority
WO
WIPO (PCT)
Prior art keywords
serial port
virtual serial
data
port
virtual
Prior art date
Application number
PCT/CN2014/091392
Other languages
English (en)
French (fr)
Inventor
杜进芳
陈飞雄
张旭辉
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015131553A1 publication Critical patent/WO2015131553A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45595Network integration; Enabling network access in virtual machine instances

Definitions

  • the present invention relates to the field of terminal communication technologies, and in particular, to a method and system for data transmission.
  • serial port is called serial interface, also called serial communication interface. It includes RS-232-C, RS-422, RS485, USB, etc. according to electrical standards and protocols.
  • the serial port is generally used in the product development stage. After the product development is completed, the serial port will be removed from the final product due to cost and security factors. Even if the serial port is reserved, the user really wants to use it. The serial port needs to open the device case, which is very troublesome to operate. However, these network terminal devices generally retain the network port.
  • serial port-based application on the PC side cannot be directly applied to a terminal with a network port. Therefore, a new solution is needed to implement data interaction with the terminal without rewriting the PC-side application.
  • the embodiment of the invention provides a data transmission method and system, which can implement a data exchange between a serial port-based application of a host computer and a terminal through a network port.
  • an embodiment of the present invention provides a data transmission method, which is applied to a host computer, and the host computer establishes a network connection with a terminal through a network port, and the method includes:
  • the application of the upper computer passes through the first virtual serial port and the second virtual serial port. Data transmission is performed between the network port and the terminal.
  • the method further includes the following features:
  • the application of the host computer performs data transmission between the network port and the terminal by using the first virtual serial port and the second virtual serial port, including:
  • the method further includes the following features:
  • the method further includes:
  • Reading by the application of the upper computer, the data-converted second data from the first virtual serial port.
  • the method further includes the following features:
  • the virtual serial port driver After the installation is successful, a pair of interconnected virtual serial ports are virtualized.
  • the first virtual serial port is used for reading and writing of the upper computer application, and the second virtual serial port is used for network port-serial port conversion and reading.
  • the method further includes the following features:
  • the baud rate of the first virtual serial port and the second virtual serial port are configured according to the rate of the network port, and the baud rate of the first virtual serial port is equal to the baud rate of the second virtual serial port.
  • the embodiment of the present invention further provides a system for data transmission, which is applied to a host computer, and the host computer establishes a network connection with the terminal through a network port, including:
  • a communication connection establishing module configured to: create a first virtual serial port for reading and writing of an application of the upper computer; and a second virtual serial port for network port-serial port conversion and reading;
  • the network port-serial port transmission module is configured to enable the application of the host computer to perform data transmission between the network port and the terminal through the first virtual serial port and the second virtual serial port.
  • system further includes the following features:
  • the network port-serial transmission module includes:
  • An application module configured to: write, by the application of the upper computer, the first data into the first virtual serial port;
  • a virtual serial communication module configured to: transmit the first data to the second virtual serial port by using the first virtual serial port
  • the network port-serial conversion module is configured to: read the first data from the second virtual serial port, perform data conversion, and then send the data to the network port; Data is sent to the terminal.
  • system further includes the following features:
  • the network port-serial conversion module is further configured to read, from the network port, the second data that is sent by the terminal after receiving the first data, and perform data conversion and then send the data to the second virtual serial port;
  • the virtual serial communication module is further configured to transmit the data-converted second data to the first virtual serial port by using the second virtual serial port;
  • the serial port application module is further configured to read the data-converted second data from the first virtual serial port by using an application of the upper computer.
  • system further includes the following features:
  • the communication connection establishing module is configured to create a first virtual serial port for reading and writing of an application for the upper computer and a second virtual serial port for network port-serial conversion and reading and writing in the following manner:
  • the virtual serial port driver After the installation is successful, a pair of interconnected virtual serial ports are virtualized.
  • the first virtual serial port is used for reading and writing of the upper computer application, and the second virtual serial port is used for network port-serial port conversion and reading.
  • the first virtual serial port transmitting the input data to the second virtual serial port as an output of the second virtual serial port;
  • the second virtual serial port transmits the input data to the first virtual serial port as an output of the first virtual serial port.
  • system further includes the following features:
  • the communication connection establishing module is further configured to: when creating a first virtual serial port for reading and writing by the application of the upper computer, and a second virtual serial port for converting the network port to the serial port, according to the network port Rate configures the baud rate of the first virtual serial port and the second virtual serial port, and the baud rate of the first virtual serial port is equal to the baud rate of the second virtual serial port.
  • Embodiments of the present invention also provide a computer program comprising program instructions that, when executed by a computer, cause the computer to perform the above method.
  • Embodiments of the present invention also provide a computer readable storage medium carrying the computer program.
  • a method and system for data transmission provided by an embodiment of the present invention, by creating a first virtual serial port for reading and writing by an application of a host computer, and a second virtual serial port for converting and reading a network port-serial port;
  • the application of the machine performs data transmission between the network port and the terminal through the first virtual serial port and the second virtual serial port, so that the serial port-based application of the upper computer interacts with the terminal through the network port.
  • FIG. 1 is a flowchart of a method for data transmission according to an embodiment of the present invention
  • FIG. 2 is a flow chart of data transmission between the upper computer and the terminal in FIG. 1;
  • FIG. 3 is a schematic structural diagram of a system for data transmission according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a network port-serial port transmission module in the system of FIG. 3;
  • FIG. 5 is a schematic diagram of data transmission between a virtual serial port and a network port according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of establishing a communication connection between a PC and a terminal according to an embodiment of the present invention
  • FIG. 7 is a schematic diagram of data flow involved in a method according to an embodiment of the present invention.
  • an embodiment of the present invention provides a data transmission method, where the upper computer establishes a network connection with a terminal through a network port, and the method includes:
  • the application of the upper computer performs data transmission between the network port and the terminal by using the first virtual serial port and the second virtual serial port.
  • the application of the host computer performs data transmission between the network port and the terminal by using the first virtual serial port and the second virtual serial port, including:
  • the first data is transmitted to the second virtual serial port by using the first virtual serial port.
  • the first data is read from the second virtual serial port, and the data is converted and sent to the network port.
  • the method further includes:
  • the second data sent by the terminal after receiving the first data is read from the network port, and the data is converted and sent to the second virtual serial port.
  • the application program of the upper computer is used for debugging, troubleshooting, and upgrading the terminal.
  • the virtual serial port driver After the installation is successful, a pair of interconnected virtual serial ports are virtualized.
  • the first virtual serial port is used for reading and writing of the upper computer application, and the second virtual serial port is used for network port-serial port conversion and reading.
  • the first virtual serial port transmitting the input data to the second virtual serial port as an output of the second virtual serial port;
  • the second virtual serial port transmits the input data to the first virtual serial port as an output of the first virtual serial port.
  • the first virtual serial port for creating and writing the application for the upper computer and the second virtual serial port for the network port-serial port conversion and reading further include:
  • the baud rate of the first virtual serial port and the second virtual serial port are configured according to the rate of the network port, and the baud rate of the first virtual serial port is equal to the baud rate of the second virtual serial port.
  • the virtual drive works in a core mode operation mode
  • the core state is the mode in which the operating system kernel runs.
  • the code running in this mode can access system storage and external devices without restrictions.
  • the main difference between the core state and the user state is that when the user state is executed, the memory space and objects that the process can access are restricted, and the processor it occupies can be preempted, but in the core state execution.
  • the process can access all the memory space and objects, and the processor it occupies is not allowed to be preempted.
  • the upper computer establishes a network connection with the terminal through the network port, and the host computer establishes a socket communication connection with the terminal through the network port.
  • the method further includes: after the application completes the operation on the terminal, the first virtual serial port, the second virtual serial port, and the read/write portion of the network port are deactivated to release resources;
  • an embodiment of the present invention provides a system for data transmission, which is applied to a host computer, and the host computer establishes a network connection with a terminal through a network port, including:
  • a communication connection establishing module configured to create a first virtual serial port for reading and writing of an application of the upper computer, and a second virtual serial port for network port-serial port conversion and reading;
  • the network port-serial port transmission module is configured to perform data transmission between the network port and the terminal by using the first virtual serial port and the second virtual serial port by the application of the upper computer.
  • the network port-serial transmission module includes:
  • An application module configured to write first data into the first virtual serial port by using an application of the upper computer
  • the virtual serial communication module is configured to transmit the first data to the second virtual serial port by using the first virtual serial port;
  • the network port-serial conversion module is configured to read the first data from the second virtual serial port, perform data conversion, and send the data to the network port; send the first data to the network port through the network port Said terminal.
  • the network port-serial conversion module is further configured to read, from the network port, the second data that is sent by the terminal after receiving the first data, and perform data conversion and then send the data to the second virtual serial port;
  • the virtual serial communication module is further configured to transmit the second data to the first virtual serial port by using the second virtual serial port;
  • the serial port application module is further configured to read the second data from the first virtual serial port by using an application of the upper computer.
  • the communication connection establishing module is configured to: create a first virtual serial port for reading and writing of an application for the upper computer and a second virtual serial port for network port-serial conversion and reading and writing in the following manner:
  • the virtual serial port driver After the installation is successful, a pair of interconnected virtual serial ports are virtualized.
  • the first virtual serial port is used for reading and writing of the upper computer application, and the second virtual serial port is used for network port-serial port conversion and reading.
  • the first virtual serial port transmitting the input data to the second virtual serial port as an output of the second virtual serial port;
  • the second virtual serial port transmits the input data to the first virtual serial port as an output of the first virtual serial port.
  • the virtual drive works in a core mode operation mode
  • the upper computer establishes a network connection with the terminal through the network port, and the host computer establishes a socket communication connection with the terminal through the network port.
  • the communication connection establishing module is further configured to: when the first virtual serial port for reading and writing the application for the upper computer and the second virtual serial port for the network port-serial port conversion and reading are created, according to the network port
  • the rate of the first virtual serial port and the second virtual serial port are configured, and the baud rate of the first virtual serial port is equal to the baud rate of the second virtual serial port.
  • the virtual driver is first installed on the PC. After the installation is successful, a pair of virtual serial ports are virtualized on the PC.
  • the serial port is defined as virtual serial port 1 and virtual serial port 2; the serial port application reads and writes the virtual serial port 1, writes the operation instruction to the device through the virtual serial port 1, and can also read the feedback information of the terminal device through the virtual serial port 1; the virtual serial port 1 and the virtual serial port 2 completes the data exchange through the core state virtual driver; the virtual driver writes the application data to the virtual serial port 1 as the output of the virtual serial port 2 for the network port to the serial port tool to read, and writes the network port to the serial port tool The data entered into the virtual serial port 2 is converted into the output of the virtual serial port 1 for reading by the serial port application.
  • the network port to serial port tool is a user mode application, and the data having the read virtual serial port (virtual serial port 2) is written to The function
  • the network port to serial port tool can include the following functional modules:
  • the configuration file storage module stores the configuration content of the user, where the configuration includes configuring the network port rate, configuring the port number and IP address of the socket communication, and configuring the baud rate of the virtual serial port (virtual serial port 2);
  • the data reading and writing module realizes the function of opening and closing the virtual serial port (virtual serial port 2), and reading and writing functions of the virtual serial port (virtual serial port 2) and the network port;
  • the resource release module releases the virtual serial port (virtual serial port 2) and the network port resource;
  • the process of creating a communication connection between a PC and a terminal in the embodiment of the present invention may include the following steps:
  • the network port is transferred to the serial port tool, and the baud rate of the virtual serial port 2 is configured according to the network port rate of the terminal to achieve correct codec.
  • the serial port-based application program configures the wave of the virtual serial port 1 according to the network port rate of the terminal.
  • the rate of the virtual serial port 1 and the virtual serial port 2 are the same;
  • the process of writing data to the terminal by the serial port-based application may include the following steps:
  • the serial port based application writes data (Data1) to the virtual serial port 1;
  • the virtual serial port 1 transparently transmits data (Data1) to the virtual serial port 2 through the virtual driver, as an output of the virtual serial port 2;
  • the network port to serial port tool reads data from the virtual serial port 2 (Data1);
  • the network port to serial port tool writes the data (Data1) read by the virtual serial port 2 to the network port;
  • the process of reading data from the terminal by the serial port-based application may include the following steps:
  • the network port to serial port tool reads the data fed back by the terminal from the network port through the socket communication (Data2);
  • the network port to serial port tool writes data (Data2) read from the network port to the virtual serial port 2;
  • the virtual serial port 2 transparently transmits data (Data2) to the virtual serial port 1 through the virtual driver, as an output of the virtual serial port 1;
  • the serial port-based application reads the data fed back by the device from the virtual serial port 1 (Data2);
  • the network port to serial port tool disables the read/write function of the virtual serial port 2 and the network port, and the serial port application disables the read/write function of the virtual serial port 1 to release resources;
  • the system can also be optimized, and the system API is used to monitor network messages to confirm the device insertion and removal, thereby completing the automatic initialization and automatic release of the virtual serial port;
  • the method and system for data transmission provided by the foregoing embodiment are: creating a first virtual serial port for reading and writing by the application program of the upper computer and a second virtual serial port for converting the network port-serial port; the upper computer
  • the application transmits data from the network port and the terminal through the first virtual serial port and the second virtual serial port, so that the serial port-based application of the upper computer interacts with the terminal through the network port.
  • the embodiment of the present invention creates a first virtual serial port for reading and writing by the application program of the upper computer and a second virtual serial port for network port-serial port conversion and reading; the application of the upper computer passes the first virtual serial port. And the second virtual serial port performs data transmission between the network port and the terminal, so that the serial port-based application of the upper computer exchanges data with the terminal through the network port.

Abstract

一种数据传输的方法和系统,应用于上位机,所述上位机通过网口与终端建立网络连接,该方法包括:创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;所述上位机的应用程序通过所述第一虚拟串口、第二虚拟串口,从所述网口与所述终端之间进行数据传输。

Description

一种数据传输的方法和系统 技术领域
本发明涉及终端通信技术领域,尤其涉及的是一种数据传输的方法和系统。
背景技术
利用PC对网络终端设备进行调试、故障诊断、设备本地升级时,PC端应用程序一般通过串口与网络终端设备进行数据交互。串口叫做串行接口,也称串行通信接口,按电气标准及协议来分包括RS-232-C、RS-422、RS485、USB等。
对于某些网络终端设备,比如,上网猫,串口一般在产品研发阶段使用,产品研发完成后,出于成本、安全等因素考虑,串口会从最终产品中去除,即使保留串口,用户真想使用串口时需要打开设备外壳,操作非常麻烦。但是,这些网络终端设备一般会保留网口。
PC侧的基于串口的应用程序不能直接应用于具有网口的终端,因此,需要一种新的解决方案,在无需改写PC侧应用程序的前提下,实现与终端的数据交互。
发明内容
本发明实施例提供一种数据传输的方法和系统,能够实现上位机的基于串口的应用程序通过网口与终端进行数据交互。
为了解决上述技术问题,本发明实施例提供了一种数据传输的方法,应用于上位机,所述上位机通过网口与终端建立网络连接,该方法包括:
创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;
所述上位机的应用程序通过所述第一虚拟串口以及第二虚拟串口,在所 述网口与所述终端之间进行数据传输。
可选地,该方法还包括下述特点:
所述上位机的应用程序通过所述第一虚拟串口、第二虚拟串口,从所述网口与所述终端之间进行数据传输,包括:
通过所述上位机的应用程序将第一数据写入所述第一虚拟串口中;
通过所述第一虚拟串口将所述第一数据传输到所述第二虚拟串口中;
从所述第二虚拟串口中读取所述第一数据,进行数据转换后发送到所述网口;
通过所述网口将经过数据转换的第一数据发送给所述终端。
可选地,该方法还包括下述特点:
所述通过所述网口将经过数据转换的第一数据发送给所述终端之后,还包括:
从所述网口中读取所述终端接收到经过数据转换的第一数据后发送的第二数据,进行数据转换后发送到所述第二虚拟串口中;
通过所述第二虚拟串口将经过数据转换的第二数据传输到所述第一虚拟串口中;
通过所述上位机的应用程序从所述第一虚拟串口中读取经过数据转换的第二数据。
可选地,该方法还包括下述特点:
所述创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口,包括:
安装虚拟串口驱动程序,安装成功后虚拟出一对相互连接的虚拟串口,其中第一虚拟串口用于上位机的应用程序读写,第二虚拟串口用于网口-串口转换读写;
所述第一虚拟串口和第二虚拟串口之间通过虚拟驱动传输数据,包括:所述第一虚拟串口将输入的数据传输给所述第二虚拟串口,作为所述第二虚拟串口的输出;所述第二虚拟串口将输入的数据传输给所述第一虚拟串口, 作为所述第一虚拟串口的输出。
可选地,该方法还包括下述特点:
所述创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口,还包括:
根据所述网口的速率配置第一虚拟串口和第二虚拟串口的波特率,且第一虚拟串口的波特率与第二虚拟串口的波特率相等。
为了解决上述技术问题,本发明实施例还提供了一种数据传输的系统,应用于上位机,所述上位机通过网口与终端建立网络连接,包括:
通信连接建立模块,其设置为:创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;
网口-串口传输模块,其设置为:令所述上位机的应用程序通过所述第一虚拟串口以及第二虚拟串口,在所述网口与所述终端之间进行数据传输。
可选地,该系统还包括下述特点:
所述网口-串口传输模块包括:
应用程序模块,其设置为:通过所述上位机的应用程序将第一数据写入所述第一虚拟串口中;
虚拟串口通信模块,其设置为:通过所述第一虚拟串口将所述第一数据传输到所述第二虚拟串口中;
网口-串口转换模块,其设置为:从所述第二虚拟串口中读取所述第一数据,进行数据转换后发送到所述网口;通过所述网口将经过数据转换的第一数据发送给所述终端。
可选地,该系统还包括下述特点:
网口-串口转换模块,还设置为从所述网口中读取所述终端接收到所述第一数据后发送的第二数据,进行数据转换后发送到所述第二虚拟串口中;
虚拟串口通信模块,还设置为通过所述第二虚拟串口将经过数据转换的第二数据传输到所述第一虚拟串口中;
串口应用程序模块,还设置为通过所述上位机的应用程序从所述第一虚拟串口中读取经过数据转换的第二数据。
可选地,该系统还包括下述特点:
通信连接建立模块,是设置为以如下方式创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口:
安装虚拟串口驱动程序,安装成功后虚拟出一对相互连接的虚拟串口,其中第一虚拟串口用于上位机的应用程序读写,第二虚拟串口用于网口-串口转换读写;
所述第一虚拟串口和第二虚拟串口之间通过虚拟驱动传输数据,包括:所述第一虚拟串口将输入的数据传输给所述第二虚拟串口,作为所述第二虚拟串口的输出;所述第二虚拟串口将输入的数据传输给所述第一虚拟串口,作为所述第一虚拟串口的输出。
可选地,该系统还包括下述特点:
通信连接建立模块,还设置为:在创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口时,根据所述网口的速率配置第一虚拟串口和第二虚拟串口的波特率,且第一虚拟串口的波特率与第二虚拟串口的波特率相等。
本发明实施例还提供一种计算机程序,包括程序指令,当该程序指令被计算机执行时,使得该计算机可执行上述方法。
本发明实施例还提供一种载有所述计算机程序的计算机可读存储介质。
本发明实施例提供的一种数据传输的方法和系统,通过创建用于上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;所述上位机的应用程序通过所述第一虚拟串口、第二虚拟串口,从所述网口与所述终端之间进行数据传输,从而实现上位机的基于串口的应用程序通过网口与终端进行数据交互。
附图概述
图1为本发明实施例的一种数据传输的方法的流程图;
图2为图1中上位机与终端之间进行数据传输的流程图;
图3为本发明实施例的一种数据传输的系统结构示意图;
图4为图3所述系统中网口-串口传输模块的结构示意图;
图5为本发明实施例虚拟串口和网口之间进行数据传输的示意图;
图6为本发明实施例建立PC机与终端之间的通信连接的示意图;
图7为本发明实施例的方法涉及到的数据流示意图。
本发明的较佳实施方式
下文中将结合附图对本发明的实施例进行详细说明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互任意组合。
如图1所示,本发明实施例提供了一种数据传输的方法,所述上位机通过网口与终端建立网络连接,该方法包括:
S10,创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;
S20,所述上位机的应用程序通过所述第一虚拟串口以及第二虚拟串口,在所述网口与所述终端之间进行数据传输。
其中,如图3所示,所述上位机的应用程序通过所述第一虚拟串口以及第二虚拟串口,在所述网口与所述终端之间进行数据传输,包括:
S101,通过所述上位机的应用程序将第一数据写入所述第一虚拟串口中;
S102,通过所述第一虚拟串口将所述第一数据传输到所述第二虚拟串口中;
S103,从所述第二虚拟串口中读取所述第一数据,进行数据转换后发送到所述网口;
S104,通过所述网口将经过数据转换的第一数据发送给所述终端。
其中,所述通过所述网口将所述经过数据转换的第一数据发送给所述终端之后,还包括:
S105,从所述网口中读取所述终端接收到所述第一数据后发送的第二数据,进行数据转换后发送到所述第二虚拟串口中;
S106,通过所述第二虚拟串口将精数据转换的第二数据传输到所述第一虚拟串口中;
S107,通过所述上位机的应用程序从所述第一虚拟串口中读取所述经过数据转换的第二数据。
其中,所述上位机的应用程序用于对终端进行调试、故障排查及升级。
其中,所述创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口,包括:
安装虚拟串口驱动程序,安装成功后虚拟出一对相互连接的虚拟串口,其中第一虚拟串口用于上位机的应用程序读写,第二虚拟串口用于网口-串口转换读写;
所述第一虚拟串口和第二虚拟串口之间通过虚拟驱动传输数据,包括:所述第一虚拟串口将输入的数据传输给所述第二虚拟串口,作为所述第二虚拟串口的输出;所述第二虚拟串口将输入的数据传输给所述第一虚拟串口,作为所述第一虚拟串口的输出。
其中,所述创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口,还包括:
根据所述网口的速率配置第一虚拟串口和第二虚拟串口的波特率,且第一虚拟串口的波特率与第二虚拟串口的波特率相等。
其中,所述虚拟驱动工作在核心态运行模式;
在处理器的存储保护中,主要有两种权限状态,一种是核心态(管态),也被称为特权态;一种是用户态(目态)。核心态是操作系统内核所运行的模式,运行在该模式的代码,可以无限制地对系统存储、外部设备进行访问。核心态和用户态的主要差别是:处于用户态执行时,进程所能访问的内存空间和对象受到限制,其所占有的处理机是可被抢占的,而处于核心态执行中 的进程,则能访问所有的内存空间和对象,其所占有的处理机是不允许被抢占的。
其中,所述上位机通过网口与终端建立网络连接,包括:所述上位机通过网口与终端建立socket通信连接。
可选地,所述方法还包括:在应用程序完成对终端的操作后,停用所述第一虚拟串口、第二虚拟串口和网口的读写部分,释放资源;
如图3所示,本发明实施例提供了一种数据传输的系统,应用于上位机,所述上位机通过网口与终端建立网络连接,包括:
通信连接建立模块,设置为创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;
网口-串口传输模块,设置为所述上位机的应用程序通过所述第一虚拟串口、第二虚拟串口,从所述网口与所述终端之间进行数据传输。
其中,如图4所示,网口-串口传输模块包括:
应用程序模块,设置为通过所述上位机的应用程序将第一数据写入所述第一虚拟串口中;
虚拟串口通信模块,设置为通过所述第一虚拟串口将所述第一数据传输到所述第二虚拟串口中;
网口-串口转换模块,设置为从所述第二虚拟串口中读取所述第一数据,进行数据转换后发送到所述网口;通过所述网口将所述第一数据发送给所述终端。
其中,网口-串口转换模块,还设置为从所述网口中读取所述终端接收到所述第一数据后发送的第二数据,进行数据转换后发送到所述第二虚拟串口中;
虚拟串口通信模块,还设置为通过所述第二虚拟串口将所述第二数据传输到所述第一虚拟串口中;
串口应用程序模块,还设置为通过所述上位机的应用程序从所述第一虚拟串口中读取所述第二数据。
其中,通信连接建立模块,是设置为以如下方式创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口:
安装虚拟串口驱动程序,安装成功后虚拟出一对相互连接的虚拟串口,其中第一虚拟串口用于上位机的应用程序读写,第二虚拟串口用于网口-串口转换读写;
所述第一虚拟串口和第二虚拟串口之间通过虚拟驱动传输数据,包括:所述第一虚拟串口将输入的数据传输给所述第二虚拟串口,作为所述第二虚拟串口的输出;所述第二虚拟串口将输入的数据传输给所述第一虚拟串口,作为所述第一虚拟串口的输出。
其中,所述虚拟驱动工作在核心态运行模式;
其中,所述上位机通过网口与终端建立网络连接,包括:所述上位机通过网口与终端建立socket通信连接。
其中,通信连接建立模块,还设置为在创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口时,根据所述网口的速率配置第一虚拟串口和第二虚拟串口的波特率,且第一虚拟串口的波特率与第二虚拟串口的波特率相等。
如图5所示,具体实施时,首先在PC机上安装虚拟驱动,安装成功后在PC机上虚拟出一对虚拟串口,比如在PC的设备管理器可以看到com3、com4,将这两个虚拟串口定义为虚拟串口1、虚拟串口2;串口应用程序对虚拟串口1进行读写,通过虚拟串口1写入对设备的操作指令,也可以通过虚拟串口1读取终端设备反馈的信息;虚拟串口1和虚拟串口2通过核心态虚拟驱动完成数据交换;虚拟驱动将应用程序写入到虚拟串口1的数据作为虚拟串口2的输出供网口转串口工具读取,并将网口转串口工具写入到虚拟串口2的数据转化为虚拟串口1的输出供串口应用程序读取,这里的网口转串口工具是用户态的应用程序,具有读取虚拟串口(虚拟串口2)的数据写入到网口和读取网口的数据写入到虚拟串口(虚拟串口2)的功能;
为达到上述目的,网口转串口工具可以包含如下几个功能模块:
配置文件存储模块,存储用户的配置内容,所述配置包括配置网口速率,配置socket通信的端口号和IP地址,配置虚拟串口(虚拟串口2)的波特率;
初始化模块,初始化网口和虚拟串口(虚拟串口2);
数据读写模块,实现对虚拟串口(虚拟串口2)的打开关闭功能,对虚拟串口(虚拟串口2)及网口的读写功能;
资源释放模块,释放虚拟串口(虚拟串口2)和网口资源;
如图6所示,本发明实施例创建PC机与终端之间的通信连接的流程可以包括以下步骤:
S601,安装虚拟驱动,虚拟出一对虚拟串口,其中,虚拟串口1供基于串口的应用程序读写,虚拟串口2供网口转串口工具读写,虚拟串口1和虚拟串口2可以通过虚拟驱动完成数据交互;
S602,通过网线连接PC机和终端;
S603,安装并打开网口转串口工具;
S604,通过网口转串口工具,根据终端的网口速率配置虚拟串口2的波特率,以达到正确的编解码;通过基于串口的应用程序,根据终端的网口速率配置虚拟串口1的波特率,使虚拟串口1和虚拟串口2的波特率相同;
S605,通过网口转串口工具,根据终端的socket端口号,正确配置与终端间进行socket通讯的端口号,根据终端特性配置PC机作为socket服务器端或者socket客户端。
S606,配置完成后,对虚拟串口和网口进行初始化,正式启用虚拟串口,应用程序与终端建立通讯。
如图7所示,基于串口的应用程序将数据写入到终端的流程可以包括下述步骤:
S701,基于串口的应用程序将数据(Data1)写入虚拟串口1;
S702,虚拟串口1通过虚拟驱动将数据(Data1)透传到虚拟串口2,作为虚拟串口2的输出;
S703,网口转串口工具从虚拟串口2读出数据(Data1);
S704,网口转串口工具将虚拟串口2读出的数据(Data1)写入到网口;
S705,通过socket通讯,最终将数据(Data1)写入到终端;
基于串口的应用程序从终端读取数据的流程可以包括下述步骤:
S706,网口转串口工具通过socket通讯从网口读出终端反馈的数据(Data2);
S707,网口转串口工具将从网口读出的数据(Data2)写入到虚拟串口2;
S708,虚拟串口2通过虚拟驱动将数据(Data2)透传到虚拟串口1,作为虚拟串口1的输出;
S709,基于串口的应用程序从虚拟串口1读取设备反馈的数据(Data2);
最终完成基于串口的应用程序与设备间的数据交互,实现PC机对终端的调试、故障排查及升级等功能。
功能操作完成后,网口转串口工具停用虚拟串口2及网口的读写功能,串口应用程序停用虚拟串口1的读写功能,释放资源;
还可以优化该系统,通过系统API监听网络报文来确认设备插拔情况,进而完成虚拟串口的自动初始化和自动释放功能;
上述实施例提供的一种数据传输的方法和系统,通过创建用于上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;所述上位机的应用程序通过所述第一虚拟串口、第二虚拟串口,从所述网口与所述终端之间进行数据传输,从而实现上位机的基于串口的应用程序通过网口与终端进行数据交互。
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序来指令相关硬件完成,所述程序可以存储于计算机可读存储介质中,如只读存储器、磁盘或光盘等。可选地,上述实施例的全部或部分步骤也可以使用 一个或多个集成电路来实现,相应地,上述实施例中的各模块/单元可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。本发明不限制于任何特定形式的硬件和软件的结合。
需要说明的是,本发明还可有其他多种实施例,在不背离本发明精神及其实质的情况下,熟悉本领域的技术人员可根据本发明作出各种相应的改变和变形,但这些相应的改变和变形都应属于本发明所附的权利要求的保护范围。
工业实用性
本发明实施例通过创建用于上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;所述上位机的应用程序通过所述第一虚拟串口、第二虚拟串口,从所述网口与所述终端之间进行数据传输,从而实现上位机的基于串口的应用程序通过网口与终端进行数据交互。

Claims (12)

  1. 一种数据传输的方法,应用于上位机,所述上位机通过网口与终端建立网络连接,该方法包括:
    创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;
    所述上位机的应用程序通过所述第一虚拟串口以及第二虚拟串口,在所述网口与所述终端之间进行数据传输。
  2. 如权利要求1所述的方法,其中,所述上位机的应用程序通过所述第一虚拟串口以及第二虚拟串口,从所述网口与所述终端之间进行数据传输,包括:
    通过所述上位机的应用程序将第一数据写入所述第一虚拟串口中;
    通过所述第一虚拟串口将所述第一数据传输到所述第二虚拟串口中;
    从所述第二虚拟串口中读取所述第一数据,进行数据转换后发送到所述网口;
    通过所述网口将经过数据转换的第一数据发送给所述终端。
  3. 如权利要求2所述的方法,其中,所述通过所述网口将经过数据转换的第一数据发送给所述终端之后,还包括:
    从所述网口中读取所述终端接收到所述经过数据转换的第一数据后发送的第二数据,进行数据转换后发送到所述第二虚拟串口中;
    通过所述第二虚拟串口将经过数据转换的第二数据传输到所述第一虚拟串口中;
    通过所述上位机的应用程序从所述第一虚拟串口中读取所述经过数据转换的第二数据。
  4. 如权利要求1-3中任一项所述的方法,其中,
    所述创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口- 串口转换读写的第二虚拟串口,包括:
    安装虚拟串口驱动程序,安装成功后虚拟出一对相互连接的虚拟串口,其中第一虚拟串口用于上位机的应用程序读写,第二虚拟串口用于网口-串口转换读写;
    所述第一虚拟串口和第二虚拟串口之间通过虚拟驱动传输数据,包括:所述第一虚拟串口将输入的数据传输给所述第二虚拟串口,作为所述第二虚拟串口的输出;所述第二虚拟串口将输入的数据传输给所述第一虚拟串口,作为所述第一虚拟串口的输出。
  5. 如权利要求4所述的方法,其中,所述创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口,还包括:
    根据所述网口的速率配置第一虚拟串口和第二虚拟串口的波特率,且第一虚拟串口的波特率与第二虚拟串口的波特率相等。
  6. 一种数据传输的系统,应用于上位机,所述上位机通过网口与终端建立网络连接,所述系统包括:
    通信连接建立模块,其设置为:创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口;以及
    网口-串口传输模块,其设置为:令所述上位机的应用程序通过所述第一虚拟串口以及第二虚拟串口,在所述网口与所述终端之间进行数据传输。
  7. 如权利要求6所述的系统,其中,所述网口-串口传输模块包括:
    应用程序模块,其设置为:通过所述上位机的应用程序将第一数据写入所述第一虚拟串口中;
    虚拟串口通信模块,其设置为:通过所述第一虚拟串口将所述第一数据传输到所述第二虚拟串口中;以及
    网口-串口转换模块,其设置为:从所述第二虚拟串口中读取所述第一数据,进行数据转换后发送到所述网口;通过所述网口将经过数据转换的第一数据发送给所述终端。
  8. 如权利要求7所述的系统,其中;
    网口-串口转换模块,还设置为:从所述网口中读取所述终端接收到所述经过数据转换的第一数据后发送的第二数据,进行数据转换后发送到所述第二虚拟串口中;
    虚拟串口通信模块,还设置为:通过所述第二虚拟串口将经过数据转换的第二数据传输到所述第一虚拟串口中;
    串口应用程序模块,还设置为:通过所述上位机的应用程序从所述第一虚拟串口中读取所述经过数据转换的第二数据。
  9. 如权利要求6-8中任一项所述的系统,其中,
    通信连接建立模块,是设置为以如下方式创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口:
    安装虚拟串口驱动程序,安装成功后虚拟出一对相互连接的虚拟串口,其中第一虚拟串口用于上位机的应用程序读写,第二虚拟串口用于网口-串口转换读写;
    所述第一虚拟串口和第二虚拟串口之间通过虚拟驱动传输数据,包括:所述第一虚拟串口将输入的数据传输给所述第二虚拟串口,作为所述第二虚拟串口的输出;所述第二虚拟串口将输入的数据传输给所述第一虚拟串口,作为所述第一虚拟串口的输出。
  10. 如权利要求9所述的系统,其中:
    通信连接建立模块,还设置为:在创建用于所述上位机的应用程序读写的第一虚拟串口和用于网口-串口转换读写的第二虚拟串口时,根据所述网口的速率配置第一虚拟串口和第二虚拟串口的波特率,且第一虚拟串口的波特率与第二虚拟串口的波特率相等。
  11. 一种计算机程序,包括程序指令,当该程序指令被计算机执行时,使得该计算机可执行权利要求1-5任一项所述的方法。
  12. 一种载有权利要求11所述计算机程序的计算机可读存储介质。
PCT/CN2014/091392 2014-09-24 2014-11-18 一种数据传输的方法和系统 WO2015131553A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410495768.0A CN105512063A (zh) 2014-09-24 2014-09-24 一种数据传输的方法和系统
CN201410495768.0 2014-09-24

Publications (1)

Publication Number Publication Date
WO2015131553A1 true WO2015131553A1 (zh) 2015-09-11

Family

ID=54054436

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/091392 WO2015131553A1 (zh) 2014-09-24 2014-11-18 一种数据传输的方法和系统

Country Status (2)

Country Link
CN (1) CN105512063A (zh)
WO (1) WO2015131553A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111124969A (zh) * 2019-12-26 2020-05-08 山西银河电子设备厂 一种基于fpga的改进型串口转换模块
CN111404739A (zh) * 2020-03-11 2020-07-10 山东超越数控电子股份有限公司 一种串口网络化属性配置的系统
CN115102941A (zh) * 2022-07-26 2022-09-23 苏州浪潮智能科技有限公司 一种基于web的服务器远程调试方法、系统、装置及介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018165900A1 (zh) * 2017-03-15 2018-09-20 深圳中兴力维技术有限公司 通信控制方法与控制装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080181236A1 (en) * 2004-05-28 2008-07-31 International Business Machines Corporation Virtual usb communications port
CN101800652A (zh) * 2010-02-04 2010-08-11 深圳市金宏威实业发展有限公司 串口与以太网方式转换的方法、系统及工业以太网交换机
CN102571689A (zh) * 2010-12-10 2012-07-11 中兴通讯股份有限公司 一种数据传输方法及装置
CN103095703A (zh) * 2013-01-11 2013-05-08 瑞斯康达科技发展股份有限公司 一种实现网络与串口数据交互的方法、设备及系统

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8150973B2 (en) * 2004-12-30 2012-04-03 Intel Corporation Virtual serial port and protocol for use in serial-over-LAN communication

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080181236A1 (en) * 2004-05-28 2008-07-31 International Business Machines Corporation Virtual usb communications port
CN101800652A (zh) * 2010-02-04 2010-08-11 深圳市金宏威实业发展有限公司 串口与以太网方式转换的方法、系统及工业以太网交换机
CN102571689A (zh) * 2010-12-10 2012-07-11 中兴通讯股份有限公司 一种数据传输方法及装置
CN103095703A (zh) * 2013-01-11 2013-05-08 瑞斯康达科技发展股份有限公司 一种实现网络与串口数据交互的方法、设备及系统

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111124969A (zh) * 2019-12-26 2020-05-08 山西银河电子设备厂 一种基于fpga的改进型串口转换模块
CN111124969B (zh) * 2019-12-26 2023-08-04 山西银河电子设备厂 一种基于fpga的改进型串口转换模块
CN111404739A (zh) * 2020-03-11 2020-07-10 山东超越数控电子股份有限公司 一种串口网络化属性配置的系统
CN115102941A (zh) * 2022-07-26 2022-09-23 苏州浪潮智能科技有限公司 一种基于web的服务器远程调试方法、系统、装置及介质
CN115102941B (zh) * 2022-07-26 2023-07-18 苏州浪潮智能科技有限公司 一种基于web的服务器远程调试方法、系统、装置及介质

Also Published As

Publication number Publication date
CN105512063A (zh) 2016-04-20

Similar Documents

Publication Publication Date Title
US9619417B2 (en) Method and apparatus for remote delivery of managed USB services via a mobile computing device
WO2017113879A1 (zh) 智能接口卡的控制方法及装置
US10885174B2 (en) IOT-enabled device and a method for manufacturing an IoT device
WO2019127476A1 (zh) 虚拟系统蓝牙通信方法及装置、虚拟系统、存储介质及电子设备
WO2015131553A1 (zh) 一种数据传输的方法和系统
US20090204725A1 (en) Wimax communication through wi-fi emulation
US20170347224A1 (en) Iot-enabled device and a method for providing internet connectivity to a device
WO2011116556A1 (zh) 基于物联网的无线通信终端及其应用方法
US20180095918A1 (en) Universal serial bus emulation layer
EP3758326B1 (en) Secure updating of computing system firmware
CN105763638A (zh) 一种云终端反向控制系统
US10796002B1 (en) Method and apparatus for establishing a root-of-trust path for a secure computer
WO2014000299A1 (zh) 串口重定向处理方法、设备和系统
US8825931B2 (en) KVM switch system capable of wirelessly transmitting keyboard-mouse-data between wired input/output devices based on a security clearance level
CN111858433A (zh) 一种基于ssh串口重定向的方法、系统、设备及介质
US9787805B2 (en) Communication control system and communication control method
CN110115012B (zh) 一种秘密信息的分发方法和设备
CN105872096B (zh) 一种外部设备的远端共享系统
Hari et al. The swiss army smartphone: Cloud-based delivery of usb services
WO2015067052A1 (zh) 测试命令发送方法、装置及系统
CN204883266U (zh) 现场设备的监控装置
TW202009694A (zh) 遠端登錄伺服器子系統方法與遠端登錄系統
CN111723042B (zh) 远程高速usb透传方法、装置及设备
Camredon USBiquitous: USB intrusion toolkit
TWI840288B (zh) 設備接入方法及其裝置、資料交換方法及其裝置、聯網設備、服務端及存儲介質

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14884400

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14884400

Country of ref document: EP

Kind code of ref document: A1