WO2018232899A1 - 通过串口传输数据的方法、客户端装置及数据转发装置 - Google Patents

通过串口传输数据的方法、客户端装置及数据转发装置 Download PDF

Info

Publication number
WO2018232899A1
WO2018232899A1 PCT/CN2017/097097 CN2017097097W WO2018232899A1 WO 2018232899 A1 WO2018232899 A1 WO 2018232899A1 CN 2017097097 W CN2017097097 W CN 2017097097W WO 2018232899 A1 WO2018232899 A1 WO 2018232899A1
Authority
WO
WIPO (PCT)
Prior art keywords
serial port
data
data frame
module
client device
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2017/097097
Other languages
English (en)
French (fr)
Inventor
史国梁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Goertek Inc
Original Assignee
Goertek Inc
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 Goertek Inc filed Critical Goertek Inc
Priority to US15/743,533 priority Critical patent/US10346344B2/en
Publication of WO2018232899A1 publication Critical patent/WO2018232899A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40052High-speed IEEE 1394 serial bus
    • H04L12/40071Packet processing; Packet format
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4633Interconnection of networks using encapsulation techniques, e.g. tunneling
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C

Definitions

  • the present invention relates to the field of data transmission, and more particularly, to a method for transmitting data through a serial port, a client device for transmitting data through a serial port, and a data forwarding device for transmitting data through a serial port.
  • the serial interface is referred to as the serial port (usually referred to as the COM interface), which refers to the sequential transmission of data one bit at a time.
  • the characteristic is that the communication line is simple, and only one pair of transmission lines can realize two-way communication, thereby greatly reducing the cost.
  • An application running on the client device can transmit data to and from an external device through the serial port of the client device. Since the client device usually only has one physical serial port, and one physical serial port can only connect one external device in principle, this limits the number of external devices that can interact with the application through the client device. It is very necessary to provide a physical device. A solution that can transfer data to and from multiple external devices through a physical serial port.
  • a method of transmitting data through a serial port comprising:
  • the client device provides at least two virtual logical serial ports mapped to one physical serial port; wherein the physical serial port is a physical serial port on the client device for connecting an external device;
  • the data forwarding device provides a main serial port connected to the physical serial port and an extended serial port corresponding to the logical serial ports;
  • the client device responds with a write operation of sending the first data through the designated logical serial port, and encapsulates the first data and the designated logical serial port according to a preset serial port protocol to obtain a first data frame.
  • the client device sends the first data frame to the data forwarding device via the physical serial port;
  • the data forwarding device receives the first data frame through the main serial port, and unpacks the first data frame according to a serial port protocol, to obtain the first data and the designated logical serial port;
  • the data forwarding device sends the first data to an extended serial port corresponding to the designated logical serial port.
  • a client device for transmitting data through a serial port comprising:
  • a virtual mapping module configured to provide at least two virtual logical serial ports mapped to the physical serial port
  • the first encapsulating module is configured to: in response to the writing operation of sending the first data through the designated logical serial port, encapsulating the first data and the designated logical serial port according to the set serial protocol to obtain the first data frame;
  • the first sending module is configured to send the first data frame to the data forwarding device via the physical serial port, so that the data forwarding device unpacks the first data from the first data frame according to the serial protocol, and sends the first data to the corresponding data.
  • the extended serial port of the logical serial port is configured to send the first data frame to the data forwarding device via the physical serial port, so that the data forwarding device unpacks the first data from the first data frame according to the serial protocol, and sends the first data to the corresponding data.
  • a data forwarding device for transmitting data through a serial port including:
  • main serial port which is set to be a physical serial port for connecting to the client device
  • At least two extended serial ports are configured to be connected to external devices
  • the second receiving module is configured to receive a first data frame that is transmitted by the client device through the main serial port, where the first data frame is encapsulated with the first data and a virtual logical serial port corresponding to an extended serial port;
  • the second unpacking module is configured to unpack the first data frame according to the serial port protocol, to obtain the first data and the logic serial port;
  • the forwarding module is configured to send the first data to the extended serial port corresponding to the logical serial port.
  • the client device provides a plurality of virtual logical serial ports mapped to the physical serial port of the client device to the application installed thereon, and the client device connects to the main serial port of the data forwarding device through the physical serial port.
  • the logical serial ports are in one-to-one correspondence with the extended serial ports provided by the data forwarding device, so that the application on the client device can directly perform the reading and writing operations on any logical serial port to directly connect with the external device connected to the corresponding extended serial port.
  • Communication the purpose of communicating with multiple external devices through a physical serial port.
  • 1 is a hardware composition of a method for transmitting data through a serial port according to an embodiment of the present invention
  • FIG. 2 is a schematic flow chart of a method for transmitting data through a serial port according to an embodiment of a write operation of the present invention
  • FIG. 3 is a schematic flow chart of a method for transmitting data through a serial port according to an embodiment of the read operation of the present invention
  • FIG. 4 is a schematic block diagram showing the hardware structure of a client device according to an embodiment of the present invention.
  • FIG. 5 is a schematic block diagram showing the hardware structure of a data forwarding device according to an embodiment of the present invention.
  • FIG. 6 is a schematic block diagram of a client device in accordance with an embodiment of a write operation of the present invention.
  • FIG. 7 is a schematic block diagram of a client device in accordance with an embodiment of the read operation of the present invention.
  • FIG. 8 is a schematic block diagram of a data forwarding device according to an embodiment of the write operation of the present invention.
  • FIG. 9 is a schematic block diagram of a data forwarding device in accordance with an embodiment of the read operation of the present invention.
  • 1 is a hardware structural composition of a method for transmitting data through a serial port according to an embodiment of the present invention.
  • a hardware component of a method for transmitting data through a serial port includes a client device 100, a data forwarding device 200, and external devices 311 to 31n, where n is an integer greater than or equal to 2. .
  • the client device 100 provides a physical serial port 110, which is a physical serial port on the client device 110 for connecting to an external device.
  • the client device 100 also provides at least two virtual logical serial ports COM11-COM1n mapped to the physical serial port 110.
  • the data forwarding device 200 provides a main serial port 210 connected to the physical serial port 110.
  • the data forwarding device 200 also provides extended serial ports COM21 to COM2n that are in one-to-one correspondence with the logical serial ports COM11 to COM1n.
  • the above physical serial port 110 is, for example, RS232, RS485, or the like.
  • the above extended serial ports COM21 ⁇ COM2n, the main serial port 210, and the physical serial port 110 are the same type of serial port.
  • Each of the extended serial ports COM21 to COM2n can be connected to an external device.
  • the extended serial port COM21 is connected to the first external device 311, and the extended serial port COM2n is connected to the nth external device 31n.
  • the client device 100 provides the encapsulated logical serial port COM11 ⁇ COM1n to the application program (hereinafter referred to as the client application) installed thereon, so that the client application can read and write the logical serial port to the same physical serial port.
  • the method for transmitting data through the serial port in the embodiment of the present invention can be directly used without modifying the task, thereby ensuring the portability of the client application.
  • the data forwarding device 200 performs mapping of the logical serial ports COM11 ⁇ COM1n to the corresponding extended serial ports COM21 ⁇ COM2n, and further maps the operation of the logical serial port COM11 ⁇ COM1n by the client application to the operation of the corresponding extended serial port COM21 ⁇ COM2n to implement the client application. Communication with different external devices.
  • a client application can communicate with one external device or with multiple external devices; different client applications can communicate with the same external device, or can each have different external devices. Communicate.
  • the external devices 311 to 31n are devices that can communicate through a serial port, such as an air conditioner, a projector, and the like.
  • the client device 100 can also provide an additional physical serial port.
  • the additional physical serial port can also be mapped to the other at least two virtual logical serial ports, just like the physical serial port 110.
  • FIG. 2 is a schematic flow chart of a method for transmitting data through a serial port according to an embodiment of the present invention, wherein the solid line in the figure indicates the internal processing flow of the client device 100 and the data forwarding device 200, and the dotted line indicates the client device 100. The flow of interaction with the data forwarding device 200.
  • the method for transmitting data through a serial port in the write operation embodiment of the present invention includes the following steps:
  • the client device 100 provides at least two virtual logical serial ports (such as the logical serial ports COM11-COM1n in FIG. 1) mapped to a physical serial port (such as the physical serial port 110 in FIG. 1), wherein the physical serial port is a client.
  • the client device 100 provides a logical serial port file corresponding to the logical serial port for the client application to operate the corresponding logical serial port through the logical serial port file, for example, opening a logical serial port, configuring a logical serial port, writing to a logical serial port, and logic
  • the serial port performs read operations, closes the logical serial port, and so on.
  • the operation of the logical serial port by the client application through the logical serial port file will cause an operating system level call, thereby implementing communication between the client application and the external device.
  • step S2210 the data forwarding device 200 provides a main serial port (such as the main serial port 210 in FIG. 1) connected to the physical serial port and an extended serial port corresponding to the logical serial port (such as the extended serial ports COM21 to COM2n in FIG. 1).
  • a main serial port such as the main serial port 210 in FIG. 1
  • an extended serial port corresponding to the logical serial port such as the extended serial ports COM21 to COM2n in FIG. 1).
  • the data forwarding device 200 connects to an external device through an extended serial port, wherein the extended serial port can be connected to an external device.
  • step S2120 the client device 100 responds with a write operation of sending the first data through the designated logical serial port, and encapsulates the first data and the designated logical serial port according to a preset serial port protocol to obtain a first data frame.
  • This write is triggered by the client application.
  • the client application can perform a write operation through a logical serial port file of a specified logical serial port.
  • the writing operation may include information such as the first data, the length of the first data, and the like.
  • the client application can open the corresponding logical serial port to clear the specified logical serial port before performing the write operation.
  • the logical serial port specified by the client application can be user settings or default settings.
  • step S2130 the client device 100 sends the first data frame to the data forwarding device 200 via the physical serial port 110.
  • step S2220 the data forwarding device 200 receives the first data frame through the main serial port 210, and unpacks the first data frame according to the serial port protocol to obtain the first data and the designated logical serial port.
  • the data forwarding device 200 and the client device 100 perform operations such as encapsulation and unpacking based on the same serial port protocol to ensure the identifiability of both parties and ensure normal communication.
  • step S2230 the data forwarding device 200 sends the first data obtained by the unpacking to the extended serial port corresponding to the designated logical serial port.
  • the data forwarding device 200 performs a mapping operation between the logical serial port and the extended serial port in step S2230.
  • the data forwarding device 200 can save a mapping table reflecting the mapping relationship between the logical serial port and the extended serial port.
  • the client device 100 can provide a plurality of virtual logical serial ports mapped to the physical serial port 110 to the client application, and the client device 100 passes through the physical serial port 110 and the data forwarding device 200.
  • the main serial port 210 is connected, and the data forwarding device 200 realizes the forwarding of data to the corresponding extended serial port through the mapping relationship between the logical serial port and the extended serial port.
  • the client application can communicate with the external device connected to the corresponding extended serial port by directly writing to the specified logical serial port, such as operating the physical serial port, thereby implementing the client application through a physical serial port 110 and multiple external devices.
  • the device communicates for the purpose, and the client application is portable without any modifications.
  • FIG. 3 is a schematic flow chart of a method for transmitting data through a serial port according to an embodiment of the read operation of the present invention.
  • the solid line in the figure indicates the internal processing flow of the client device 100 and the data forwarding device 200, and the dotted line indicates the client device 100. The flow of interaction with the data forwarding device 200.
  • the method for transmitting data through the serial port in the read operation embodiment of the present invention can be Including the following steps:
  • step S3210 the data forwarding device 200 receives the second data from an extended serial port.
  • the extended serial port is the first extended serial port 311 in FIG.
  • step S3220 the data forwarding device 200 determines the logical serial port corresponding to the extended serial port as the target logical serial port.
  • the target logical serial port is a logical serial port COM1 mapped to the first extended serial port 311.
  • step S3230 the data forwarding device 200 encapsulates the second data and the target logical serial port according to the serial port protocol to obtain a second data frame.
  • step S3240 the data forwarding device 200 transmits the second data frame to the client device 100 through the main serial port 210.
  • step S3110 the client device 100 receives the second data frame through the physical serial port 110, and unpacks the second data frame according to the serial port protocol to obtain the second data and the target logical serial port.
  • step S3120 the client device 100 writes the second data into the buffer corresponding to the target logical serial port.
  • step S3120 when the client application performs a read operation on the target logical serial port (for example, directly calling the read function of the operation serial port), the operating system level read interface function is called, and the read interface function checks the buffer of the target logical serial port. Whether there is data in the device, if there is data, the data is returned to the client application, otherwise, depending on whether the operating system is blocked or not, it is decided whether to wait for data here.
  • a read operation on the target logical serial port for example, directly calling the read function of the operation serial port
  • the client application can read data from a plurality of external devices through a physical serial port 110, wherein data from the external device is mapped to the corresponding data by the processing of the data forwarding device 200.
  • the logical serial port in this way, the client application can obtain the data transmitted by the external device connected to the corresponding extended serial port by directly reading the logical serial port as the physical serial port is operated, thereby implementing the client application through a physical serial port 110 and multiple The purpose of communication by the external device, and the client application is portable without any modification.
  • the method of the present invention may further include:
  • step S4110 the client device 100 sets a check value when the first data frame is obtained by encapsulation.
  • the check value may be calculated according to a preset check algorithm, such as a CRC8 algorithm.
  • the check value is located in a field defined by the serial protocol in the first data frame, for example, at the end of the first data frame, occupying 1 byte.
  • the check value is calculated, for example, by setting a setting field in the first data frame according to a preset check algorithm.
  • the setting field includes at least the first data, and may further include a designated logical serial port or the like.
  • step S4210 the data forwarding device 200 verifies the correctness of the first data frame according to the obtained check value after unpacking.
  • the data forwarding device 200 first obtains the check value set by the client device 100 for the first data frame by unpacking.
  • the data forwarding device 200 calculates a new check value for the received first data frame according to the same check algorithm in which the client device 100 sets the check value.
  • the new check value calculated by the data forwarding device 200 is the same as the check value obtained by the unpacking, the content of the first data frame is correct, and the first data frame is verified to pass; if the data forwarding device 200 calculates the new one.
  • the check value is different from the check value obtained by unpacking, indicating that the content of the first data frame is incorrect, and the first data frame is not passed.
  • Step S4220 After verifying that the first data frame passes, the data forwarding device 200 sends the first data obtained by the unpacking to the extended serial port corresponding to the designated logical serial port.
  • the method of the present invention may further include:
  • step S5210 the data forwarding device 200 sets a check value when the second data frame is obtained by encapsulation.
  • Step S5110 after the unpacking, the client device 100 verifies the correctness of the second data frame according to the check value obtained by the unpacking.
  • Step S5120 After verifying that the second data frame passes, the client device 100 writes the second data into the buffer corresponding to the target logical serial port.
  • the accuracy of data transmission between the client application and the external device can be improved by adding the above verification link.
  • the method of the embodiment of the present invention may further include:
  • Step S6110 the client device 100 determines to send the first data transmission serial number through the designated logical serial port in response to the write operation of transmitting the first data through the designated logical serial port, and encapsulates the transmission serial number according to the serial port protocol. In a data frame.
  • the client device 100 can respectively perform the sequential numbering of the data frames sent through each logical serial port according to the serial port protocol.
  • the client device 100 can also serially number the data frames sent through each logical serial port according to the serial port protocol.
  • the logical serial port specified in the step S6110 is the logical serial port COM1 in FIG. 1, and if the first data is sent through the first sending operation of the logical serial port COM1, the transmission sequence is sent. The number is 0X01. If the first data is sent through the second transmission operation of the logical serial port COM1, the serial number is sent as 0X02, and so on.
  • the method of the embodiment of the present invention may further include:
  • Step S7210 After determining the target logical serial port, the data forwarding device 200 may determine to send the sending sequence number of the second data to the target logical serial port, and further encapsulate the sending serial number in the second data frame according to the serial port protocol.
  • Step S6210 After unpacking the first data frame according to the serial port protocol, the data forwarding device 200 returns an acknowledgement response for the first data frame to the client device 100, where the acknowledgement response includes the sending sequence number or corresponding Send the confirmation number of the serial number.
  • the correspondence between the serial number and the confirmation number can be agreed between the data forwarding device 200 and the client device 100.
  • the sending sequence number includes a character indicating a designated logical serial port, a character indicating a sending operation, and a serial number
  • the corresponding confirmation number includes a character indicating a specified logical serial port and a sequence number thereof, but Replace the character indicating the send operation with the character indicating the acknowledgement.
  • Step S6120 After the first data frame is sent to the data forwarding device 200 via the physical serial port, the client device 100 detects whether the data forwarding is received within the set time according to the sending sequence number or the confirmation number corresponding to the sending sequence number. The acknowledgment response returned by the device 200, if received, the next data frame is transmitted, and if not received, the first data frame is resent via the physical serial port according to the detection result that the acknowledgment response is not received. Up to the data forwarding device 200 until the acknowledgment response returned by the data forwarding device 200 is received.
  • the method of the embodiment of the present invention may further include:
  • Step S7110 After unpacking the second data frame according to the serial port protocol, the client device 100 returns an acknowledgement response for the second data frame to the data forwarding device 200, where the acknowledgement response includes decoding from the second data frame.
  • Step S7220 after the second data frame is sent to the client device 100 via the main serial port, the data forwarding device 200 detects whether the data frame number is sent to the target logical serial port or the confirmation number corresponding to the serial number is sent. Receiving an acknowledgment response returned by the client device 100 within the set time, if received, transmitting the next data frame, and if not, transmitting the second data according to the detection result of not receiving the acknowledgment response Data frame is sent via the main serial port It is sent to the client device 100 until an acknowledgment response returned by the client device 100 is received.
  • the above embodiment of setting the acknowledgement response may be combined with the above embodiment for setting the data frame check, so that the data forwarding device 200 may further return to the client device 100 for the first after verifying that the first data frame passes.
  • the data frame is acknowledged.
  • the client device 100 may further return an acknowledgement response for the second data frame to the data forwarding device 200 after verifying that the second data frame has passed.
  • the client device 100 and the data transmission device 200 can transmit data by using the default baud rate agreed upon by the transmitting and receiving parties, so that the client application can directly write after opening the logical serial port file. operating.
  • the client device 100 may also notify the data transmission device 200 to configure the baud rate of forwarding data to the corresponding extended serial port by using a configuration command.
  • the method of the embodiment of the present invention may further include the following steps:
  • the client device 100 is in response to a write operation that sends the first data through the designated logical serial port:
  • step S8110 the client device 100 responds to the operation of the specified logical serial port, and encapsulates the configuration content and the designated logical serial port according to the serial port protocol to obtain a configuration command.
  • step S8120 the client device 100 sends the configuration command to the data forwarding device 200 via the physical serial port.
  • step S8210 the data forwarding device 200 receives the configuration command through the main serial port, and unpacks the configuration command according to the serial port protocol to obtain the configuration content and the designated logical serial port.
  • step S8220 the data forwarding device 200 configures the extended serial port corresponding to the designated logical serial port according to the configuration content.
  • This configuration includes the configuration of the baud rate for forwarding data to the extended serial port corresponding to the specified logical serial port.
  • the client application can freely select the baud rate for data transmission as needed.
  • the frame format for transmitting data/instructions between the client device 100 and the data forwarding device 200 is as shown in Table 1 below:
  • the frame format in this example may include a data header, a type identifier of the transmission content (including data, an instruction, an acknowledgement response, etc.), a logical serial port ID, a transmission sequence number, a length, a transmission content, and a check value, wherein The length is the sum of the number of bytes of the transmitted content and the check value.
  • the data header occupies 2 BYTE (bytes)
  • the type of transmission content occupies 1 BYTE
  • the logical serial port ID occupies 1 BYTE
  • the transmission sequence number occupies 1 BYTE
  • the length occupies 1 BYTE
  • the check value occupies 1 BYTE.
  • the client application sends data 0x01 to the external device 311 through the logical serial port COM11 of the client device 100, and the frame format of 0x02 is as shown in Table 2 below:
  • the client application configures the frame format of the extended serial port COM21 through the logical serial port COM11 of the client device 100 as shown in Table 3 below:
  • Table 4 The transmission contents in Table 3 are as shown in Table 4 below: Table 4:
  • the transmission content shown in Table 4 is the baud rate 115200 of the extended serial port COM21, and the serial port attribute is 8N1, where "8" represents 8 data bits, “N” means no parity, and “1" means there is one stop. Bit.
  • the acknowledgement response of the data frame transmitted by the data forwarding device 200 for the logical serial port COM11 with the transmission sequence number 0x01 is as shown in Table 5 below:
  • FIG. 4 is a functional block diagram of a hardware structure of a client device 100 in accordance with an embodiment of the present invention.
  • the client device 100 of this embodiment includes the physical serial port 110, the processor 120, and the memory 130 of FIG.
  • the memory 130 is for storing instructions for controlling the processor 120 to operate to perform a method of transmitting data over a serial port in accordance with the present invention.
  • the memory 130 can include high speed random access memory and can also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • the processor 120 can be a central processing unit CPU, a microcontroller MCU, or the like.
  • the physical serial port 110 is, for example, RS232, RS485, or the like.
  • the client device 100 may further include a display device, an input device, and the like.
  • the display device is, for example, a display screen, a touch screen or the like.
  • the input device includes, for example, a keyboard, a mouse, a touch screen, and the like.
  • FIG. 5 is a schematic block diagram of a hardware configuration of a data forwarding device 200 according to an embodiment of the present invention.
  • the client device 100 of this embodiment includes a main serial port 210, a processor 220, a memory 230, and extended serial ports COM21 to COM2n in FIG. 1, wherein n is an integer greater than or equal to 2.
  • the memory 230 is for storing instructions for controlling the processor 220 to operate to perform a method of transmitting data over a serial port in accordance with the present invention.
  • the memory 230 can include high speed random access memory and can also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • the processor 220 can be a microcontroller MCU or the like.
  • the main serial port 210 and the extended serial ports COM21 to COM2n are, for example, RS232 and RS485.
  • FIG. 6 is a schematic block diagram of a client device 100 for transmitting data through a serial port in accordance with an embodiment of the write operation of the present invention.
  • the client device 100 of this embodiment of the present invention includes a physical serial port 110, a virtual mapping module 121, a first encapsulating module 122, and a first sending module 123.
  • the virtual mapping module 121 is configured to provide at least two virtual logical serial ports that are mapped to the physical serial port 110.
  • the first encapsulating module 122 is configured to respond to a write operation of sending the first data through the designated logical serial port, and package the first data and the designated logical serial port according to the set serial protocol to obtain the first data frame.
  • the first sending module 123 is configured to send the first data frame to the data forwarding device 200 via the physical serial port 110, so that the data forwarding device 200 unpacks the first data from the first data frame according to the serial protocol to send the corresponding data.
  • the extended serial port of the specified logical serial port is configured to send the first data frame to the data forwarding device 200 via the physical serial port 110, so that the data forwarding device 200 unpacks the first data from the first data frame according to the serial protocol to send the corresponding data.
  • FIG. 7 is a schematic block diagram of a client device for transmitting data through a serial port in accordance with an embodiment of the read operation of the present invention.
  • the client device 100 of this embodiment of the present invention may further include a first receiving module 124, a first unpacking module 125, and a queuing module 126.
  • the first receiving module 124 is configured to receive the second data frame transmitted by the data forwarding device 200 through the physical serial port 110, wherein the second data frame is encapsulated with the second data and the target logical serial port corresponding to the extended serial port providing the second data. .
  • the first unpacking module 125 is configured to unpack the second data frame to obtain a target logical serial port corresponding to the second data and the second data.
  • the queuing module 126 is configured to write the second data into a buffer of the target logical serial port corresponding to the second data.
  • the client device 100 for transmitting data through the serial port according to the write operation embodiment of the present invention may further include a first check value setting module (not shown).
  • the first check value setting module is configured to set a check value when the first encapsulation module 122 encapsulates the first data frame, so that after the data forwarding device 200 verifies that the first data frame passes according to the check value, The first data that is unpacked is sent to the extended serial port corresponding to the specified logical serial port.
  • the client device 100 for transmitting data through the serial port according to the read operation embodiment of the present invention may further include a first verification module (not shown).
  • the first check module is configured to obtain a check value set by the data forwarding device 200 obtained by the first unpacking module 125 to unpack the second data frame, and check the obtained check value according to the acquired check value.
  • the correctness of the second data frame is if the second data frame is verified by the re-notification queuing module 126 to write the second data into the buffer of the target logical serial port corresponding to the second data.
  • the client device 100 for transmitting data through the serial port according to the read operation embodiment of the present invention may further include a first acknowledgement module (not shown).
  • the first acknowledgement module is configured to be after the first receiving module 124 receives the second data frame,
  • the acknowledgment response for the second data frame is returned to the data forwarding device 200 such that the data forwarding device 200 can resend the second data frame to the client device 100 when the acknowledgment response is not received within the set time.
  • the first acknowledgement module may further return an acknowledgement response for the second data frame to the data forwarding device 200 after the first check module verifies that the second data frame has passed.
  • the client device 100 for transmitting data through the serial port may further include a first serial number setting module (not shown).
  • the first sequence number setting module is configured to: when the first encapsulation module 122 responds to the write operation of sending the first data through the designated logical serial port, determine to send the transmission sequence number of the first data through the designated logical serial port, so that the first The encapsulation module 122 further encapsulates the transmission sequence number in the first data frame according to the serial port protocol.
  • the client device 100 for transmitting data through the serial port according to the write operation embodiment of the present invention may further include a first acknowledgement determination module (not shown).
  • the first acknowledgment determining module is configured to detect, according to the sending sequence number or the acknowledgment number corresponding to the sending sequence number, whether an acknowledgment response returned by the data forwarding device 200 for the first data frame is received within a set time, wherein The acknowledgment response includes the transmission sequence number or an acknowledgment number corresponding to the transmission sequence number; if yes, the first sending module 123 is notified to send the next data frame, and if not, the first data is re-transmitted by the first sending module 123.
  • the frame is transmitted to the data forwarding device 200 via the physical serial port 110.
  • the client device 100 for transmitting data through the serial port according to the write operation embodiment of the present invention may further include a configuration module (not shown).
  • the configuration module is configured to respond to the configuration of the designated logical serial port before the first encapsulation module 122 responds to the write operation of sending the first data through the designated logical serial port, to configure the configuration content and the specified logical serial port according to the serial port protocol. And instructing the first sending module 123 to send the configuration command to the data forwarding device 200 via the physical serial port 110, so that the data forwarding device 200 configures the extended serial port corresponding to the specified logical serial port according to the configuration content obtained by the unpacking.
  • FIG. 8 is a schematic block diagram of a data forwarding device for transmitting data through a serial port according to an embodiment of the write operation of the present invention.
  • the data forwarding device 200 of this embodiment includes a main serial port 210, at least two extended serial ports COM21 COMCOM2n (where n is an integer greater than or equal to 2), a second receiving module 221, and a second solution.
  • the main serial port 210 is configured to connect to the physical serial port 110 of the client device 100.
  • the at least two extended serial ports COM21 to COM2n are arranged to be connected to an external device.
  • the second receiving module 221 is configured to receive the first data frame transmitted by the client device 100 through the main serial port 210.
  • the first data frame is encapsulated with the first data and a virtual logical serial port corresponding to an extended serial port.
  • the second unpacking module 222 is configured to unpack the first data frame according to the serial port protocol to obtain the first data and the corresponding logical serial port.
  • the forwarding module 223 is configured to send the first data to the extended serial port corresponding to the logical serial port.
  • FIG. 9 is a schematic block diagram of a data forwarding device for transmitting data through a serial port according to an embodiment of the read operation of the present invention.
  • the data forwarding device 200 of this embodiment may further include a third receiving module 224, a mapping module 225, a second encapsulating module 226, and a second sending module 227.
  • the third receiving module 224 is configured to receive second data from the extended serial port.
  • the mapping module 225 is configured to determine a virtual logical serial port corresponding to the extended serial port that provides the second data as the target logical serial port.
  • the second encapsulating module 226 is configured to encapsulate the second data and the target logical serial port according to a serial port protocol to obtain a second data frame.
  • the second sending module 227 is configured to send the second data frame to the client device 100 through the main serial port, so that the client device 100 unpacks the second data and the target logical serial port from the second data frame, and The second data is written into the buffer of the target logical serial port.
  • the data forwarding device 200 for transmitting data through the serial port according to the write operation embodiment of the present invention may further include a second verification module (not shown).
  • the second check module is configured to obtain a check value set by the client device 100 obtained by the second unpacking module 222 to unpack the first data frame, and check the obtained check value according to the acquired check value. If the first data frame is verified, the first data frame is sent to the extended serial port corresponding to the logical serial port by the notification forwarding module 223.
  • the data forwarding device 200 for transmitting data through the serial port according to the read operation embodiment of the present invention may further include a second check value setting module (not shown).
  • the second check value setting module is configured to set a check value when the second encapsulation module 226 encapsulates the second data frame, so that the client device 100 checks the second data frame according to the check value, The second data is then written into the buffer of the target logical serial port.
  • the data forwarding device 200 for transmitting data through the serial port according to the write operation embodiment of the present invention may further include a second acknowledgement module (not shown).
  • the second acknowledgement module is configured to return an acknowledgement response for the first data frame to the client device 100 after the second receive module 221 receives the first data frame, such that the client device 100 When the acknowledgement response is not received within the set time, the first data frame can be resent to the data transfer device 200.
  • the second acknowledgement module further returns an acknowledgement response for the first data frame to the client device 100 after the second check module verifies that the first data frame has passed.
  • the data forwarding device 200 for transmitting data through the serial port may further include a second serial number setting module (not shown).
  • the second sequence number setting module is configured to determine to send a transmission sequence number of the second data to the target logical serial port, so that the second encapsulation module 226 further encapsulates the transmission sequence number in the second data frame according to the serial port protocol.
  • the data forwarding device 200 for transmitting data through the serial port may further include a second acknowledgement determining module (not shown).
  • the second acknowledgment determining module is configured to detect, according to the sending sequence number or the acknowledgment number corresponding to the sending sequence number, whether the acknowledgment response returned by the client device 100 for the second data frame is received within the set time, where The acknowledgement response includes a transmission sequence number set by the second sequence number setting module or a confirmation number corresponding to the transmission sequence number; if yes, the second sending module 227 is notified to send the next data frame, and if not, the second sending module 227 is notified.
  • the second data frame is again sent to the client device 100 via the main serial port 210.
  • the data forwarding device 200 for transmitting data through the serial port according to the write operation embodiment of the present invention may further include a configuration execution module (not shown).
  • the configuration execution module is configured to unpack the configuration content and the corresponding logical serial port from the configuration command sent by the client device 100 through the main serial port 210, and configure the extended serial port corresponding to the logical serial port according to the configuration content.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Information Transfer Systems (AREA)

Abstract

本发明公开了一种通过串口传输数据的方法、客户端装置及数据转发装置,该方法包括:客户端装置提供映射至一个物理串口的至少两个虚拟的逻辑串口;其中,物理串口为客户端装置上用于连接外部设备的物理串口;数据转发装置提供与物理串口连接的主串口及与逻辑串口一一对应的扩展串口;客户端装置响应通过指定的逻辑串口发送第一数据的写操作,按照预设的串口协议封装第一数据和指定的逻辑串口,得到第一数据帧;客户端装置将第一数据帧经由物理串口发送至数据转发装置;数据转发装置通过主串口接收第一数据帧,并按照串口协议对第一数据帧进行解包,得到第一数据及指定的逻辑串口;数据转发装置将第一数据发送至指定的逻辑串口对应的扩展串口。

Description

通过串口传输数据的方法、客户端装置及数据转发装置 技术领域
本发明涉及数据传输领域,更具体地,本发明涉及一种通过串口传输数据的方法、一种通过串口传输数据的客户端装置及一种通过串口传输数据的数据转发装置。
背景技术
串行接口简称串口(通常指COM接口),是指数据一位一位地顺序传送,其特点是通信线路简单,只要一对传输线就可以实现双向通信,从而大大降低了成本。
运行在客户端装置上的应用程序可以通过客户端装置的串口与外部设备进行数据传输。由于客户端装置通常仅具有一个物理串口,而一个物理串口原则上仅能连接一个外部设备,这就限制了能够通过客户端装置与应用程序进行交互的外部设备的数量,非常有必要提供一种能够通过一个物理串口与多个外部设备进行数据传输的方案。
发明内容
本发明实施例的一个目的是提供一种通过串口传输数据的新的技术方案。
根据本发明的第一方面,提供了一种通过串口传输数据的方法,其包括:
客户端装置提供映射至一个物理串口的至少两个虚拟的逻辑串口;其中,该物理串口为客户端装置上用于连接外部设备的物理串口;
数据转发装置提供与该物理串口连接的主串口及与这些逻辑串口一一对应的扩展串口;
该客户端装置响应通过指定的逻辑串口发送第一数据的写操作,按照预设的串口协议封装该第一数据和指定的逻辑串口,得到第一数据帧;
该客户端装置将该第一数据帧经由该物理串口发送至数据转发装置;
该数据转发装置通过该主串口接收该第一数据帧,并按照串口协议对该第一数据帧进行解包,得到该第一数据及指定的逻辑串口;
该数据转发装置将该第一数据发送至指定的逻辑串口对应的扩展串口。
根据本发明的第二方面,还提供了一种通过串口传输数据的客户端装置,其包括:
物理串口;
虚拟映射模块,被设置为提供被映射至该物理串口的至少两个虚拟的逻辑串口;
第一封装模块,被设置为响应通过指定的逻辑串口发送第一数据的写操作,按照设定的串口协议封装该第一数据和指定的逻辑串口,得到第一数据帧;以及,
第一发送模块,被设置为将该第一数据帧经由该物理串口发送至数据转发装置,以供数据转发装置按照串口协议从第一数据帧中解包出第一数据发送至对应该指定的逻辑串口的扩展串口。
根据本发明的第三方面,还提供了一种通过串口传输数据的数据转发装置,其包括:
一个主串口,被设置为用于连接客户端装置的物理串口;
至少两个扩展串口,被设置为用于连接外部设备;
第二接收模块,被设置为接收客户端装置通过主串口传输的第一数据帧,该第一数据帧封装有第一数据和对应一个扩展串口的虚拟的逻辑串口;
第二解包模块,被设置为根据串口协议对第一数据帧进行解包,得到第一数据及该逻辑串口;以及,
转发模块,被设置为将该第一数据发送至该逻辑串口对应的扩展串口。
本发明的一个有益效果在于,客户端装置向安装在其上的应用提供映射至客户端装置的物理串口的多个虚拟的逻辑串口,客户端装置通过该物理串口与数据转发装置的主串口连接,这些逻辑串口与数据转发装置提供的扩展串口一一对应,这样,客户端装置上的应用通过对任一逻辑串口进行读、写等操作便可直接与连接在对应扩展串口上的外部设备进行通信,实现通过一个物理串口与多个外部设备进行通信的目的。
附图说明
被结合在说明书中并构成说明书的一部分的附图示出了本发明的实施例,并且连同其说明一起用于解释本发明的原理。
图1为根据本发明实施例的通过串口传输数据的方法的硬件组成;
图2为根据本发明写操作实施例的通过串口传输数据的方法的流程示意图;
图3为根据本发明读操作实施例的通过串口传输数据的方法的流程示意图;
图4为根据本发明实施例的客户端装置的硬件结构的原理框图;
图5为根据本发明实施例的数据转发装置的硬件结构的原理框图。
图6为根据本发明写操作实施例的客户端装置的原理框图;
图7为根据本发明读操作实施例的客户端装置的原理框图;
图8为根据本发明写操作实施例的数据转发装置的原理框图;
图9为根据本发明读操作实施例的数据转发装置的原理框图。
具体实施方式
现在将参照附图来详细描述本发明的各种示例性实施例。应注意到:这些实施例仅仅是说明性的,决不作为对本发明及其应用或使用的任何限制。
<硬件组成>
图1为实施本发明实施例的通过串口传输数据的方法的硬件结构组成。
根据图1所示,实施本发明实施例的通过串口传输数据的方法的硬件结构组成包括客户端装置100、数据转发装置200、及外部设备311~31n,其中,n为大于或者等于2的整数。
客户端装置100提供一个物理串口110,该物理串口110为客户端装置110上用于连接外部设备的物理串口。
客户端装置100还提供映射至该物理串口110的至少两个虚拟的逻辑串口COM11~COM1n。
数据转发装置200提供一个主串口210与物理串口110连接。
数据转发装置200还提供与逻辑串口COM11~COM1n一一对应的扩展串口COM21~COM2n。
以上物理串口110例如是RS232、RS485等。
以上扩展串口COM21~COM2n、主串口210、及物理串口110为相同类型的串口。
每一扩展串口COM21~COM2n可以连接一个外部设备,例如,扩展串口COM21连接第一外部设备311,扩展串口COM2n连接第n外部设备31n。
客户端装置100向安装在其上的应用程序(以下简称为客户端应用)提供封装好的逻辑串口COM11~COM1n,使得客户端应用能够向使用物理串口一样对逻辑串口进行读、写等操作,而无需进行任务修改就可以直接使用本发明实施例的通过串口传输数据的方法,进而保证了客户端应用的可移植性。
数据转发装置200进行逻辑串口COM11~COM1n至对应扩展串口COM21~COM2n的映射,进而将客户端应用对逻辑串口COM11~COM1n的操作映射至对对应扩展串口COM21~COM2n的操作,以实现客户端应用与不同外部设备之间的通信。
在本实施例中,一个客户端应用可以与一个外部设备进行通信,也可以与多个外部设备进行通信;不同的客户端应用可以与相同的外部设备进行通信,也可以各自与不同的外部设备进行通信。
外部设备311~31n是可以通过串口进行通信的设备,例如空调、投影仪等等。
在另外的实施例中,客户端装置100还可以提供另外的物理串口,该另外的物理串口也可以与物理串口110一样,映射至另外的至少两个虚拟的逻辑串口。
<方法>
图2为根据本发明写操作实施例的通过串口传输数据的方法的流程示意图,其中,图中实线表示客户端装置100和数据转发装置200的内部处理流程,点划线表示客户端装置100与数据转发装置200之间的交互流程。
根据图2所示,本发明写操作实施例的通过串口传输数据的方法包括如下步骤:
步骤S2110,客户端装置100提供映射至一个物理串口(如图1中物理串口110)的至少两个虚拟的逻辑串口(如图1中逻辑串口COM11~COM1n),其中,该物理串口为客户端装置100上用于连接外部设备的物理串口。
客户端装置100提供与逻辑串口一一对应的逻辑串口文件,以供客户端应用通过逻辑串口文件操作对应的逻辑串口,例如,打开逻辑串口、配置逻辑串口、对逻辑串口进行写操作、对逻辑串口进行读操作、关闭逻辑串口等。
客户端应用通过逻辑串口文件对逻辑串口的操作会导致操作系统级别的调用,进而实现客户端应用与外部设备之间的通信。
步骤S2210,数据转发装置200提供与物理串口连接的主串口(如图1中的主串口210)及与逻辑串口一一对应的扩展串口(如图1中的扩展串口COM21~COM2n)。
数据转发装置200通过扩展串口连接外部设备,其中,扩展串口可以连接一个外部设备。
步骤S2120,客户端装置100响应通过指定的逻辑串口发送第一数据的写操作,按照预设的串口协议封装第一数据和指定的逻辑串口,得到第一数据帧。
该写操作由客户端应用触发。
该客户端应用可以通过指定的逻辑串口的逻辑串口文件执行写操作。
该写操作中可以包括第一数据、第一数据的长度等信息。
按照串口协议,该客户端应用在执行写操作之前,可以先打开对应的逻辑串口,以明确指定的逻辑串口。
客户端应用指定的逻辑串口可以是用户设置,也可以是默认设置。
步骤S2130,客户端装置100将第一数据帧经由物理串口110发送至数据转发装置200。
步骤S2220,数据转发装置200通过主串口210接收该第一数据帧,并按照串口协议对第一数据帧进行解包,得到第一数据及指定的逻辑串口。
数据转发装置200与客户端装置100基于相同的串口协议进行封装、解包等操作,以保证双方的可识别性,保证通信的正常进行。
步骤S2230,数据转发装置200将解包得到的第一数据发送至指定的逻辑串口对应的扩展串口。
数据转发装置200在该步骤S2230中执行逻辑串口与扩展串口之间的映射操作。
在该实施例中,数据转发装置200可以保存反映逻辑串口与扩展串口之间映射关系的映射表。
由此可见,根据本发明实施例的方法,客户端装置100可以向客户端应用提供映射至物理串口110的多个虚拟的逻辑串口,客户端装置100通过该物理串口110与数据转发装置200的主串口210连接,数据转发装置200通过逻辑串口与扩展串口之间的映射关系实现数据向对应扩展串口的转发。这样,客户端应用便可像操作物理串口一样,通过直接对指定的逻辑串口进行写等操作与连接在对应扩展串口上的外部设备进行通信,实现客户端应用通过一个物理串口110与多个外部设备进行通信的目的,而且,该客户端应用无需进行任何修改,具有可移植性。
图3为根据本发明读操作实施例的通过串口传输数据的方法的流程示意图,其中,图中实线表示客户端装置100和数据转发装置200的内部处理流程,点划线表示客户端装置100与数据转发装置200之间的交互流程。
根据图3所示,本发明读操作实施例的通过串口传输数据的方法可以 包括如下步骤:
步骤S3210,数据转发装置200接收来自一扩展串口的第二数据。
例如,该扩展串口为图1中的第一扩展串口311。
步骤S3220,数据转发装置200确定该扩展串口对应的逻辑串口作为目标逻辑串口。
在该扩展串口为第一扩展串口311的例子中,该目标逻辑串口为映射至第一扩展串口311的逻辑串口COM1。
步骤S3230,数据转发装置200按照串口协议封装第二数据和目标逻辑串口,得到第二数据帧。
步骤S3240,数据转发装置200将第二数据帧通过主串口210发送至客户端装置100。
步骤S3110,客户端装置100通过物理串口110接收该第二数据帧,并按照串口协议对第二数据帧进行解包,得到第二数据及目标逻辑串口。
步骤S3120,客户端装置100将第二数据写入对应目标逻辑串口的缓冲器中。
根据步骤S3120,当客户端应用对目标逻辑串口进行读操作时(例如直接调用操作串口的读函数),就会导致调用操作系统级别的读接口函数,该读接口函数将检查目标逻辑串口的缓冲器中是否存在数据,如果存在数据,则将数据返回给客户端应用,否则,依据操作系统设置的阻塞与否,决定是否在此处等待数据。
由此可见,根据本发明实施例的方法,客户端应用可以通过一个物理串口110读取来自多个外部设备的数据,其中,来自外部设备的数据通过数据转发装置200的处理被映射至对应的逻辑串口,这样,客户端应用便可像操作物理串口一样,通过直接对逻辑串口进行读操作获取连接至对应扩展串口的外部设备传输的数据,进而实现客户端应用通过一个物理串口110与多个外部设备进行通信的目的,而且,该客户端应用无需进行任何修改,具有可移植性。
在图2实施例的基础上,本发明方法还可以进一步包括:
步骤S4110,客户端装置100在封装得到第一数据帧时设置校验值。
该校验值可以根据预设的校验算法计算,该校验算法例如是CRC8算法。
该校验值在第一数据帧中位于串口协议定义的字段上,例如位于第一数据帧的段尾,占用1个字节。
该校验值例如是对第一数据帧中的设定字段按照预设的校验算法计算得到。
该设定字段至少包括第一数据,还可以进一步包括指定的逻辑串口等。
步骤S4210,数据转发装置200在解包后,根据得到的校验值校验第一数据帧的正确性。
在该步骤S4210中,数据转发装置200先通过解包获得客户端装置100针对第一数据帧设置的校验值。
数据转发装置200在获得客户端装置100设置的校验值后,按照客户端装置100设置校验值的相同校验算法,针对接收到的第一数据帧计算新的校验值。
如果数据转发装置200计算得到的新的校验值与解包得到的校验值相同,则说明第一数据帧的内容正确,校验第一数据帧通过;如果数据转发装置200计算得到的新的校验值与解包得到的校验值不同,则说明第一数据帧的内容出现错误,校验第一数据帧不通过。
步骤S4220,数据转发装置200在校验第一数据帧通过后,再将解包得到的第一数据发送至指定的逻辑串口对应的扩展串口。
同理,在图3实施例的基础上,本发明方法还可以进一步包括:
步骤S5210,数据转发装置200在封装得到第二数据帧时设置校验值。
步骤S5110,客户端装置100在解包后,根据解包得到的校验值校验第二数据帧的正确性。
步骤S5120,客户端装置100在校验第二数据帧通过后,再将第二数据写入对应目标逻辑串口的缓冲器中。
根据本发明该实施例的方法,通过增加以上校验环节,可以提高客户端应用与外部设备之间进行数据传输的准确性。
在图2实施例的基础上,本发明实施例的方法还可以进一步包括:
步骤S6110,客户端装置100在响应通过指定的逻辑串口发送第一数据的写操作时,确定通过指定的逻辑串口发送第一数据的发送序列号,并按照串口协议还将发送序列号封装在第一数据帧中。
根据该步骤S6110,客户端装置100可以按照串口协议,分别针对通过每一逻辑串口发送的数据帧进行各自的顺序编号。客户端装置100也可以按照串口协议,针对通过每一逻辑串口发送的数据帧进行统一的顺序编号。
以上述的进行各自的顺序编号为例,设在该步骤S6110中指定的逻辑串口为图1中的逻辑串口COM1,如果发送第一数据是通过逻辑串口COM1的第一次发送操作,则发送序列号为0X01,如果发送第一数据是通过逻辑串口COM1的第二次发送操作,则发送序列号为0X02,以此类推。
同理,在图3实施例的基础上,本发明实施例的方法还可以进一步包括:
步骤S7210,数据转发装置200在确定目标逻辑串口之后,可以确定向目标逻辑串口发送第二数据的发送序列号,并按照串口协议还将该发送序列号封装在第二数据帧中。
根据本发明该实施例的方法,通过设置针对逻辑串口发送数据的发送序列号,可以记录针对每一逻辑串口收发数据的情况,这有利于进行例如数据帧的校验、数据传输的调试等。
在以上第一数据帧中包含发送序列号的实施例的基础上,本发明实施例的方法还可以进一步包括:
步骤S6210,数据转发装置200在按照串口协议对第一数据帧进行解包之后,向客户端装置100返回针对第一数据帧的确收应答,其中,该确收应答包含该发送序列号或者对应该发送序列号的确认号。
在该步骤S6210中,数据转发装置200与客户端装置100之间可以约定发送序列号与确认号之间的对应关系。
例如,发送序列号包括表示指定的逻辑串口的字符、表示发送操作的字符、及顺序编制的序号,而对应的确认号包括其中的表示指定的逻辑串口的字符及其中的顺序编制的序号,但将表示发送操作的字符替换为表示确收的字符。
步骤S6120,客户端装置100在将第一数据帧经由物理串口发送至数据转发装置200之后:根据该发送序列号或者对应该发送序列号的确认号,检测是否在设定时间内接收到数据转发装置200返回的该确收应答,如果接收到,则进行下一数据帧的发送,如果未接收到,则根据未接收到该确收应答的检测结果,重新将第一数据帧经由物理串口发送至数据转发装置200,直至接收到数据转发装置200返回的该确收应答为止。
同理,在以上第二数据帧中包含发送序列号的实施例的基础上,本发明实施例的方法还可以进一步包括:
步骤S7110,客户端装置100在按照串口协议对第二数据帧进行解包之后,向数据转发装置200返回针对第二数据帧的确收应答,其中,该确收应答包含从第二数据帧中解包出的发送序列号或者对应该发送序列号的确认号。
步骤S7220,数据转发装置200在将第二数据帧经由主串口发送至客户端装置100之后:根据向目标逻辑串口发送第二数据的发送序列号或者对应该发送序列号的确认号,检测是否在设定时间内接收到客户端装置100返回的确收应答,如果接收到,则进行下一数据帧的发送,如果未接收到,则根据未接收到该确收应答的检测结果,重新将第二数据帧经由主串口发 送至客户端装置100,直至接收到客户端装置100返回的确收应答为止。
根据本发明该实施例的方法,通过设置确收应答步骤可以保证数据传输不会丢数据帧,提高数据传输的可靠性。
以上设置确收应答的实施例可以与以上设置数据帧校验的实施例相结合,这样,数据转发装置200可以进一步在校验第一数据帧通过后,再向客户端装置100返回针对第一数据帧的确收应答。同理,客户端装置100也可以进一步在校验第二数据帧通过后,再向数据转发装置200返回针对第二数据帧的确收应答。
根据本发明该实施例的方法,通过设置校验和确收应答的步骤即可以保证不会丢数据帧,又可以保证数据帧的正确性。
在图2中实施例的基础上,客户端装置100与数据传输装置200可以采用收发双方约定好的默认波特率传输数据,这样,客户端应用在打开逻辑串口文件后,便可直接进行写操作。
另外,客户端装置100也可以通过配置指令通知数据传输装置200配置向对应扩展串口转发数据的波特率,为此,本发明实施例的方法还可以包括如下步骤:
客户端装置100在响应通过指定的逻辑串口发送第一数据的写操作之前:
步骤S8110,客户端装置100响应配置指定的逻辑串口的操作,按照串口协议封装配置内容和指定的逻辑串口,得到配置指令。
该配置指定的逻辑串口的操作由客户端应用调用配置函数触发。
步骤S8120,客户端装置100将配置指令经由物理串口发送至数据转发装置200。
步骤S8210,数据转发装置200通过主串口接收配置指令,并按照串口协议对配置指令进行解包,得到配置内容及指定的逻辑串口。
步骤S8220,数据转发装置200按照配置内容配置指定的逻辑串口对应的扩展串口。
该配置包括对向指定的逻辑串口对应的扩展串口转发数据的波特率的配置。
通过本发明该实施例的方法,客户端应用可以根据需要自由选择进行数据传输的波特率。
<例子>
按照串口协议,客户端装置100与数据转发装置200之间传输数据/指令的帧格式如下表1中所示:
表1:帧格式
Figure PCTCN2017097097-appb-000001
根据表1,该例子中的帧格式可以包括数据头、传输内容的类型标识(包括数据、指令和确收应答等)、逻辑串口ID、发送序列号、长度、传输内容和校验值,其中,长度为传输内容与校验值的字节数之和。
根据表1,该例子中的帧格式中,数据头占用2BYTE(字节)、传输内容的类型占用1BYTE、逻辑串口ID占用1BYTE、发送序列号占用1BYTE、长度占用1BYTE、校验值占用1BYTE。
根据以上帧格式,参照图1,客户端应用通过客户端装置100的逻辑串口COM11向外部设备311发送数据0x01,0x02的帧格式如下表2所示:
表2:
Figure PCTCN2017097097-appb-000002
根据以上帧格式,参照图1,客户端应用通过客户端装置100的逻辑串口COM11配置扩展串口COM21的帧格式如下表3所示:
表3:
Figure PCTCN2017097097-appb-000003
表3中的传输内容如下表4所示:表4:
Figure PCTCN2017097097-appb-000004
表4中表示的传输内容为配置扩展串口COM21的波特率115200,串口属性为8N1,其中“8”表示8位数据位,“N”表示无奇偶校验,“1”表示具有一位停止位。
根据以上帧格式,参照图1,数据转发装置200针对逻辑串口COM11发送的发送序列号为0x01的数据帧的确收应答如下表5所示:
表5:
Figure PCTCN2017097097-appb-000005
<硬件结构>
图4为根据本发明实施例的客户端装置100的一种硬件结构的原理框图。
根据图4所示,该实施例的客户端装置100包括图1中物理串口110、处理器120和存储器130。
该存储器130用于存储指令,该指令用于控制处理器120进行操作以执行根据本发明的通过串口传输数据的方法。
该存储器130可以包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。
该处理器120可以是中央处理器CPU、微控制器MCU等。
该物理串口110例如是RS232、RS485等。
该客户端装置100还可以进一步包括显示装置、输入装置等。该显示装置例如是显示屏、触摸屏等。该输入装置例如包括键盘、鼠标、触摸屏等。
图5为根据本发明实施例的数据转发装置200的一种硬件结构的原理框图。
根据图5所示,该实施例的客户端装置100包括图1中主串口210、处理器220、存储器230、扩展串口COM21~COM2n,其中,n为大于或者等于2的整数。
该存储器230用于存储指令,该指令用于控制处理器220进行操作以执行根据本发明的通过串口传输数据的方法。
该存储器230可以包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。
该处理器220可以是微控制器MCU等。
该主串口210、扩展串口COM21~COM2n例如是RS232、RS485等。
<客户端装置>
图6为根据本发明写操作实施例的通过串口传输数据的客户端装置100的原理框图。
根据图6所示,本发明该实施例的客户端装置100包括物理串口110、虚拟映射模块121、第一封装模块122和第一发送模块123。
该虚拟映射模块121被设置为提供被映射至物理串口110的至少两个虚拟的逻辑串口。
该第一封装模块122被设置为响应通过指定的逻辑串口发送第一数据的写操作,按照设定的串口协议封装第一数据和指定的逻辑串口,得到第一数据帧。
该第一发送模块123被设置为将第一数据帧经由物理串口110发送至数据转发装置200,以供数据转发装置200按照该串口协议从第一数据帧中解包出第一数据发送至对应指定的逻辑串口的扩展串口。
图7为根据本发明读操作实施例的通过串口传输数据的客户端装置的原理框图。
根据图7所示,本发明该实施例的客户端装置100还可以包括第一接收模块124、第一解包模块125和排队模块126。
该第一接收模块124被设置为接收数据转发装置200通过物理串口110传输的第二数据帧,其中,该第二数据帧封装有第二数据及提供第二数据的扩展串口对应的目标逻辑串口。
该第一解包模块125被设置为对第二数据帧进行解包,得到第二数据及第二数据对应的目标逻辑串口。
该排队模块126被设置为将第二数据写入第二数据对应的目标逻辑串口的缓冲器中。
进一步地,根据本发明写操作实施例的通过串口传输数据的客户端装置100还可以包括第一校验值设置模块(图中未示出)。
该第一校验值设置模块被设置为在第一封装模块122封装得到第一数据帧时设置校验值,以使得数据转发装置200在根据该校验值校验第一数据帧通过后、再将解包出的第一数据发送至指定的逻辑串口对应的扩展串口。
进一步地,根据本发明读操作实施例的通过串口传输数据的客户端装置100还可以包括第一校验模块(图中未示出)。
该第一校验模块被设置为获取第一解包模块125解包第二数据帧得到的数据转发装置200针对该第二数据帧设置的校验值,并根据获取的该校验值校验第二数据帧的正确性,如果校验第二数据帧通过再通知排队模块126将第二数据写入第二数据对应的目标逻辑串口的缓冲器中。
进一步地,根据本发明读操作实施例的通过串口传输数据的客户端装置100还可以包括第一确收模块(图中未示出)。
该第一确收模块被设置为在第一接收模块124接收到第二数据帧后, 向数据转发装置200返回针对第二数据帧的确收应答,以使得数据转发装置200在设定时间内未接收到该确收应答时,能够重新将第二数据帧发送至客户端装置100。
该第一确收模块可以进一步在第一校验模块校验第二数据帧通过后,再向数据转发装置200返回针对第二数据帧的确收应答。
进一步地,根据本发明写操作实施例的通过串口传输数据的客户端装置100还可以包括第一序列号设置模块(图中未示出)。
该第一序列号设置模块被设置为在第一封装模块122响应通过指定的逻辑串口发送第一数据的写操作时,确定通过指定的逻辑串口发送第一数据的发送序列号,以使第一封装模块122按照串口协议还将该发送序列号封装在第一数据帧中。
更进一步地,根据本发明写操作实施例的通过串口传输数据的客户端装置100还可以包括第一确收判断模块(图中未示出)。
该第一确收判断模块被设置为根据该发送序列号或者对应该发送序列号的确认号,检测是否在设定时间内接收到数据转发装置200针对该第一数据帧返回的确收应答,其中,该确收应答包含该发送序列号或者对应该发送序列号的确认号;如是,则通知第一发送模块123发送下一数据帧,如否,则通过第一发送模块123重新将第一数据帧经由物理串口110发送至数据转发装置200。
进一步地,根据本发明写操作实施例的通过串口传输数据的客户端装置100还可以包括配置模块(图中未示出)。
该配置模块被设置为在第一封装模块122响应通过指定的逻辑串口发送第一数据的写操作之前,响应配置指定的逻辑串口的操作,以按照串口协议封装配置内容和指定的逻辑串口得到配置指令,并通知第一发送模块123将配置指令经由物理串口110发送至数据转发装置200,以供数据转发装置200按照解包得到的配置内容配置指定的逻辑串口对应的扩展串口。
<数据转发装置>
图8为根据本发明写操作实施例的通过串口传输数据的数据转发装置的原理框图。
根据图8所示,该实施例的数据转发装置200包括一个主串口210、至少两个扩展串口COM21~COM2n(其中,n为大于或者等于2的整数)、第二接收模块221、第二解包模块222和转发模块223。
该主串口210被设置为用于连接客户端装置100的物理串口110。
该至少两个扩展串口COM21~COM2n被设置为用于连接外部设备。
该第二接收模块221被设置为接收客户端装置100通过主串口210传输的第一数据帧,第一数据帧封装有第一数据和对应一个扩展串口的虚拟的逻辑串口。
该第二解包模块222被设置为根据串口协议对第一数据帧进行解包,得到第一数据及对应的逻辑串口。
该转发模块223被设置为将第一数据发送至该逻辑串口对应的扩展串口。
图9为根据本发明读操作实施例的通过串口传输数据的数据转发装置的原理框图。
根据图9所示,该实施例的数据转发装置200还可以包括第三接收模块224、映射模块225、第二封装模块226和第二发送模块227。
该第三接收模块224被设置为接收来自扩展串口的第二数据。
该映射模块225被设置为确定提供第二数据的扩展串口对应的虚拟的逻辑串口作为目标逻辑串口。
该第二封装模块226被设置为按照串口协议封装第二数据和目标逻辑串口,得到第二数据帧。
该第二发送模块227被设置为将第二数据帧通过主串口发送至客户端装置100,以供客户端装置100从第二数据帧中解包出第二数据及目标逻辑串口、并将第二数据写入目标逻辑串口的缓冲器中。
进一步地,根据本发明写操作实施例的通过串口传输数据的数据转发装置200还可以包括第二校验模块(图中未示出)。
该第二校验模块被设置为获取第二解包模块222解包第一数据帧得到的客户端装置100针对该第一数据帧设置的校验值,并根据获取的该校验值校验第一数据帧的正确性,如果校验第一数据帧通过再通知转发模块223将第一数据发送至该逻辑串口对应的扩展串口。
进一步地,根据本发明读操作实施例的通过串口传输数据的数据转发装置200还可以包括第二校验值设置模块(图中未示出)。
该第二校验值设置模块被设置为在第二封装模块226封装得到第二数据帧时设置校验值,以使得客户端装置100在根据该校验值校验第二数据帧通过后、再将第二数据写入目标逻辑串口的缓冲器中。
进一步地,根据本发明写操作实施例的通过串口传输数据的数据转发装置200还可以包括第二确收模块(图中未示出)。
该第二确收模块被设置为在第二接收模块221接收到第一数据帧后,向客户端装置100返回针对第一数据帧的确收应答,以使得客户端装置100 在设定时间内未接收到该确收应答时,能够重新将第一数据帧发送至数据转发装置200。
该第二确收模块进一步在第二校验模块校验第一数据帧通过后,再向客户端装置100返回针对第一数据帧的确收应答。
进一步地,根据本发明读操作实施例的通过串口传输数据的数据转发装置200还可以包括第二序列号设置模块(图中未示出)。
该第二序列号设置模块被设置为确定向目标逻辑串口发送第二数据的发送序列号,以使第二封装模块226按照串口协议还将该发送序列号封装在第二数据帧中。
更进一步地,根据本发明读操作实施例的通过串口传输数据的数据转发装置200还可以包括第二确收判断模块(图中未示出)。
该第二确收判断模块被设置为根据发送序列号或者对应发送序列号的确认号,检测是否在设定时间内接收到客户端装置100针对该第二数据帧返回的确收应答,其中,该确收应答包含第二序列号设置模块设置的发送序列号或者对应该发送序列号的确认号;如是,则通知第二发送模块227发送下一数据帧,如否,则通知第二发送模块227重新将第二数据帧经由主串口210发送至客户端装置100。
进一步地,根据本发明写操作实施例的通过串口传输数据的数据转发装置200还可以包括配置执行模块(图中未示出)。
该配置执行模块被设置为从客户端装置100通过主串口210发送的配置指令中解包出配置内容及配置对应的逻辑串口,并按照配置内容配置该逻辑串口对应的扩展串口。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分相互参见即可,每个实施例重点说明的都是与其他实施例的不同之处,但本领域技术人员应当清楚的是,上述各实施例可以根据需要单独使用或者相互结合使用。另外,对于装置实施例而言,由于其是与方法实施例相对应,所以描述得比较简单,相关之处参见方法实施例的对应部分的说明即可。以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的模块可以是或者也可以不是物理上分开的。
以上已经描述了本发明的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所披露的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本发明的范围由所附权利要求来限定。

Claims (20)

  1. 一种通过串口传输数据的方法,其特征在于,包括:
    客户端装置提供映射至一个物理串口的至少两个虚拟的逻辑串口;其中,所述物理串口为客户端装置上用于连接外部设备的物理串口;
    数据转发装置提供与所述物理串口连接的主串口及与所述逻辑串口一一对应的扩展串口;
    所述客户端装置响应通过指定的逻辑串口发送第一数据的写操作,按照预设的串口协议封装所述第一数据和指定的逻辑串口,得到第一数据帧;
    所述客户端装置将所述第一数据帧经由所述物理串口发送至所述数据转发装置;
    所述数据转发装置通过所述主串口接收所述第一数据帧,并按照所述串口协议对所述第一数据帧进行解包,得到所述第一数据及指定的逻辑串口;
    所述数据转发装置将所述第一数据发送至所述指定的逻辑串口对应的扩展串口。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    所述数据转发装置接收来自一扩展串口的第二数据;
    所述数据转发装置确定所述一扩展串口对应的逻辑串口作为目标逻辑串口;
    所述数据转发装置按照所述串口协议封装所述第二数据和所述目标逻辑串口,得到第二数据帧;
    所述数据转发装置将所述第二数据帧通过所述主串口发送至所述客户端装置;
    所述客户端装置通过所述物理串口接收所述第二数据帧,并按照所述串口协议对所述第二数据帧进行解包,得到所述第二数据及所述目标逻辑串口;
    所述客户端装置将所述第二数据写入对应所述目标逻辑串口的缓冲器中。
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:
    所述客户端装置在封装得到所述第一数据帧时设置校验值;
    所述数据转发装置在解包后,根据得到的校验值校验所述第一数据帧的正确性;
    所述数据转发装置在校验所述第一数据帧通过后,再将解包得到的第一数据发送至所述指定的逻辑串口对应的扩展串口。
  4. 根据权利要求1-3中任一项所述的方法,其特征在于,所述方法还包括:
    所述客户端装置在响应通过指定的逻辑串口发送第一数据的写操作时,确定通过所述指定的逻辑串口发送第一数据的发送序列号,并按照所述串口协议还将所述发送序列号封装在所述第一数据帧中。
  5. 根据权利要求4所述的方法,其特征在于,所述方法还包括:
    所述数据转发装置在按照所述串口协议对所述第一数据帧进行解包之后,向所述客户端装置返回针对所述第一数据帧的确收应答,其中,所述确收应答包含所述发送序列号或者对应所述发送序列号的确认号;
    所述客户端装置在将所述第一数据帧经由所述物理串口发送至所述数据转发装置之后:
    根据所述发送序列号或者对应所述发送序列号的确认号,检测是否在设定时间内接收到所述数据转发装置返回的所述确收应答;
    根据未接收到所述确收应答的检测结果,重新将所述第一数据帧经由所述物理串口发送至所述数据转发装置。
  6. 根据权利要求1-5中任一项所述的方法,其特征在于,所述方法还包括:
    所述客户端装置在响应通过指定的逻辑串口发送第一数据的写操作之前:
    响应配置所述指定的逻辑串口的操作,按照所述串口协议封装配置内容和指定的逻辑串口,得到配置指令;以及,
    将所述配置指令经由所述物理串口发送至所述数据转发装置;
    所述数据转发装置通过所述主串口接收所述配置指令,并按照所述串 口协议对所述配置指令进行解包,得到配置内容及指定的逻辑串口;
    所述数据转发装置按照所述配置内容配置所述指定的逻辑串口对应的扩展串口。
  7. 一种通过串口传输数据的客户端装置,其特征在于,包括:
    物理串口;
    虚拟映射模块,被设置为提供被映射至所述物理串口的至少两个虚拟的逻辑串口;
    第一封装模块,被设置为响应通过指定的逻辑串口发送第一数据的写操作,按照设定的串口协议封装所述第一数据和指定的逻辑串口,得到第一数据帧;以及,
    第一发送模块,被设置为将所述第一数据帧经由所述物理串口发送至数据转发装置,以供所述数据转发装置按照所述串口协议从所述第一数据帧中解包出所述第一数据发送至对应所述指定的逻辑串口的扩展串口。
  8. 根据权利要求7所述的客户端装置,其特征在于,还包括:
    第一接收模块,被设置为接收数据转发装置通过所述物理串口传输的第二数据帧,其中,所述第二数据帧封装有第二数据及提供所述第二数据的扩展串口对应的目标逻辑串口;
    第一解包模块,被设置为对所述第二数据帧进行解包,得到所述第二数据及所述第二数据对应的目标逻辑串口;
    排队模块,被设置为将所述第二数据写入所述第二数据对应的目标逻辑串口的缓冲器中。
  9. 根据权利要求7或8所述的客户端装置,其特征在于,还包括:
    第一校验值设置模块,被设置为在所述第一封装模块封装得到第一数据帧时设置校验值,以使得所述数据转发装置在根据所述校验值校验第一数据帧通过后、再将解包出的第一数据发送至指定的逻辑串口对应的扩展串口。
  10. 根据权利要求7-9中任一项所述的客户端装置,其特征在于,还包括:
    第一序列号设置模块,被设置为在所述第一封装模块响应通过指定的 逻辑串口发送第一数据的写操作时,确定通过指定的逻辑串口发送第一数据的发送序列号,以使所述第一封装模块按照串口协议还将所述发送序列号封装在第一数据帧中。
  11. 根据权利要求10所述的客户端装置,其特征在于,还包括:
    第一确收判断模块,被设置为根据所述发送序列号或者对应该发送序列号的确认号,检测是否在设定时间内接收到数据转发装置针对所述第一数据帧返回的确收应答,其中,所述确收应答包含该发送序列号或者对应该发送序列号的确认号;如是,则通知所述第一发送模块发送下一数据帧,如否,则通知所述第一发送模块重新将所述第一数据帧经由物理串口发送至数据转发装置。
  12. 根据权利要求8所述的客户端装置,其特征在于,还包括:
    第一校验模块,被设置为获取所述第一解包模块解包第二数据帧得到的数据转发装置针对所述第二数据帧设置的校验值,及根据获取到的所述校验值校验所述第二数据帧的正确性,并在校验所述第二数据帧通过的情况下再通知所述排队模块将所述第二数据写入第二数据对应的目标逻辑串口的缓冲器中。
  13. 根据权利要求7-12中任一项所述的客户端装置,其特征在于,还包括:
    配置模块,被设置为在所述第一封装模块响应通过指定的逻辑串口发送第一数据的写操作之前,响应配置指定的逻辑串口的操作,以按照串口协议封装配置内容和指定的逻辑串口得到配置指令,并通知第一发送模块将配置指令经由物理串口发送至数据转发装置,以供数据转发装置按照解包得到的配置内容配置指定的逻辑串口对应的扩展串口。
  14. 一种通过串口传输数据的数据转发装置,其特征在于,包括:
    一个主串口,被设置为用于连接客户端装置的物理串口;
    至少两个扩展串口,被设置为用于连接外部设备;
    第二接收模块,被设置为接收客户端装置通过所述主串口传输的第一数据帧,所述第一数据帧封装有第一数据和对应一个扩展串口的虚拟的逻辑串口;
    第二解包模块,被设置为根据串口协议对所述第一数据帧进行解包,得到所述第一数据及所述逻辑串口;以及,
    转发模块,被设置为将所述第一数据发送至所述逻辑串口对应的扩展串口。
  15. 根据权利要求14所述的数据转发装置,其特征在于,还包括:
    第三接收模块,被设置为接收来自扩展串口的第二数据;
    映射模块,被设置为确定提供所述第二数据的扩展串口对应的虚拟的逻辑串口作为目标逻辑串口;
    第二封装模块,被设置为按照所述串口协议封装所述第二数据和所述目标逻辑串口,得到第二数据帧;以及,
    第二发送模块,被设置为将所述第二数据帧通过所述主串口发送至所述客户端装置,以供所述客户端装置从所述第二数据帧中解包出所述第二数据及所述目标逻辑串口、并将所述第二数据写入所述目标逻辑串口的缓冲器中。
  16. 根据权利要求14或15所述的数据转发装置,其特征在于,还包括:
    第二校验模块,被设置为获取所述第二解包模块解包所述第一数据帧得到的客户端装置针对所述第一数据帧设置的校验值,及根据获取到的所述校验值校验第一数据帧的正确性,并在校验所述第一数据帧通过的情况下再通知所述转发模块将所述第一数据发送至逻辑串口对应的扩展串口。
  17. 根据权利要求15所述的数据转发装置,其特征在于,还包括:
    第二校验值设置模块,被设置为在所述第二封装模块封装得到第二数据帧时设置校验值,以使得客户端装置在根据所述校验值校验第二数据帧通过后、再将第二数据写入目标逻辑串口的缓冲器中。
  18. 根据权利要求15或17所述的数据转发装置,其特征在于,还包括:
    第二序列号设置模块,被设置为确定向目标逻辑串口发送第二数据的发送序列号,以使所述第二封装模块按照串口协议还将该发送序列号封装在第二数据帧中。
  19. 根据权利要求18所述的数据转发装置,其特征在于,还包括:
    第二确收判断模块,被设置为根据所述发送序列号或者对应发送序列号的确认号,检测是否在设定时间内接收到客户端装置针对所述第二数据帧返回的确收应答,其中,所述确收应答包含所述第二序列号设置模块设置的发送序列号或者对应该发送序列号的确认号;如是,则通知所述第二发送模块发送下一数据帧,如否,则通知所述第二发送模块重新将所述第二数据帧经由主串口发送至客户端装置。
  20. 根据权利要求14-20中任一项所述的数据转发装置,其特征在于,还包括:
    配置执行模块,被设置为从客户端装置通过主串口发送的配置指令中解包出配置内容及配置对应的逻辑串口,并按照配置内容配置该逻辑串口对应的扩展串口。
PCT/CN2017/097097 2017-06-23 2017-08-11 通过串口传输数据的方法、客户端装置及数据转发装置 Ceased WO2018232899A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US15/743,533 US10346344B2 (en) 2017-06-23 2017-08-11 Method, client device and data forwarding device for transmitting data through serial port

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710488731.9A CN107391421B (zh) 2017-06-23 2017-06-23 通过串口传输数据的方法、客户端装置及数据转发装置
CN201710488731.9 2017-06-23

Publications (1)

Publication Number Publication Date
WO2018232899A1 true WO2018232899A1 (zh) 2018-12-27

Family

ID=60332625

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/097097 Ceased WO2018232899A1 (zh) 2017-06-23 2017-08-11 通过串口传输数据的方法、客户端装置及数据转发装置

Country Status (3)

Country Link
US (1) US10346344B2 (zh)
CN (1) CN107391421B (zh)
WO (1) WO2018232899A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115794236A (zh) * 2022-10-27 2023-03-14 北京计算机技术及应用研究所 基于龙芯2K处理器的Linux系统串口数据包可靠传输方法
CN116028259A (zh) * 2021-10-26 2023-04-28 比亚迪股份有限公司 储能系统、云端服务器及储能数据管理系统

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108733604B (zh) * 2018-05-11 2020-06-05 深圳市脉联电子有限公司 一种基于modbus通讯协议的485总线智能扩展方法及装置
CN109194442A (zh) * 2018-08-08 2019-01-11 济南浪潮高新科技投资发展有限公司 一种串口数据转发装置、方法及系统
CN110365687B (zh) * 2019-07-19 2022-09-13 北京智芯微电子科技有限公司 Swp协议处理器
CN110704357B (zh) * 2019-09-29 2021-05-18 歌尔股份有限公司 一种主站与多个从站串行通信的方法及装置
CN111404739B (zh) * 2020-03-11 2023-05-26 超越科技股份有限公司 一种串口网络化属性配置的系统
CN111475318B (zh) * 2020-04-29 2021-02-23 中国人民解放军军事科学院国防科技创新研究院 一种支持多用户访问的串口通信装置、方法及系统
CN113595966B (zh) * 2020-04-30 2023-04-18 阿里巴巴集团控股有限公司 串口通信控制、配置、测试方法、装置、电子设备和存储介质
CN112799988A (zh) * 2020-12-28 2021-05-14 杭州涂鸦信息技术有限公司 虚拟串口与串口通讯板的绑定方法、设备及介质
CN112765083A (zh) * 2021-01-29 2021-05-07 苏州易德龙科技股份有限公司 一种基于rs232的通讯协议
CN114048163A (zh) * 2021-11-11 2022-02-15 四川泛华航空仪表电器有限公司 一种基于Python的串口调试方法及系统
CN116132501B (zh) * 2021-11-15 2025-07-18 北京小米移动软件有限公司 信息发送和接收方法、装置、终端及存储介质
CN114189316B (zh) * 2021-12-06 2024-11-08 经纬恒润(天津)研究开发有限公司 一种波特率和报文协议的自适应方法及装置
CN114647597A (zh) * 2022-03-22 2022-06-21 杭州迪普科技股份有限公司 Cpu的串口转换方法及装置
CN116827822A (zh) * 2023-07-10 2023-09-29 普联技术有限公司 串行链路的通信方法、系统、设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470688A (zh) * 2007-12-28 2009-07-01 希姆通信息技术(上海)有限公司 单端串口实现多功能复用的方法
CN101621440A (zh) * 2009-05-22 2010-01-06 浙江天正电气股份有限公司 远程多路串口通讯映射系统
CN101894041A (zh) * 2010-07-15 2010-11-24 中兴通讯股份有限公司 多虚拟串口系统及其通信方法
WO2017021764A1 (en) * 2015-08-06 2017-02-09 Telefonaktiebolaget Lm Ericsson (Publ) Methods, apparatus, and systems for providing access to serial ports of virtual machines in self-deployed virtual applications

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7327688B2 (en) * 1994-01-21 2008-02-05 Alcatel Canada Inc. Digital communications system
US6073183A (en) * 1995-03-31 2000-06-06 Intel Corporation Transparent communication with multiple devices over a single serial or parallel port of a computer
US7111102B2 (en) * 2003-10-06 2006-09-19 Cisco Technology, Inc. Port adapter for high-bandwidth bus
US7761621B2 (en) * 2006-09-14 2010-07-20 Digi International Inc. Embedded virtual serial port
US9647883B2 (en) * 2014-03-21 2017-05-09 Nicria, Inc. Multiple levels of logical routers
JP6434821B2 (ja) * 2015-02-19 2018-12-05 アラクサラネットワークス株式会社 通信装置及び通信方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470688A (zh) * 2007-12-28 2009-07-01 希姆通信息技术(上海)有限公司 单端串口实现多功能复用的方法
CN101621440A (zh) * 2009-05-22 2010-01-06 浙江天正电气股份有限公司 远程多路串口通讯映射系统
CN101894041A (zh) * 2010-07-15 2010-11-24 中兴通讯股份有限公司 多虚拟串口系统及其通信方法
WO2017021764A1 (en) * 2015-08-06 2017-02-09 Telefonaktiebolaget Lm Ericsson (Publ) Methods, apparatus, and systems for providing access to serial ports of virtual machines in self-deployed virtual applications

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116028259A (zh) * 2021-10-26 2023-04-28 比亚迪股份有限公司 储能系统、云端服务器及储能数据管理系统
CN115794236A (zh) * 2022-10-27 2023-03-14 北京计算机技术及应用研究所 基于龙芯2K处理器的Linux系统串口数据包可靠传输方法

Also Published As

Publication number Publication date
CN107391421B (zh) 2019-11-15
CN107391421A (zh) 2017-11-24
US10346344B2 (en) 2019-07-09
US20190079894A1 (en) 2019-03-14

Similar Documents

Publication Publication Date Title
WO2018232899A1 (zh) 通过串口传输数据的方法、客户端装置及数据转发装置
TWI571087B (zh) 用於在乙太型網路上對記憶體及輸入/輸出進行遠端存取之非揮發性記憶體快速控制器
US11809367B2 (en) Programmed input/output mode
CN104025069B (zh) 用于fpga原型化的串行接口
US11695669B2 (en) Network interface device
US11989154B2 (en) Hybrid remote direct memory access
US9152592B2 (en) Universal PCI express port
KR102367234B1 (ko) NVMe SGL 비트 버킷 전송들
EP4016309A1 (en) System, apparatus and method for handling multi-protocol traffic in data link layer circuitry
US20040139244A1 (en) Method, system, and program for processing a packet including I/O commands and data
TW201720123A (zh) 用於透過乙太式網路遠端存取記憶體及輸入/輸出之特快非揮發性記憶體控制器
US10846163B1 (en) Hybrid hardware and software reporting management
WO2019128575A1 (zh) 一种中断处理方法及中断处理装置
CN115664883A (zh) 具有高效存储协议仿真的网络适配器
CN106708762B (zh) 一种linux下串口设备统一管理系统及方法
US20200210224A1 (en) Methods and apparatus for verifying completion of groups of data transactions between processors
TWI704453B (zh) 具有通訊機制的計算系統及其操作方法
CN104184543B (zh) 一种数据传输的方法、装置和系统
CN101208677B (zh) 自动串行协议目标端口传输层重试方法及装置
CN111131439A (zh) 基于iSCSI的报文传输方法、装置、设备及存储介质
CN104737145A (zh) 传输中断包
CN104102550A (zh) 一种多主机进程间通信的方法
CN118642883B (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: 17915014

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: 17915014

Country of ref document: EP

Kind code of ref document: A1