Double-output serial port device based on data encryption and communication method thereof

文档序号:649758 发布日期:2021-05-14 浏览:9次 中文

阅读说明:本技术 一种基于数据加密的双输出串口装置及其通讯方法 (Double-output serial port device based on data encryption and communication method thereof ) 是由 吕梓铭 李源 吴思炜 于 2020-12-11 设计创作,主要内容包括:本发明公开了一种基于数据加密的双输出串口装置及其通讯方法,所述基于数据加密的双输出串口装置包括串口传输模块和外部电路,串口传输模块包括计算机控制端、控制器和数据接收设备:计算机控制端通过通用总线连接控制器,用于向控制器发送数据和控制指令;数据接收设备设置于控制器上,用于接收计算机控制端传送的数据和控制指令;控制器通过输出引脚连接外部电路,用于处理接收到的数据和控制指令,并将处理后的数据发送给外部电路;外部电路连接终端设备,用于接收控制器传输的数据,并根据控制指令将一组输入数据转变为两组输出数据。本发明通过让串口在特定波特率下接收一次数据而输出两组数据,提高串口效率,减少芯片占用率。(The invention discloses a double-output serial port device based on data encryption and a communication method thereof, wherein the double-output serial port device based on data encryption comprises a serial port transmission module and an external circuit, the serial port transmission module comprises a computer control end, a controller and a data receiving device: the computer control end is connected with the controller through a universal bus and used for sending data and control instructions to the controller; the data receiving equipment is arranged on the controller and used for receiving data and control instructions transmitted by the computer control end; the controller is connected with an external circuit through an output pin and is used for processing received data and control instructions and sending the processed data to the external circuit; and the external circuit is connected with the terminal equipment and is used for receiving the data transmitted by the controller and converting one group of input data into two groups of output data according to the control instruction. The serial port receives one-time data at a specific baud rate to output two groups of data, so that the serial port efficiency is improved, and the chip occupancy rate is reduced.)

1. The utility model provides a dual output serial ports device based on data encryption which characterized in that, dual output serial ports device based on data encryption includes serial ports transmission module and external circuit, serial ports transmission module includes computer control end, controller and data receiving equipment:

the computer control end is connected with the controller through a universal bus and used for sending data and control instructions to the controller;

the data receiving equipment is arranged on the controller and used for receiving data and control instructions transmitted by the control end of the computer;

the controller is connected with an external circuit through an output pin and is used for processing received data and control instructions and sending the processed data to the external circuit;

and the external circuit is connected with the terminal equipment and is used for receiving the data transmitted by the controller and converting one group of input data into two groups of output data according to the control instruction.

2. The dual-output serial port device based on data encryption as claimed in claim 1, wherein said controller data output pin TX is connected to an AND gate AND1, AND is connected to an AND gate AND2 via a not gate; the output control pins are connected with an AND2 one by one AND an AND1 by a NOT gate.

3. The dual-output serial port device based on data encryption as claimed in claim 2, wherein the data is output separately through AND gates 1 AND AND gates 2 or alternatively after being combined.

4. The dual-output serial port device based on data encryption as claimed in claim 1, wherein said controller further comprises a control chip for processing data sent from the control terminal of the computer.

5. The dual-output serial port device based on data encryption as claimed in claim 4, wherein said controller further comprises an internal memory for storing data after being processed by the control chip.

6. The dual-output serial port device based on data encryption of claim 4, wherein the controller further comprises a data output device, and the data output device is provided with three operation modes:

and (3) a normal mode: outputting the received data completely;

double-output mode: changing the received data into two types of data to be output;

and (3) encryption mode: the received data is output in an encrypted manner.

7. The dual-output serial port device based on data encryption as claimed in claim 1, wherein the computer control terminal and the controller communicate with each other through a serial port.

8. A dual-output serial port communication method based on data encryption is characterized by comprising the following steps:

s1: the universal bus is used for connecting the computer and the controller, and sending data and outputting control instructions to the controller through the universal bus;

s2: configuring baud rate and serial port parameters when sending data;

s3: controlling the timer to interrupt to enable the switching of the output control pin to be in an idle bit transmitted between bytes;

s4: and processing the data transmitted by the controller through an external circuit, wherein when the control pin is at a low level, the output data is normal data, and when the control pin is at a high level, the output data is false data and the processed data is transmitted to the terminal equipment.

Technical Field

The invention relates to the field of computers, in particular to a double-output serial port device based on data encryption and a communication method thereof.

Background

Today, electronic technology is changing day by day, and various communication modes are coming up endlessly, such as: the serial port is still important as a stable and efficient universal bus with mature technology. The traditional serial port can only complete receiving data once and sending data once under a specific baud rate, the serial port efficiency is not high, and potential safety hazards exist in data transmission by utilizing the traditional serial port.

Disclosure of Invention

Therefore, the invention aims to solve the problems of low transmission efficiency and lack of safety of the traditional serial port device.

In order to achieve the above object, the present invention provides a dual-output serial port device based on data encryption and a communication method thereof, wherein the dual-output serial port device based on data encryption comprises a serial port transmission module and an external circuit, the serial port transmission module comprises a computer control terminal, a controller and a data receiving device:

the computer control end is connected with the controller through a universal bus and used for sending data and control instructions to the controller;

the data receiving equipment is arranged on the controller and used for receiving data and control instructions transmitted by the control end of the computer;

the controller is connected with an external circuit through an output pin and is used for processing received data and control instructions and sending the processed data to the external circuit;

and the external circuit is connected with the terminal equipment and is used for receiving the data transmitted by the controller and converting one group of input data into two groups of output data according to the control instruction.

One controller data output pin TX is connected with an AND gate AND1, AND the other controller data output pin TX is connected with an AND gate AND2 through a NOT gate; the output control pins are connected with an AND2 one by one AND an AND1 by a NOT gate.

The data is output through AND gates AND1 AND2 respectively or alternately after being combined.

The controller also comprises a control chip used for processing the data sent by the computer control end.

The controller also comprises an internal memory for storing data processed by the control chip.

The controller also comprises data output equipment, and the data output equipment is provided with three working modes:

and (3) a normal mode: outputting the received data completely;

double-output mode: changing the received data into two types of data to be output;

and (3) encryption mode: the received data is output in an encrypted manner.

And the computer control end is communicated with the controller through a serial port.

The dual-output serial port communication method based on data encryption comprises the following steps:

s1: the universal bus is used for connecting the computer and the controller, and sending data and outputting control instructions to the controller through the universal bus;

s2: configuring baud rate and serial port parameters when sending data;

s3: controlling the timer to interrupt to enable the switching of the output control pin to be in an idle bit between bytes;

s4: and processing the data transmitted by the controller through the external circuit, and sending the processed data to the terminal equipment.

The beneficial effect of this application:

(1) the invention can enable the serial port to receive data once at a specific baud rate and output two groups of data, thereby improving the efficiency of the serial port and reducing the occupancy rate of chips;

(2) the invention can encrypt and transmit data after the decryption condition is agreed.

Drawings

In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and for those skilled in the art, other drawings can be obtained according to the structures of the drawings without creative efforts.

FIG. 1 is a general block diagram of the present invention;

FIG. 2 is a schematic diagram of an interface according to the present invention;

the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.

Detailed Description

In order to more clearly understand the technical features, objects, and effects of the present invention, embodiments of the present invention will now be described with reference to the accompanying drawings.

As shown in fig. 1, in this embodiment, the present invention provides a dual-output serial port device based on data encryption and a communication method thereof, where the dual-output serial port device based on data encryption includes a serial port transmission module and an external circuit, and the serial port transmission module includes a computer control end, a controller, and a data receiving device:

the computer control end is connected with the controller through a universal bus and used for sending data and control instructions to the controller;

the data receiving equipment is arranged on the controller and used for receiving data and control instructions transmitted by the control end of the computer;

the controller is connected with an external circuit through an output pin and is used for processing received data and control instructions and sending the processed data to the external circuit;

and the external circuit is connected with the terminal equipment and is used for receiving the data transmitted by the controller and converting one group of input data into two groups of output data according to the control instruction.

It should be added that the computer control software needs to send correct data and control command to the controller, and the format of the control command, for example, 3C (00111100), affects the high and low level change of the control pin of the controller, so that the output 3 rd to 5 th bytes are dummy data. Bytes 1 to 2 and 7 to 8 are true data.

It should be noted that, as shown in fig. 2, the control chip needs to process the data received from the computer control end and cache the data in the internal memory; meanwhile, the interrupt time of the timer needs to be set, so that the holding time after the high and low levels of the output control pin are switched is in the idle time between two output bytes, and the error of output data is avoided. The computer-side application software and the controller communicate through a serial port, and a communication protocol between the computer-side application software and the controller needs to be defined as follows:

frame head: a communication protocol packet data start field;

output control (password): specifying a few bytes of output data as true;

the transmission length: the data length of the "send data" field;

and (3) sending data: data to be transmitted;

checking: for the check value of the data of the communication protocol data packet, the check method can be selected from sum check, CRC check and the like;

and (4) frame end: a communication protocol packet data end field;

the data to be forwarded is encapsulated into a communication data packet, the computer sends the communication data packet, and the controller forwards the forwarded data according to the field setting after receiving the communication data packet;

the output module is provided with three working modes, 1) a normal mode: directly and completely forwarding the received data transmitted by the computer end; 2) double-output mode: the received computer-side transmission data becomes two types of data output. 3) And (3) encryption mode: outputting the received data transmitted by the computer end in an encryption mode;

the working process of the serial port module is as follows:

a) configuring parameters:

baud rate and serial port corresponding parameters when data are transmitted need to be configured, so that the data are transmitted to an external circuit correctly;

b) matching a control pin:

the switching of the output control pin is in an idle position between bytes by controlling the interruption of the timer, so that the accuracy of the external circuit in outputting data is ensured.

One controller data output pin TX is connected with an AND gate AND1, AND the other controller data output pin TX is connected with an AND gate AND2 through a NOT gate; the output control pins are connected with an AND2 one by one AND an AND1 by a NOT gate.

The data is output through AND gates AND1 AND2 respectively or alternately after being combined.

The controller also comprises a control chip used for processing the data sent by the computer control end.

The controller also comprises an internal memory for storing data processed by the control chip.

The controller also comprises data output equipment, and the data output equipment is provided with three working modes:

and (3) a normal mode: outputting the received data completely;

double-output mode: changing the received data into two types of data to be output;

and (3) encryption mode: the received data is output in an encrypted manner.

And the computer control end is communicated with the controller through a serial port.

The dual-output serial port communication method based on data encryption comprises the following steps:

s1: the universal bus is used for connecting the computer and the controller, and sending data and outputting control instructions to the controller through the universal bus;

s2: configuring baud rate and serial port parameters when sending data;

s3: controlling the timer to interrupt to enable the switching of the output control pin to be in an idle bit between bytes;

s4: and processing the data transmitted by the controller through the external circuit, and sending the processed data to the terminal equipment.

Specifically, the idle state of the control pin is low level, the output is normal data, and when the idle state of the control pin is high level, the output is a value obtained after the inversion of the normal data, namely 255-normal data;

by switching the high and low levels of the control pin, a plurality of bytes can output normal data, a plurality of bytes can output negation data, and then correct data can be selected according to a decryption protocol;

the output position of the external circuit is slightly changed, and the purpose of outputting two kinds of data by inputting one data can be achieved.

The foregoing is illustrative of the preferred embodiments of this invention, and it is to be understood that the invention is not limited to the precise form disclosed herein and that various other combinations, modifications, and environments may be resorted to, falling within the scope of the concept as disclosed herein, either as described above or as apparent to those skilled in the relevant art. And that modifications and variations may be effected by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种调整NAND FLASH频率的方法及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!