CN111352882A - Serial port shunting device - Google Patents
Serial port shunting device Download PDFInfo
- Publication number
- CN111352882A CN111352882A CN202010124068.6A CN202010124068A CN111352882A CN 111352882 A CN111352882 A CN 111352882A CN 202010124068 A CN202010124068 A CN 202010124068A CN 111352882 A CN111352882 A CN 111352882A
- Authority
- CN
- China
- Prior art keywords
- serial port
- data
- serial
- command
- cache region
- 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
Links
- 239000000872 buffer Substances 0.000 claims description 26
- 238000004891 communication Methods 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 238000000034 method Methods 0.000 description 3
- 238000013480 data collection Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/40—Bus structure
- G06F13/4004—Coupling between buses
- G06F13/4027—Coupling between buses using bus bridges
- G06F13/4031—Coupling between buses using bus bridges with arbitration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/14—Handling requests for interconnection or transfer
- G06F13/20—Handling requests for interconnection or transfer for access to input/output bus
- G06F13/32—Handling requests for interconnection or transfer for access to input/output bus using combination of interrupt and burst mode transfer
- G06F13/34—Handling requests for interconnection or transfer for access to input/output bus using combination of interrupt and burst mode transfer with priority control
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a serial port shunting device, which comprises a central processing unit module, a command caching module, a data caching module, a power supply module, a serial interface module and an internal bus for connecting the modules, wherein the serial interface module comprises a first serial port, a second serial port and an instrument serial port; the serial port shunting device also comprises an interrupt priority register used for setting serial port interrupt priority and an interrupt processing program; the command cache module comprises a first command cache region and a second command cache region; the data cache module comprises a first data cache region used for storing data sent through the first serial port and a second data cache region used for storing data sent through the second serial port. The invention can realize that two hosts simultaneously send commands and receive data to the slave machines on the same serial bus. The invention belongs to the technical field of data acquisition equipment.
Description
Technical Field
The invention relates to the technical field of data acquisition equipment, in particular to a serial port shunting device for data acquisition.
Background
MODBUS serial link protocol is an industry standard for industrial field serial communication protocols and is supported by most industrial electronic devices. The MODBUS serial link protocol is a master/slave protocol, only one host is allowed to be connected to the serial bus at the same time, one or more slaves are connected to the same serial bus, and MODBUS communication is always initiated by the host, and the slaves do not send data when not receiving a request from the host. In the actual data collection process, there is often a need for both masters to send commands and receive data to the slaves on the serial bus. However, if there are two hosts in the MODBUS communication network, and the two hosts simultaneously send commands to the serial bus respectively, the bus contention is easily caused, and the two commands are easily caused to form a messy code, thereby affecting the normal data acquisition work.
Disclosure of Invention
In view of the above-mentioned drawbacks in the prior art, an object of the present invention is to provide a serial port shunting device capable of simultaneously sending commands to and receiving data from slaves on the same serial bus by two masters.
In order to achieve the purpose, the invention adopts the following technical scheme:
a serial port shunting device is used for two hosts to simultaneously request data from an instrument on the same serial bus, wherein the two hosts are respectively a first host and a second host, the serial port shunting module comprises a central processing unit module, a command cache module, a data cache module, a power supply module, a serial interface module and internal buses for connecting the modules, and the serial interface module comprises a first serial port for connecting the first host, a second serial port for connecting the second host and an instrument serial port for connecting the serial bus where the instrument is located; the serial port shunting device also comprises an interrupt priority register used for setting serial port interrupt priority and an interrupt processing program; the command cache module comprises a first command cache region used for storing commands received by the first serial port and a second command cache region used for storing commands received by the second serial port; the data cache module comprises a first data cache region used for storing data sent through the first serial port and a second data cache region used for storing data sent through the second serial port.
Further, the interrupt processing program of the first serial port includes the following processing steps: (1) sending the data request command in the first command cache region to the serial bus for data request; (2) receiving data returned by the instrument according to the command to the first data cache region; (3) and sending the data in the first data cache region to the first host.
Further, the interrupt processing program of the second serial port includes the following processing steps: (1) sending the data request command in the second command cache region to the serial bus for data request; (2) receiving data returned by the instrument according to the command to the second data cache region; (3) and sending the data in the second data cache region to the second host.
Further, the serial port interrupt priority of the first serial port is higher than the serial port interrupt priority of the second serial port.
Further, the first serial port and the second serial port are selected from one of an RS-485 interface and an RS-232 interface.
Further, the data in the first data buffer is sent to the first host through the first port in a DMA manner.
Further, the data in the second data cache region is sent to the second host through the second serial port in a DMA manner.
Further, the serial bus is a 485 serial bus or a 232 serial bus.
Further, the first command buffer area and the second command buffer area are both FIFO buffer areas.
Further, the first data buffer area and the second data buffer area are both FIFO buffer areas.
The invention has the outstanding effects that: the two hosts can simultaneously send commands and receive data to the slave machines on the same serial bus; bus competition is not easy to cause, and communication can be kept smooth; the data transmission mode of DMA reduces the data transmission time and the pressure of the central processing unit module.
Drawings
Fig. 1 is a schematic structural diagram of an embodiment of the present invention.
Detailed Description
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 only a part of the embodiments of the present invention, and not all of the embodiments.
Examples
As shown in fig. 1, the serial port shunting device of this embodiment is used for two hosts to request data to an instrument located on the same serial bus at the same time, and for convenience of description, the two hosts are respectively called a first host and a second host, the serial port shunting module includes a central processing unit module, a command buffer module, a data buffer module, a power supply module, and a serial interface module, and each of the above modules is connected through an internal bus. The first host and the second host can be a DTU, an industrial personal computer, a PLC, a server and the like, and the serial bus can be a 485 serial bus or a 232 serial bus. The serial interface module comprises a first serial port used for being connected with the first host, a second serial port used for being connected with the second host and an instrument serial port used for being connected with a serial bus where the instrument is located. Preferably, the first serial port, the second serial port and the instrument serial port are selected from RS-485 interfaces or RS-232 interfaces. In this embodiment, the serial port interrupt priority of the first serial port is higher than the serial port interrupt priority of the second serial port (equivalently, the serial port interrupt priority of the first serial port may also be lower than the serial port interrupt priority of the second serial port). The command cache module comprises a first command cache region and a second command cache region, the first command cache region is used for storing commands received by the first serial port, the second command cache region is used for storing commands received by the second serial port, the commands received by the first command cache region are sent by the first host, and the commands received by the second command cache region are sent by the second host. The data cache module comprises a first data cache region and a second data cache region, the first data cache region is used for storing data sent by the first serial port, the second data cache region is used for storing data sent by the second serial port, the data stored in the first data cache region is meter data returned by the meter according to a command sent by the first host, and the data stored in the second data cache region is meter data returned by the meter according to a command sent by the second host. Preferably, the first command buffer and the second command buffer are both FIFO buffers (first-in first-out storage), and the first data buffer and the second data buffer are also FIFO buffers (first-in first-out storage).
In the interrupt priority register, the interrupt processing program of the first serial port includes the following processing steps: (1) sending the data request command in the first command cache region to the serial bus to request data of a relevant instrument; (2) receiving data returned by the instrument according to the command to the first data cache region; (3) and sending the data in the first data cache region to the first host. The interrupt processing program of the second serial port comprises the following processing steps: (1) sending the data request command in the second command cache region to the serial bus to request data of a relevant instrument; (2) and receiving data returned by the meter according to the command to the second data cache region (3) and sending the data in the second data cache region to the second host. Preferably, the data in the first data buffer area is sent to the first host through the first serial port in a DMA manner, and the data in the second data buffer area is also sent to the second host through the second serial port in a DMA manner, so that the data transmission time is reduced and the pressure of the central processor module is relieved by adopting a DMA data transmission manner.
In the main application data acquisition process of the serial port shunting device, in the actual use process, the first serial port is connected to the first host, the second serial port is connected to the second host, and the instrument serial port is connected to the serial bus where the instrument is located. When the first host sends a command to the first command cache region through the first serial port, triggering an interrupt processing program of the first serial port in the interrupt priority register: (1) sending the command in the first command cache region to the serial bus through the instrument serial port and making a data request for a relevant instrument; (2) receiving data returned by the instrument according to the command to the first data cache region; (3) and the data in the first data cache region is transmitted to the first host computer in a DMA mode, and when the execution of the interrupt processing program of the first serial port is finished, the serial port shunting device continues to execute the interrupted program. And after the second host sends a command and transmits the command to the second command cache region through the second serial port, triggering an interrupt processing program of the second serial port in the interrupt priority register (no longer described in detail). When the first host and the second host respectively send an instruction to the serial port shunting device at the same time, according to the serial port interrupt priority set in the interrupt priority register: the serial port interrupt priority of the first serial port is higher than that of the second serial port, the CPU module preferentially executes the interrupt processing program of the first serial port, and executes the interrupt processing program of the second serial port after the interrupt processing program of the first serial port is executed, so that two hosts can simultaneously send commands and receive data to slave machines on the same serial bus, bus competition is not easy to cause, and communication can be kept smooth.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art should be considered to be within the technical scope of the present invention, and the technical solutions and the inventive concepts thereof according to the present invention should be equivalent or changed within the scope of the present invention.
Claims (10)
1. The utility model provides a serial ports diverging device for two hosts are simultaneously to being located the instrument request data on same serial bus, two hosts be first host computer and second host computer respectively, serial ports diverging module includes central processing unit module, order buffer memory module, data buffer memory module, power module, serial interface module to and be used for connecting the internal bus of above-mentioned each module, its characterized in that:
the serial interface module comprises a first serial port used for connecting the first host, a second serial port used for connecting the second host and an instrument serial port used for connecting a serial bus where the instrument is located; the serial port shunting device also comprises an interrupt priority register used for setting serial port interrupt priority and an interrupt processing program; the command cache module comprises a first command cache region used for storing commands received by the first serial port and a second command cache region used for storing commands received by the second serial port; the data cache module comprises a first data cache region used for storing data sent through the first serial port and a second data cache region used for storing data sent through the second serial port.
2. The serial port shunting device according to claim 1, wherein the interrupt processing program of the first serial port includes the following processing steps: (1) sending the data request command in the first command cache region to the serial bus for data request; (2) receiving data returned by the instrument according to the command to the first data cache region; (3) and sending the data in the first data cache region to the first host.
3. The serial port shunting device according to claim 1 or 2, wherein the interrupt processing program of the second serial port includes the following processing steps: (1) sending the data request command in the second command cache region to the serial bus for data request; (2) receiving data returned by the instrument according to the command to the second data cache region; (3) and sending the data in the second data cache region to the second host.
4. The serial port shunting device according to claim 1, characterized in that: the serial port interrupt priority of the first serial port is higher than that of the second serial port.
5. The serial port shunting device according to claim 1, characterized in that: the first serial port and the second serial port are selected from one of an RS-485 interface and an RS-232 interface.
6. The serial port shunting device according to claim 2, characterized in that: and the data in the first data buffer area is sent to the first host through the first serial port in a DMA mode.
7. The serial port shunting device according to claim 3, characterized in that: and the data in the second data cache region is sent to the second host computer through the second serial port in a DMA mode.
8. The serial port shunting device according to claim 1, characterized in that: the serial bus is a 485 serial bus or a 232 serial bus.
9. The serial port shunting device according to claim 1, characterized in that: the first command buffer area and the second command buffer area are both FIFO buffer areas.
10. The serial port shunting device according to claim 1 or 9, wherein: the first data buffer area and the second data buffer area are both FIFO buffer areas.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010124068.6A CN111352882A (en) | 2020-02-27 | 2020-02-27 | Serial port shunting device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010124068.6A CN111352882A (en) | 2020-02-27 | 2020-02-27 | Serial port shunting device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111352882A true CN111352882A (en) | 2020-06-30 |
Family
ID=71194115
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010124068.6A Pending CN111352882A (en) | 2020-02-27 | 2020-02-27 | Serial port shunting device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111352882A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1584860A (en) * | 2003-08-20 | 2005-02-23 | 松下电器产业株式会社 | Command providing and controlling device and semiconductor device |
CN101034381A (en) * | 2006-03-08 | 2007-09-12 | 松下电器产业株式会社 | Multi-master system and data transfer system |
CN101136828A (en) * | 2007-09-27 | 2008-03-05 | 广州市聚晖电子科技有限公司 | RS485 based multi-host machine wired serial communication method |
CN108733604A (en) * | 2018-05-11 | 2018-11-02 | 深圳市脉联电子有限公司 | A kind of 485 bus intelligent expansion method and devices based on modbus communications protocol |
CN109067630A (en) * | 2018-10-16 | 2018-12-21 | 苏州琅润达检测科技有限公司 | A kind of serial data communication link branch cooperative control device |
-
2020
- 2020-02-27 CN CN202010124068.6A patent/CN111352882A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1584860A (en) * | 2003-08-20 | 2005-02-23 | 松下电器产业株式会社 | Command providing and controlling device and semiconductor device |
CN101034381A (en) * | 2006-03-08 | 2007-09-12 | 松下电器产业株式会社 | Multi-master system and data transfer system |
CN101136828A (en) * | 2007-09-27 | 2008-03-05 | 广州市聚晖电子科技有限公司 | RS485 based multi-host machine wired serial communication method |
CN108733604A (en) * | 2018-05-11 | 2018-11-02 | 深圳市脉联电子有限公司 | A kind of 485 bus intelligent expansion method and devices based on modbus communications protocol |
CN109067630A (en) * | 2018-10-16 | 2018-12-21 | 苏州琅润达检测科技有限公司 | A kind of serial data communication link branch cooperative control device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN202870808U (en) | FPGA realization device of SPI serial port module | |
CN103714029B (en) | Novel two-line synchronous communication protocol and application | |
EP3110077B1 (en) | Protocol converter and conversion method of cpci bus and isa bus | |
CN104021102B (en) | CPCI serial port plate based on state machine and on-chip bus and working method of CPCI serial port plate | |
CN102495920B (en) | Integrated logic analysis module based on PCIe (peripheral component interconnection express) for FPGA (field programmable gate array) | |
CN102354305A (en) | Serial communication system between devices and method | |
CN103218337B (en) | Based on wishbone bus realize main and master and slave with from the SOC (system on a chip) communicated and method | |
CN109800193B (en) | Bridging device of SRAM on AHB bus access chip | |
CN102841869B (en) | Multi-channel I2C controller based on FPGA | |
CN107562672A (en) | A kind of system and method for improving vector network analyzer message transmission rate | |
CN104714907B (en) | A kind of pci bus is converted to ISA and APB bus design methods | |
CN110188059A (en) | The flow control type FIFO buffer structure and method of the unified configuration of data valid bit | |
CN101937413A (en) | Communication method of I2C bus | |
CN107066413A (en) | A kind of method and its bus system for being used to handle multiple bus apparatus data | |
CN107127811A (en) | Flexible material cutting robot intelligent digital controller and implementation method | |
CN210155653U (en) | Device for realizing M-LVDS bus data interaction based on ZYNQ chip | |
CN111352882A (en) | Serial port shunting device | |
CN1969268B (en) | Host controller, bus communication device and method for operating the host controller | |
CN111444124A (en) | Serial port shunting device with high-frequency autonomous request | |
CN111008169A (en) | Low-cost high-speed communication bus and transmission control method thereof | |
CN206003081U (en) | A kind of synchronous serial interface association of industrial computer processes managing device and industrial computer | |
CN111177048A (en) | AHB bus equipment and data stream transmission method thereof | |
CN209017081U (en) | A kind of high-precise synchronization information processing system based on Power PC Processor | |
CN111324559A (en) | Serial port shunting device with independent request | |
CN201465098U (en) | Multi-channel crossed DMA |
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 | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20200630 |
|
WD01 | Invention patent application deemed withdrawn after publication |