CN111666238A - Data transmission device and method - Google Patents

Data transmission device and method Download PDF

Info

Publication number
CN111666238A
CN111666238A CN202010500054.XA CN202010500054A CN111666238A CN 111666238 A CN111666238 A CN 111666238A CN 202010500054 A CN202010500054 A CN 202010500054A CN 111666238 A CN111666238 A CN 111666238A
Authority
CN
China
Prior art keywords
data
serial port
port
network
serial
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.)
Pending
Application number
CN202010500054.XA
Other languages
Chinese (zh)
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.)
Beijing Interstellar Glory Space Technology Co Ltd
Beijing Interstellar Glory Technology Co Ltd
Original Assignee
Beijing Interstellar Glory Space Technology Co Ltd
Beijing Interstellar Glory Technology Co Ltd
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 Beijing Interstellar Glory Space Technology Co Ltd, Beijing Interstellar Glory Technology Co Ltd filed Critical Beijing Interstellar Glory Space Technology Co Ltd
Priority to CN202010500054.XA priority Critical patent/CN111666238A/en
Publication of CN111666238A publication Critical patent/CN111666238A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/385Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/38Universal adapter
    • G06F2213/3808Network interface controller

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention relates to the technical field of Internet of things, in particular to a data transmission device and a data transmission method, wherein the device comprises a serial port communication unit which is provided with at least one serial port; a network port communication unit having at least one network port; the control unit is respectively connected with the serial port communication unit and the network port communication unit; the control unit is used for converting first serial port data received by the at least one serial port into first internet access data and outputting the first internet access data from the at least one internet access; and the control unit is also used for converting the second network port data received by the at least one network port into second serial port data and outputting the second serial port data from the at least one serial port. The device can realize the transmission problem of serial port data and network port data, and can better solve the compatibility problem of serial port communication and network port communication by adopting a plug-and-play strategy without changing the original circuit and software system when the data transmission device is subsequently applied to an embedded system.

Description

Data transmission device and method
Technical Field
The invention relates to the technical field of Internet of things, in particular to a data transmission device and a data transmission method.
Background
At present, the communication of the internet of things becomes a great development direction, and the embedded network communication technology is the basis of the internet of things. For embedded devices, data communication is generally performed through a serial port. However, with the popularization and wide application of network technologies, the internet of things communication is emerging, and some network devices also need to be accessed into an embedded system. For network devices, data communication is typically performed through a portal. Then, if the embedded device and the network device need to be accessed in the same embedded system, new circuits and driver software need to be added on the basis of the original embedded system to realize the compatibility of serial port communication and network port communication. However, this method may cause the circuit structure of the original embedded system to change, increasing the complexity of the circuit design.
Disclosure of Invention
In view of this, embodiments of the present invention provide a data transmission device and method to solve the problem of compatibility between serial port communication and network port communication in the same embedded system.
According to a first aspect, an embodiment of the present invention provides a data transmission apparatus, including:
the serial port communication unit is provided with at least one serial port;
a network port communication unit having at least one network port;
the control unit is respectively connected with the serial port communication unit and the network port communication unit; the control unit is used for converting first serial port data received by the at least one serial port into first internet access data and outputting the first internet access data from the at least one internet access; and the control unit is also used for converting the second network port data received by the at least one network port into second serial port data and outputting the second serial port data from the at least one serial port.
According to the data transmission device provided by the embodiment of the invention, the serial port communication unit and the network port communication unit are integrated in the device and used for transmitting serial port data and network port data, and the control unit is used for converting the serial port data into the network port data and converting the network port data into the serial port data, so that the problem of transmission of the serial port data and the network port data can be realized through the device, when the data transmission device is subsequently applied to an embedded system, the original circuit and software system do not need to be changed, and the problem of compatibility of the serial port communication and the network port communication can be better solved by adopting a plug-and-play strategy.
With reference to the first aspect, in a first implementation manner of the first aspect, the serial port communication unit includes:
and the level conversion circuit is respectively connected with the at least one serial port and the control unit.
According to the data transmission device provided by the embodiment of the invention, the working voltages between the upper computer in communication with the serial port and the control unit are different, so that the level conversion circuit arranged in the serial port communication unit can meet the normal working requirement of the serial port communication unit.
With reference to the first aspect or the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the portal communication unit includes:
the clock circuit is connected with the clock interface of the network card chip;
and the network card chip is connected with the control unit.
The Ethernet peripheral circuit is connected with the network card chip;
according to the data transmission device provided by the embodiment of the invention, the Ethernet peripheral circuit is adopted in the network port communication unit to transmit the network port data, namely, the data is transmitted in a direct memory access mode, so that the data is directly accessed from the memory without passing through the CPU in the data transmission, and the resource occupancy rate of the CPU is reduced.
With reference to the first aspect, in a third implementation manner of the first aspect, the control unit includes:
the power supply circuit is used for supplying working power to the controller;
and the controller is respectively connected with the serial port communication unit and the network port communication unit.
According to a second aspect, an embodiment of the present invention further provides a data transmission method, including:
acquiring first serial port data from at least one serial port of a serial port communication unit, and/or acquiring second network port data from at least one network port of a network port communication unit;
and converting the first serial port data into first internet port data and outputting the first internet port data from the at least one internet port, and/or converting the second internet port data into second serial port data and outputting the second serial port data from the at least one serial port.
The data transmission method provided by the embodiment of the invention can be applied to a data transmission device, and the serial port data is converted into the network port data and the network port data is converted into the serial port data, so that the transmission problem of the serial port data and the network port data can be realized through the device.
With reference to the second aspect, in a first embodiment of the second aspect, the converting the first serial data into first portal data and outputting the first portal data from the at least one portal includes:
receiving the first serial port data from the at least one serial port in an interrupt mode;
analyzing the first serial port data according to a first preset protocol to obtain first internet port data;
and outputting the first internet access data through the at least one internet access.
With reference to the first embodiment of the second aspect, in the second embodiment of the second aspect, the outputting the first portal data through the at least one portal includes:
and outputting the first internet access data through the at least one internet access by using a uIP protocol stack.
The data transmission method provided by the embodiment of the invention can be operated on a bare board without an operating system based on the operation of the uIP protocol stack.
With reference to the second aspect, or the first implementation manner of the second aspect, or the second implementation manner of the second aspect, in a third implementation manner of the second aspect, the converting the second internet access data into second serial data to be output from the at least one serial port includes:
receiving the second internet access data from the at least one internet access by adopting a query mode;
analyzing the second internet access data according to a second preset protocol to obtain second serial port data;
and outputting the second serial port data through the at least one serial port.
With reference to the third implementation manner of the second aspect, in a fourth implementation manner of the second aspect, the receiving, by using a query, the second portal data from the at least one portal includes:
and receiving the second internet access data from the at least one internet access by using a uIP protocol stack in a query mode.
With reference to the fourth embodiment of the second aspect, in a fifth embodiment of the second aspect, the outputting the second serial port data through the at least one serial port includes:
and outputting the second serial port data through the at least one serial port in a direct memory access mode.
According to the data transmission method provided by the embodiment of the invention, the second serial port data is output by adopting a direct memory access method, so that the data is directly accessed from the memory without passing through the CPU in the data transmission process, and the resource occupancy rate of the CPU is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a block diagram of a data transmission apparatus according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a serial communication unit according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a clock circuit according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an Ethernet peripheral circuit according to an embodiment of the invention;
FIG. 5 is a schematic structural diagram of a control unit according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a power supply circuit according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a reset circuit according to an embodiment of the present invention;
FIG. 8 is a flow chart of a method of data transmission according to an embodiment of the present invention;
FIG. 9 is a logical framework diagram of a data transfer method according to an embodiment of the present invention;
FIG. 10 is a process flow of portal data processing in a control loop according to an embodiment of the present invention;
fig. 11 is a process flow of reception of portal data according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the data communication device described in the embodiment of the present invention is used in a circuit system, and realizes compatibility between serial port communication and network port communication. The data communication device is provided with a serial port and a network port, so that the serial port of the data communication device can be connected with the serial port communication equipment in a circuit system which needs to solve the problem of compatibility between serial port communication and network port communication, the network port is connected with the network port communication equipment, the structure of the original circuit system does not need to be changed, and plug and play are realized.
An embodiment of the present invention provides a data communication device, as shown in fig. 1, the data communication device includes a serial port communication unit 10, a network port communication unit 20, and a control unit 30. The control unit 30 is connected to the serial port communication unit 10 and the network port communication unit 20, respectively, and is configured to implement interconversion between serial port data and network port data.
Specifically, the serial communication unit 10 has at least one serial port, and each serial port may be used to transmit serial data. For example, the number of serial ports may be 1, 2, 3, or 5, etc., and the number of serial ports of the serial port communication unit 10 is not limited at all, and may be set accordingly according to actual situations.
The serial port communication unit 10 may further include other auxiliary circuits, such as a level shift circuit, on the basis of having at least one serial port. The specific structure of the serial communication unit 10 will be described in detail below.
In this embodiment, for example, the serial communication unit 10 has 5 serial ports, and the control unit may attach a source of the serial data to the data packet when converting the serial data, for example, may add an identifier corresponding to the serial port one to one. When a serial port receives the first serial port data, the control unit 30 converts the first serial port data into first internet port data, and outputs the first internet port data through the internet port of the internet port communication unit 20. When the control unit 30 converts the serial port data into the network port data, the serial port data may be analyzed first and then converted into the network port data for output. The specific conversion process will be described in detail in the following data transmission method.
The internet access communication unit 20 has at least one internet access, and each internet access can be used for transmitting internet access data. For example, the number of the network ports may be 1, 2, or 3, and so on, and the number of the network ports of the network port communication unit 20 is not limited at all, and may be set accordingly according to actual situations.
The portal communication unit 20 may further include other auxiliary circuits such as a power circuit, an outlet circuit, and the like, in addition to the at least one portal. The specific structure of the portal communication unit 20 will be described in detail below.
In this embodiment, taking the example that the network port communication unit 20 has one network port, after the network port receives the second network port data, the control unit 30 converts the second network port data into second serial data, and outputs the second serial data by using the serial port of the serial communication unit 10. When the control unit 30 converts the second network port data into the second serial port data, the second network port data may be analyzed first and then converted into the second serial port data to be output. The specific conversion process will be described in detail in the following data transmission method.
The control unit 10 shown in fig. 1 is used to implement interconversion between serial port data and network port data, and may be implemented by a programmable logic control device, or by other controllers, where the specific form of the control unit 10 is not limited at all. A data conversion program is stored in a storage module of the controller, and the control unit 10 converts received serial port data or network port data based on the stored data conversion program. The specific conversion will be described in detail below.
The data transmission device that this embodiment provided, serial communication unit and net gape communication unit have integrateed in the device are used for transmitting serial data and net gape data, and utilize the control unit to carry out serial data to net gape data, and net gape data changes serial data, therefore, can realize the transmission problem of serial data and net gape data through the device, follow-up when using this data transmission device to embedded system in, need not change original circuit and software system, adopt the compatible problem of plug-and-play's strategy can better solution serial communication and net gape communication.
In some optional implementations of this embodiment, as shown in fig. 2, the serial port communication unit includes a level shifter circuit and a serial port. The level shift circuit in fig. 2 is MAX232 as an example, but the protection scope of the present invention is not limited thereto, and may be other types of level shift circuits, which are not limited herein, and only need to implement normal communication between the host computer in communication with the serial port and the control unit 10. For example, the typical working voltage of the upper computer communicating with the RS232 serial port is 3V to 12V, -3V to-12V, while the working voltage of the control unit 10 is TTL level, and for the convenience of subsequent user debugging, a level conversion circuit is connected with the serial port UART1 for communicating with the upper computer.
It should be noted that the type of the capacitor connected to the level shift circuit MAX232 in fig. 2 may be set according to actual conditions, and fig. 2 is only an alternative embodiment, but the scope of the present invention is not limited thereto.
In other optional implementations of this embodiment, the network port communication unit includes a clock circuit, a network card chip, and an ethernet peripheral circuit. The clock circuit is used for providing an external clock for the network card chip, and the Ethernet peripheral circuit is connected with the network card chip.
The clock circuit is used for providing a time sequence signal for the network card chip. The clock circuit can adopt a crystal oscillator circuit or other clock chips. In the present embodiment, a clock circuit is taken as an external crystal oscillator circuit as an example. As shown in fig. 3, a 25MHz crystal oscillator is used as the external clock.
The network card chip may be specifically selected according to the actual situation, for example, the DM9000A network card chip may be selected. The network card chip has the self-adaptive rate of 10M/1000M, the width of a data bus is set to be 8 bits, an interrupt processing mode is not adopted, and a polling mode is adopted. The circuit structure diagram of the ethernet peripheral device may adopt the connection structure shown in fig. 4. The portal communication unit 20 may be connected via RJ45 as an interface, using twisted pair wires or other network equipment.
In the network port communication unit 20, the ethernet peripheral circuit is used to transmit network port data, that is, the data is transmitted in a direct memory access manner, so that the data is directly accessed from the memory without passing through the CPU, and the CPU resource occupancy is reduced.
As an optional implementation manner of this embodiment, as shown in fig. 5, the control unit 10 may be implemented by a minimum system of a single chip, and the control unit includes a power circuit and a controller. As shown in fig. 5, the minimum system of the single chip has a working frequency of 72MHz, and contains 512K Flash and 5 UART interfaces.
The power circuit is used for providing working power for the controller. Fig. 6 shows a specific schematic block diagram of a power supply circuit for converting an external 5V voltage to a 3.3V voltage. In conjunction with the control unit shown in fig. 5, the operating voltage of the controller is 2V to 3.6V, and the external power supply voltage can be converted into the operating voltage of the controller by using the power supply circuit. The voltage regulator chip U2 in fig. 6 is used for voltage reduction, and the capacitors C1, C17, C2 and C18 are used for filtering and filtering the interference of the input voltage fluctuation to the controller.
The control unit in fig. 5 also comprises a reset circuit. Optionally, for convenience of debugging, the reset circuit used in this embodiment is, as shown in fig. 7, a combination of power-on automatic reset and manual reset.
The embodiment of the invention also provides a data transmission method which can be applied to the control unit of the data transmission device in the embodiment. Specifically, as shown in fig. 8, the data transmission method includes:
s11, obtaining the first serial port data from at least one serial port of the serial port communication unit, and/or obtaining the second network port data from at least one network port of the network port communication unit.
With reference to the data transmission device in the foregoing embodiment, the control unit obtains the first serial port data from at least one serial port of the serial port communication unit, and/or obtains the second internet access data from at least one internet access of the internet access communication unit.
S12, converting the first serial port data into first network port data and outputting the first network port data from at least one network port, and/or converting the second network port data into second serial port data and outputting the second serial port data from at least one serial port.
After receiving the first serial port data, the control unit analyzes the first serial port data, packages the first serial port data into first internet port data and outputs the first internet port data from at least one internet port; and/or after receiving the second network port data, the control unit analyzes the second network port data, packages the second network port data into second serial port data and outputs the second serial port data from at least one serial port.
The data transmission method provided by the embodiment can be applied to a data transmission device, and the serial port data is converted into the network port data and the network port data is converted into the serial port data, so that the transmission problem of the serial port data and the network port data can be realized through the device.
As an optional implementation manner of this embodiment, the step S11 includes the following steps:
(1) and receiving the first serial port data from at least one serial port in an interrupt mode.
For example, referring to fig. 9, as shown in fig. 9, the control unit receives the first serial port data in an interrupt manner.
(2) And analyzing the first serial port data according to a first preset protocol to obtain first internet port data.
After receiving the first serial port data, analyzing the first serial port data according to a first preset protocol, and sending the analyzed first serial port data to a scheduling and management module in the control unit. The first preset protocol is a communication protocol corresponding to the serial port, for example, when the serial port is RS232, the RS232 communication protocol is used to analyze the first serial port data.
(3) And outputting the first internet access data through at least one internet access.
The scheduling and management module processes the network data and sends the network data to the network port for sending.
Optionally, the control unit outputs the first portal data through at least one portal by using the upi protocol stack. Based on the running of the uIP protocol stack, the operating system can be separated from running on a bare board.
In other optional embodiments of this embodiment, the step S12 includes the following steps:
(1) and receiving second internet access data from at least one internet access by adopting an inquiry mode.
And the control unit receives the second internet access data from at least one internet access of the internet access communication unit in an inquiry mode, and optionally, receives the second internet access data from at least one internet access in an inquiry mode by using the uIP protocol stack.
(2) And analyzing the second network port data according to a second preset protocol to obtain second serial port data.
After receiving the second port data, the control unit analyzes the second port data according to a second preset protocol, and performs serial port data processing on the analyzed data by using the scheduling and management module shown in fig. 9.
(3) And outputting the second serial port data through at least one serial port.
And after the scheduling and management module processes the second network port data into second serial port data, the second serial port data is output through at least one serial port of the serial port communication unit.
Optionally, the control unit outputs the second serial port data through at least one serial port in a direct memory access manner. The second serial port data is output by adopting a direct memory access method, so that the data is directly accessed from the memory without being transmitted through the CPU, and the resource occupancy rate of the CPU is reduced.
Hereinafter, a data transmission method is described from the software implementation perspective. The software running in the control unit of the data transmission device is divided into three layers, namely a drive layer, a protocol layer and an application layer. The drive layer comprises transplantation of network uIP, interruption of five serial ports and DMA communication realization. The protocol layer contains the parsing, translation and packaging of data. The application layer mainly handles information and manages scheduling.
And the software transplantation uIP protocol is used for carrying out network communication. As shown in FIG. 9, FIG. 9 illustrates the overall logical framework of the software. Wherein, the application function portal: the data flow or program operation start is divided into main entry and interrupt entry, namely the so-called embedded software foreground and background architecture. The dispatching and management are periodically operated in the main, the network data are received, the serial port and the network data are sent, the data which are mainly processed and read by the serial port are interrupted, the receiving and sending conversion of the serial port data and the network data is comprehensively realized, namely, the controller reads the network data and then converts the data into the serial port data to be sent, and the data read from the serial port is sent through the network.
Specifically, the initialization includes startup, clock initialization, Flash storage initialization, DMA initialization, interrupt initialization, serial port initialization, network initialization, and the like. This part of the function is automatically completed by the program.
Configuration parameters can be filled in by a user through the operation of an upper computer network assistant interface, and include but are not limited to serial port numbers, baud rates, data bit lengths, stop bits, parity bits and data lengths of serial ports; network address, port number, etc. The filling mode and content are detailed in the protocol design part below, and the configuration can be completed.
(1) Network to serial port
Example (c):
com 1: the data represents data sent to com 1;
com 123456789: the data is sent to a com1 port without changing;
com 223456789: the data is sent to a com2 port without changing;
if the packet does not carry a header (com2, etc.), it is automatically sent from the com 1.
(2) Serial to network
And the data received by the serial port is directly sent to the network port and transmitted through. (it is proposed to have a header for data processing).
(3) Configuring serial port parameters
(3.1) opening configuration
Wherein, the upper computer issuing protocol is shown in table 1; the lower computer returns a protocol, and does not.
TABLE 1 upper computer issuing protocol
Frame header
Type (B) Char
Length of 15 bytes
Content providing method and apparatus usartConfigOpen
Example (c): usartConfigOpen
setUsart,com1,115200,8,1,None,end;
setUsart,com2,,9600,8,0,0,end;
A stop position 012;
and a check bit 012.
(3.2) configuration parameters
Wherein, the upper computer issuing protocol is shown in table 2; the lower computer returns a protocol, and does not.
TABLE 2 upper computer issuing protocol
Frame header Separator symbol Data of
Type (B) Char Char Char
Length of 4 bytes 1 byte Become longer
Content providing method and apparatus comX , Baud rate
Example (c): com1, 115200, 8, 1, None, end.
(4) Network parameter configuration
(4.1) opening configuration
The upper computer issuing protocol is shown in table 3.
TABLE 3 upper computer issuing protocol
Frame header
Type (B) Char
Length of 13 bytes
Content providing method and apparatus netConfigOpen
Example (c): netConfigOpen.
(4.2) configuration parameters
Wherein, the upper computer issuing protocol is shown in table 4; the lower computer returns a protocol, and does not.
TABLE 4 upper computer issuing protocol
Frame header Separator symbol Data of
Type (B) Char Char Char
Length of 3 bytes 1 byte Become longer
Content providing method and apparatus net , Configuration information
Example (c): net, 192.168.1.10, 1000; or: net, 192.168.1.100, 8080.
After configuration is complete, data communication can be achieved. Wherein, the network transmission is based on the open source small-sized uIP protocol stack, and the Ethernet data is processed by TCP at the network layer and the protocol layer by being transplanted to stm 32. In the physical layer and the data link layer, the ethernet controller employs DM9000A, which is driven by its 10M/100M adaptive PHY and MAC functions to design procedures including initialization, packet transmission, packet reception, and the like.
As shown in fig. 10, fig. 10 shows a flow of the portal data processing in the control loop. The process mainly calls uip _ process () function to process the ethernet event, so as to realize the analysis and processing of the ethernet packet, the program processes through polling main control loop, creates two timers as the clocks of TCP and ARP respectively, then reads the ethernet packet read from DM9000A, and calls uip _ process () function to analyze the received data. The interface function between the protocol stack and the application layer is UIP _ APPCALL (), which is a callback function and passes different states and parameters to the application layer. Specifically, the internet access data processing comprises the following steps:
(101) judging whether the first entry is made; when entering for the first time, executing (102); otherwise, executing (104);
(102) creating a timer of 0.5S;
(103) creating a timer of 10S;
(104) receiving a network data packet from the network communication unit;
(105) judging whether the length of the received network data packet is greater than 0; when the length is greater than 0, executing (106); otherwise, executing (112);
(106) judging whether the received network data packet is an IP packet or not; when the network data packet is an IP packet, executing (107); otherwise, executing (108);
(107) performing IP unpacking processing and executing (110);
(108) judging whether the received network data packet is an ARP packet; when the network data packet is an ARP packet, executing (109);
(109) performing ARP unpacking processing and executing (110);
(110) judging whether a packet needs to be sent; when the package sending is needed, executing (111); otherwise, executing (113);
(111) packaging the uIP protocol stack;
(112) the network card is sent out, and the execution is returned (101);
(113) judging whether the 0.5S timer is overtime or not; when the 0.5S timer times out, executing (114); otherwise, executing (101);
(114) resetting the 0.5S timer;
(115) polling each TCP connection;
(116) judging whether a packet needs to be sent; when the package sending is needed, executing (117); otherwise, executing (119);
(117) packaging by adopting a uIP protocol stack;
(118) adopting a network card to send out a packet;
(119) judging whether the timer is overtime or not; when the 10S timer times out, executing (120); otherwise, executing (101);
(120) resetting the 10S timer;
(121) and updating the ARP cache table and returning to the execution (101).
Alternatively, the processing flow shown in fig. 11 may be employed for the reception of portal data. Specifically, the method comprises the following steps:
(201) clearing the length of the received data;
(202) reading memory data;
(203) calculating the position of the memory data;
(204) reading the data state;
(205) judging whether data is received or not; when data is received, execution 206; otherwise, performing (215);
(206) detecting the width of a data bus;
(207) judging whether the width of the data bus is 8 bits or not; when the data bus width is 8 bits, execute (208); otherwise, executing (216);
(208) reading the state of the data packet;
(209) reading the length of the data packet;
(210) calculating the storage position of the next data packet;
(211) reading data packet data;
(212) the packet length is reported to a TCP/IP upper layer;
(213) accumulating the packet receiving times;
(214) returning the length of the data packet, and ending;
(215) DM9000A software reset;
(216) and returning to 0 and ending.
The serial port transmission adopts the design of interrupt reception and DMA transmission, and a total of five serial ports are available for use. The interrupt is distributed to the serial ports 1-5, and the priority level is gradually reduced. After triggering the interrupt, the frame header is judged first, and then the data is received to the buffer area. And sending and matching DMA, and reducing the occupancy rate of the CPU.
The control unit is responsible for scheduling the three parts and realizing the mutual transmission and conversion of the network data and the serial port data.
As a typical application scenario of the data transmission method of the embodiment, when an upper computer, i.e. a common PC terminal, is used for communicating with an embedded serial device, the use steps are as follows:
and step 1, connecting and operating. The upper computer is connected with the data transmission device through a network cable, and the data transmission device is connected with the embedded equipment through a serial port; then the module program is automatically operated after being electrified.
And step 2, the upper computer refers to a protocol and fills communication configuration parameters of the serial port and the network through network assistant software.
And 3, sending and receiving data according to the communication protocol.
And 4, checking the sent and returned data on the interface of the upper computer.
In order to meet the requirements of resources and efficiency of the embedded system, the data transmission method provided by the embodiment adopts a design principle of lightweight, general and easy use, especially considers that the data transmission method is used in different systems and software environments in the future, has clear external interfaces and clear internal modules, and is convenient to transplant to different embedded environments.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.

Claims (10)

1. A data transmission apparatus, comprising:
the serial port communication unit is provided with at least one serial port;
a network port communication unit having at least one network port;
the control unit is respectively connected with the serial port communication unit and the network port communication unit; the control unit is used for converting first serial port data received by the at least one serial port into first internet access data and outputting the first internet access data from the at least one internet access; and the control unit is also used for converting the second network port data received by the at least one network port into second serial port data and outputting the second serial port data from the at least one serial port.
2. The apparatus of claim 1, wherein the serial communication unit comprises:
and the level conversion circuit is respectively connected with the at least one serial port and the control unit.
3. The apparatus according to claim 1 or 2, wherein the portal communication unit comprises:
the clock circuit is connected with the clock interface of the network card chip;
the network card chip is connected with the control unit;
and the Ethernet peripheral circuit is connected with the network card chip.
4. The apparatus of claim 1, wherein the control unit comprises:
the power supply circuit is used for supplying working power to the controller;
and the controller is respectively connected with the serial port communication unit and the network port communication unit.
5. A method of data transmission, comprising:
acquiring first serial port data from at least one serial port of a serial port communication unit, and/or acquiring second network port data from at least one network port of a network port communication unit;
and converting the first serial port data into first internet port data and outputting the first internet port data from the at least one internet port, and/or converting the second internet port data into second serial port data and outputting the second serial port data from the at least one serial port.
6. The method of claim 5, wherein converting the first serial data into first portal data is output from the at least one portal, comprising:
receiving the first serial port data from the at least one serial port in an interrupt mode;
analyzing the first serial port data according to a first preset protocol to obtain first internet port data;
and outputting the first internet access data through the at least one internet access.
7. The method of claim 6, wherein outputting the first portal data through the at least one portal comprises:
and outputting the first internet access data through the at least one internet access by using a uIP protocol stack.
8. The method according to any one of claims 5-7, wherein said converting the second portal data into second serial data for output from the at least one serial port comprises:
receiving the second internet access data from the at least one internet access by adopting a query mode;
analyzing the second internet access data according to a second preset protocol to obtain second serial port data;
and outputting the second serial port data through the at least one serial port.
9. The method of claim 8, wherein said receiving said second portal data from said at least one portal in a query manner comprises:
and receiving the second internet access data from the at least one internet access by using a uIP protocol stack in a query mode.
10. The method of claim 9, wherein outputting the second serial port data via the at least one serial port comprises:
and outputting the second serial port data through the at least one serial port in a direct memory access mode.
CN202010500054.XA 2020-06-04 2020-06-04 Data transmission device and method Pending CN111666238A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010500054.XA CN111666238A (en) 2020-06-04 2020-06-04 Data transmission device and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010500054.XA CN111666238A (en) 2020-06-04 2020-06-04 Data transmission device and method

Publications (1)

Publication Number Publication Date
CN111666238A true CN111666238A (en) 2020-09-15

Family

ID=72385868

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010500054.XA Pending CN111666238A (en) 2020-06-04 2020-06-04 Data transmission device and method

Country Status (1)

Country Link
CN (1) CN111666238A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114760364A (en) * 2022-04-02 2022-07-15 沈阳飞机设计研究所扬州协同创新研究院有限公司 Time-triggered serial device communication management method
CN115086104A (en) * 2022-06-23 2022-09-20 武汉迈威通信股份有限公司 Method for supporting data disconnection retransmission and serial server

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101141421A (en) * 2007-09-27 2008-03-12 苏州工业园区新大诚科技发展有限公司 Ethernet interface converter
CN201708810U (en) * 2010-06-01 2011-01-12 天津通广集团振通电子有限公司 Serial-to-Ethernet device
CN204229397U (en) * 2014-11-17 2015-03-25 广州智光电气股份有限公司 RS232 serial ports and ethernet interface converter
US20150341277A1 (en) * 2014-05-21 2015-11-26 Alain Gravel Single-lane, twenty-five gigabit ethernet

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101141421A (en) * 2007-09-27 2008-03-12 苏州工业园区新大诚科技发展有限公司 Ethernet interface converter
CN201708810U (en) * 2010-06-01 2011-01-12 天津通广集团振通电子有限公司 Serial-to-Ethernet device
US20150341277A1 (en) * 2014-05-21 2015-11-26 Alain Gravel Single-lane, twenty-five gigabit ethernet
CN204229397U (en) * 2014-11-17 2015-03-25 广州智光电气股份有限公司 RS232 serial ports and ethernet interface converter

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114760364A (en) * 2022-04-02 2022-07-15 沈阳飞机设计研究所扬州协同创新研究院有限公司 Time-triggered serial device communication management method
CN115086104A (en) * 2022-06-23 2022-09-20 武汉迈威通信股份有限公司 Method for supporting data disconnection retransmission and serial server
CN115086104B (en) * 2022-06-23 2023-11-21 武汉迈威通信股份有限公司 Method for supporting data disconnection retransmission and serial server

Similar Documents

Publication Publication Date Title
CN111656336B (en) PCIE sending and receiving method, device, equipment and system
CN114222009B (en) Industrial communication multi-protocol conversion system
CN101957808B (en) Communication method among various CPUs (Central Processing Units), system and CPU
CN110417780B (en) Multi-channel high-speed data interface conversion module of customized data transmission protocol
CN103095703B (en) A kind of method, equipment and system realizing network and serial port data interactive
CN201323598Y (en) Protocol converter for MODBUS/TCP and DeviceNet
CN111666238A (en) Data transmission device and method
CN108768667B (en) Method for inter-chip network communication of multi-core processor
CN102637453B (en) Phase change memory including serial input/output interface
CN106873541A (en) A kind of EtherCAT Distributed Servo kinetic control systems based on DSP
CN102291337B (en) Gateway for switching communication based on EtherCAT (Ethernet for Control and Automation Technology) protocol and Profibus-DP (Process Field Bus-Decentralized Periphery) protocol and communication method thereof
CN109062834B (en) DMA-based SPI communication method, electronic equipment, storage medium and device
CN110445585A (en) Based on PPP information frame framing and frame decoding hardware accelerator
CN108462620B (en) Gilbert-level SpaceWire bus system
CN111736867A (en) FPGA updating device, method and storage medium
CN103136163A (en) Protocol processor chip capable of allocating and achieving FC-AE-ASM and FC-AV protocol
CN206922798U (en) A kind of Multi-protocol converter, data transmitting equipment and communication system
CN115114202A (en) Embedded WEB server based on optical fiber communication interface extension
CN101383788B (en) FlexRay-RS485 communication gateway and implementing method
CN106603113A (en) Radar signal processor external communication control system
CN113625630B (en) Device for remote control of single-chip microcomputer operation by upper computer
CN201601690U (en) Input-output module based on EtherCAT technique
CN202206415U (en) Gateway for communication conversion between Ethernet CAT (Ethernet for Control and Automation Technology) protocol and Profibus-DP (Process Field Bus-Decentralized Periphery) protocol
CN111752705A (en) MCU cloud platform resource pooling system
CN112131169B (en) High speed data communication system and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100045 1-14-214, 2nd floor, 136 Xiwai street, Xicheng District, Beijing

Applicant after: Beijing Star glory Space Technology Co.,Ltd.

Applicant after: Beijing Star glory Technology Co.,Ltd.

Address before: 329, floor 3, building 1, No. 9, Desheng South Street, Daxing Economic and Technological Development Zone, Beijing 100176

Applicant before: BEIJING I-SPACE TECHNOLOGY Co.,Ltd.

Applicant before: Beijing Star glory Technology Co.,Ltd.

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20200915

RJ01 Rejection of invention patent application after publication