CN112631824A - UART communication method and system based on ink-jet printer, electronic equipment and storage medium - Google Patents
UART communication method and system based on ink-jet printer, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN112631824A CN112631824A CN202011613514.6A CN202011613514A CN112631824A CN 112631824 A CN112631824 A CN 112631824A CN 202011613514 A CN202011613514 A CN 202011613514A CN 112631824 A CN112631824 A CN 112631824A
- Authority
- CN
- China
- Prior art keywords
- transmission
- check code
- packet
- crc check
- total
- 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
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/08—Error detection or correction by redundancy in data representation, e.g. by using checking codes
- G06F11/10—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
- G06F11/1004—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Communication Control (AREA)
- Accessory Devices And Overall Control Thereof (AREA)
Abstract
The invention discloses a UART communication method and system based on an ink-jet printer, electronic equipment and a storage medium, belonging to the technical field of communication, comprising the steps that a user sets control parameters of the ink-jet printer through a processing module, generates control data packets from the control parameters and generates a check code A; dividing the control data packet into a plurality of effective data segments, generating the effective data segments into a transmission packet, extracting the effective data segments in the transmission packet by the programming module, checking the effective data segments, and generating a check code X2(ii) a Checking code X2And check code X1Matching, storing all transmission packets by a programming module, and combining all the transmission packets into a total data packet; checking the total data packet to generate a total check code; and matching the total check code with the check code A, and finishing transmission if the total check code is consistent with the check code A. The invention avoids the condition that the transmitted data is not matched with the original data through the CRC check and the data retransmission mechanism, and improves the stability of the code spraying machine.
Description
Technical Field
The invention relates to the technical field of communication, in particular to a UART communication method and system based on an ink-jet printer, electronic equipment and a storage medium.
Background
The code spraying machine is a device which is controlled by software and used for carrying out identification on products in a non-contact mode. The principle is that the ink is deflected out of the normal flying route by the way of ink charged deflection and is shot to the surface of a work piece, and the position of each ink drop is controlled by the electric quantity charged to the ink drops, so that the data to be printed is formed. The product is marked by using the ink-jet printer in industry, and the ink-jet printer has the advantages of non-contact, high speed, wide application range, easy editing and modification and the like. With the gradual deepening of the identification technology in the industrial field, the code spraying machine is widely applied to various industries such as food, beverage, building materials, electric wires and cables, medicine, chemical engineering, electronics and the like.
However, when the inkjet printer uses the UART to transmit data, the data is easily subjected to external electromagnetic interference and is lost when the data is transmitted and received, so that the finally transmitted data is not matched with the original data. This situation can cause the entire code spraying system to be disabled.
Disclosure of Invention
Aiming at the defects existing in the problems, the invention provides a UART communication method and system based on an ink-jet printer, electronic equipment and a storage medium.
In order to achieve the above object, the present invention provides a UART communication method based on an inkjet printer, where the inkjet printer includes a processing module and a programming module, and the processing module is communicated with the programming module through a UART, including:
a user sets control parameters of the ink-jet printer through the processing module and generates control data packets according to the control parameters;
checking the control data packet to generate a CRC (cyclic redundancy check) code A;
dividing the control data packet into a plurality of effective data segments, generating a transmission packet from each effective data segment, wherein each transmission packet comprises a CRC (cyclic redundancy check) code X corresponding to the effective data segment1;
The processing module sends the transmission packet to the programming module through the UART, and the programming module extracts the effective data segment in the transmission packet and checks the effective data segment to generate a CRC (cyclic redundancy check) code X2;
The CRC check code X is used2And the CRC check code X1Matching, and if the transmission packets are consistent, storing the transmission packets; if not, the programming module notifies the instituteThe processing module retransmits;
the programming module stores all the transmission packets and combines all the transmission packets into a total data packet;
checking the total data packet to generate a total CRC check code;
matching the total CRC check code with the CRC check code A, and finishing transmission if the total CRC check code is consistent with the CRC check code A; and if the data transmission rate is not consistent with the transmission rate, the programming module informs the processing module of transmission failure.
Preferably, the dividing the control data packet into a plurality of valid data segments and generating a transmission packet from each of the valid data segments includes:
dividing the control data packet into a plurality of effective data segments according to each 128Bit, and coding the effective data segments;
checking each effective data segment, and generating a CRC check code X for each effective data segment1;
Adding a header, a trailer, a data length, the code and the CRC check code X to the effective data segment1And filling data, finishing the packaging process and generating a transmission packet.
Preferably, the processing module sends the transmission packet to the programming module through the UART, and includes:
setting a transmission time length threshold value of the transmission packet;
the processing module transmits the transmission packet to the programming module, if the programming module does not accept the transmission packet when the threshold value is exceeded, the transmission fails, and the programming module notifies the processing module of the transmission failure.
Preferably, said combining all said transport packets into a total data packet comprises:
and extracting the codes in the transmission packets, and splicing and combining the codes according to the transmission packets to form the total data packet.
Preferably, the programming module notifies the processing module of a transmission failure and the programming module discards the total data packet.
The UART communication system based on the ink-jet printer provided by the embodiment of the invention is used for realizing the method, and comprises the following steps:
a processing module, configured to set a control parameter of the inkjet printer, generate a control data packet from the control parameter, check the control data packet to generate a CRC check code a, divide the control data packet into multiple effective data segments, and generate a transmission packet from each effective data segment, where each transmission packet includes a CRC check code X corresponding to the effective data segment1;
The UART is used for sending the transmission packet to a programming module by the processing module;
a programming module for extracting the effective data segment in the transmission packet and checking to generate a CRC check code X2The CRC check code X is used2And the CRC check code X1Matching, and if the transmission packets are consistent, storing the transmission packets; if not, the programming module informs the processing module to resend the message; the programming module stores all the transmission packets and combines all the transmission packets into a total data packet; checking the total data packet to generate a total CRC check code; matching the total CRC check code with the CRC check code A, and finishing transmission if the total CRC check code is consistent with the CRC check code A; and if the data transmission rate is not consistent with the transmission rate, the programming module informs the processing module of transmission failure.
An embodiment of the present invention provides an electronic device, which includes at least one processing unit and at least one storage unit, where the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit is caused to execute the method described above.
A storage medium storing a computer program executable by an electronic device according to an embodiment of the present invention is configured to, when the program runs on the electronic device, cause the electronic device to execute the method described above.
Compared with the prior art, the invention has the beneficial effects that:
according to the invention, the control parameters are generated into the control data packet, the control data packet is divided into a plurality of transmission packets, each transmission packet is subjected to CRC (cyclic redundancy check), all the plurality of transmission packets are combined into a total data packet after transmission is finished, and CRC check codes of the total data packet and a binary data packet are matched, namely double verification matching is carried out through the transmission process, so that the data in the data transmission process are kept consistent; in addition, if the data are not matched, the data are retransmitted, so that the error of data transmission is further avoided, and the system stability is improved.
Drawings
Fig. 1 is a structural diagram of a UART communication system based on an inkjet printer in the present invention;
fig. 2 is a flowchart of a UART communication method based on an inkjet printer in the present invention.
Reference numerals:
1. a processing module; 2. a programming module; 3. a UART.
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 obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should also be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
Referring to fig. 1-2, the present invention provides an inkjet printer-based UART3 communication system, including:
a processing module 1, configured to set a control parameter of the inkjet printer, generate a control data packet from the control parameter, check the control data packet to generate a CRC check code a, divide the control data packet into multiple valid data segments, and generate a transmission packet from each valid data segment, where each transmission packet includes a CRC check code X corresponding to the valid data segment1;
Specifically, the control data packet is divided into a plurality of effective data segments per 128 bits, and the effective data segments are encoded;
checking each effective data segment, and generating a CRC check code X for each effective data segment1;
Adding a header, a tail, a data length, a code and a CRC check code X to the effective data section1And filling data, finishing the packaging process and generating a transmission packet.
UART3, for processing module 1 to send the transmission packet to programming module 2;
specifically, a transmission duration threshold of a transmission packet is set;
the processing module 1 transmits the transmission packet to the programming module 2, and if the programming module 2 does not accept the transmission packet when the threshold value is exceeded, the transmission fails, and the programming module 2 notifies the processing module 1 of the transmission failure.
A programming module 2 for extracting the effective data segment in the transmission packet and checking to generate a CRC check code X2Will beCRC check code X2And CRC check code X1Matching, and if the matching is consistent, storing the transmission packet; if the two signals are not consistent, the programming module 2 informs the processing module 1 to resend the signals; the programming module 2 stores all the transmission packets and combines all the transmission packets into a total data packet; checking the total data packet to generate a total CRC check code; matching the total CRC check code with the CRC check code A, and finishing transmission if the total CRC check code is consistent with the CRC check code A; if not, the programming module 2 notifies the processing module 1 that the transmission fails.
Specifically, combining all transport packets into a total data packet includes:
and extracting codes in the transmission packets, and splicing and combining the codes according to the codes of the transmission packets to form a total data packet.
Programming module 2 notifies processing module 1 of the transmission failure and programming module 2 discards the total packet.
Referring to fig. 2, the invention further provides a UART3 communication method based on an inkjet printer, which includes
A user sets control parameters of the ink-jet printer through the processing module 1 and generates control data packets according to the control parameters;
checking the control data packet to generate a CRC (cyclic redundancy check) code A;
dividing the control data packet into a plurality of effective data segments, and generating a transmission packet from each effective data segment, wherein each transmission packet comprises a CRC (cyclic redundancy check) code X corresponding to the effective data segment1;
Specifically, the control data packet is divided into a plurality of effective data segments per 128 bits, and the effective data segments are encoded;
checking each effective data segment, and generating a CRC check code X for each effective data segment1;
Adding a header, a tail, a data length, a code and a CRC check code X to the effective data section1And filling data, finishing the packaging process and generating a transmission packet.
The processing module 1 sends the transmission packet to the programming module 2 through the UART3, the programming module 2 extracts the effective data segment in the transmission packet and checks the effective data segment to generate a CRC check code X2;
Specifically, a transmission duration threshold of a transmission packet is set;
the processing module 1 transmits the transmission packet to the programming module 2, and if the programming module 2 does not accept the transmission packet when the threshold value is exceeded, the transmission fails, and the programming module 2 notifies the processing module 1 of the transmission failure.
Checking CRC code X2And CRC check code X1Matching, and if the matching is consistent, storing the transmission packet; if the two signals are not consistent, the programming module 2 informs the processing module 1 to resend the signals;
the programming module 2 stores all the transmission packets and combines all the transmission packets into a total data packet;
specifically, codes in the transmission packets are extracted, and the transmission packets are spliced and combined into the total data packet according to the codes of the transmission packets.
Checking the total data packet to generate a total CRC check code;
matching the total CRC check code with the CRC check code A, and finishing transmission if the total CRC check code is consistent with the CRC check code A; if not, the programming module 2 notifies the processing module 1 of the transmission failure, and the programming module 2 discards the total data packet.
The present embodiment also provides an electronic device, which includes at least one processing unit and at least one storage unit, where the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit is enabled to execute the method.
The present embodiment also provides a storage medium storing a computer program executable by an electronic device, which, when the program is run on the electronic device, causes the electronic device to perform the above-mentioned method.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes will occur to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (8)
1. A UART communication method based on an ink-jet printer, wherein the ink-jet printer comprises a processing module and a programming module, the processing module is communicated with the programming module through UART, and the UART communication method is characterized by comprising the following steps:
a user sets control parameters of the ink-jet printer through the processing module and generates control data packets according to the control parameters;
checking the control data packet to generate a CRC (cyclic redundancy check) code A;
dividing the control data packet into a plurality of effective data segments, generating a transmission packet from each effective data segment, wherein each transmission packet comprises a CRC (cyclic redundancy check) code X corresponding to the effective data segment1;
The processing module sends the transmission packet to the programming module through the UART, and the programming module extracts the effective data segment in the transmission packet and checks the effective data segment to generate a CRC (cyclic redundancy check) code X2;
The CRC check code X is used2And the CRC check code X1Matching, and if the transmission packets are consistent, storing the transmission packets; if not, the programming module informs the processing module to resend the message;
the programming module stores all the transmission packets and combines all the transmission packets into a total data packet;
checking the total data packet to generate a total CRC check code;
matching the total CRC check code with the CRC check code A, and finishing transmission if the total CRC check code is consistent with the CRC check code A; and if the data transmission rate is not consistent with the transmission rate, the programming module informs the processing module of transmission failure.
2. The UART communication method based on the inkjet printer of claim 1, wherein the dividing the control data packet into a plurality of valid data segments and generating a transmission packet from each valid data segment comprises:
dividing the control data packet into a plurality of effective data segments according to each 128Bit, and coding the effective data segments;
checking each effective data segment, and generating a CR for each effective data segmentC check code X1;
Adding a header, a trailer, a data length, the code and the CRC check code X to the effective data segment1And filling data, finishing the packaging process and generating a transmission packet.
3. The inkjet printer-based UART communication method of claim 1, wherein the processing module sends the transmission packet to the programming module through the UART, comprising:
setting a transmission time length threshold value of the transmission packet;
the processing module transmits the transmission packet to the programming module, if the programming module does not accept the transmission packet when the threshold value is exceeded, the transmission fails, and the programming module notifies the processing module of the transmission failure.
4. The inkjet printer based UART communication method of claim 2, wherein the combining all of the transport packets into a total data packet comprises:
and extracting the codes in the transmission packets, and splicing and combining the codes according to the transmission packets to form the total data packet.
5. The inkjet printer based UART communication method of claim 1, wherein the programming module notifies the processing module of a transmission failure and the programming module drops the total data packet.
6. An UART communication system based on an inkjet printer, which is used for realizing the method of any one of claims 1-5, and comprises:
a processing module, configured to set a control parameter of the inkjet printer, generate a control data packet from the control parameter, check the control data packet to generate a CRC check code a, divide the control data packet into multiple valid data segments, generate a transmission packet from each valid data segment, and generate a transmission packet from each transmission packetIncluding a CRC check code X corresponding to the valid data segment1;
The UART is used for sending the transmission packet to a programming module by the processing module;
a programming module for extracting the effective data segment in the transmission packet and checking to generate a CRC check code X2The CRC check code X is used2And the CRC check code X1Matching, and if the transmission packets are consistent, storing the transmission packets; if not, the programming module informs the processing module to resend the message; the programming module stores all the transmission packets and combines all the transmission packets into a total data packet; checking the total data packet to generate a total CRC check code; matching the total CRC check code with the CRC check code A, and finishing transmission if the total CRC check code is consistent with the CRC check code A; and if the data transmission rate is not consistent with the transmission rate, the programming module informs the processing module of transmission failure.
7. An electronic device, comprising at least one processing unit and at least one memory unit, wherein the memory unit stores a computer program that, when executed by the processing unit, causes the processing unit to perform the method of any of claims 1 to 5.
8. A storage medium storing a computer program executable by an electronic device, the program, when run on the electronic device, causing the electronic device to perform the method of any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011613514.6A CN112631824A (en) | 2020-12-30 | 2020-12-30 | UART communication method and system based on ink-jet printer, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011613514.6A CN112631824A (en) | 2020-12-30 | 2020-12-30 | UART communication method and system based on ink-jet printer, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112631824A true CN112631824A (en) | 2021-04-09 |
Family
ID=75286987
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011613514.6A Pending CN112631824A (en) | 2020-12-30 | 2020-12-30 | UART communication method and system based on ink-jet printer, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112631824A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102079167A (en) * | 2010-11-01 | 2011-06-01 | 天津伟力捷包装设备有限公司 | Ink jet printer circuit with remote control function |
CN110561911A (en) * | 2019-09-05 | 2019-12-13 | 福州三龙喷码科技有限公司 | High-resolution ink jet printer system based on embedded Linux |
CN110838893A (en) * | 2019-11-26 | 2020-02-25 | 北华航天工业学院 | Communication system based on Beidou system and communication method thereof |
CN111813425A (en) * | 2019-04-12 | 2020-10-23 | 顺丰科技有限公司 | Equipment upgrading method, device, equipment and storage medium |
CN112558875A (en) * | 2020-12-14 | 2021-03-26 | 北京百度网讯科技有限公司 | Data verification method and device, electronic equipment and storage medium |
CN215665312U (en) * | 2021-01-14 | 2022-01-28 | 广州松禾科技有限公司 | Special-shaped cigarette line small order sorting and coding system and coding machine |
-
2020
- 2020-12-30 CN CN202011613514.6A patent/CN112631824A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102079167A (en) * | 2010-11-01 | 2011-06-01 | 天津伟力捷包装设备有限公司 | Ink jet printer circuit with remote control function |
CN111813425A (en) * | 2019-04-12 | 2020-10-23 | 顺丰科技有限公司 | Equipment upgrading method, device, equipment and storage medium |
CN110561911A (en) * | 2019-09-05 | 2019-12-13 | 福州三龙喷码科技有限公司 | High-resolution ink jet printer system based on embedded Linux |
CN110838893A (en) * | 2019-11-26 | 2020-02-25 | 北华航天工业学院 | Communication system based on Beidou system and communication method thereof |
CN112558875A (en) * | 2020-12-14 | 2021-03-26 | 北京百度网讯科技有限公司 | Data verification method and device, electronic equipment and storage medium |
CN215665312U (en) * | 2021-01-14 | 2022-01-28 | 广州松禾科技有限公司 | Special-shaped cigarette line small order sorting and coding system and coding machine |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103201976A (en) | Packet-level erasure protection coding in aggregated packet transmissions | |
CN101800757A (en) | No-feedback one-way data transmission method based on single fiber structure | |
JP4984774B2 (en) | RF tag reader and retransmission control method | |
CN105398224A (en) | Ink cartridge chip, ink cartridge, printer and ink cartridge authentication method | |
US20100192048A1 (en) | Transmitting apparatus and communication system | |
CN103825905A (en) | Method and device for multimedia data exchange | |
CN106911428A (en) | The transmission method and device of information | |
US9113470B2 (en) | Systems and methods for network coding using maximum distance separable (MDS) linear network codes | |
CN107835066A (en) | A kind of RSSP I safety communicating methods | |
CN109743337B (en) | TCP protocol-based download communication method in nuclear security level DCS system | |
CN112631824A (en) | UART communication method and system based on ink-jet printer, electronic equipment and storage medium | |
US10142058B2 (en) | Communication device and communication method | |
CN112667432A (en) | SPI communication method and system based on ink jet printer, electronic equipment and storage medium | |
CN104704512A (en) | Data communication in printing device | |
US7676723B2 (en) | Method for the protected transmission of data, particularly transmission over an air interface | |
CN108984136B (en) | Printing data transmission method, device, equipment and storage medium | |
CN110113100B (en) | Visible light communication device and method for Ethernet data transmission | |
KR100859499B1 (en) | Data transmitting/receiving method and communication system thereof | |
CN111246428A (en) | Network reliable communication method, system, device and storage medium | |
US10237018B2 (en) | Communication device and communication method | |
CN113098746B (en) | CAN bus communication method and device for work machine | |
CN103346961B (en) | The method and system that a kind of data packing is exchanged | |
CN115361236A (en) | Data transmission consistency checking method, device, equipment and medium | |
CN107609443A (en) | A kind of method of raising RFID radio frequency identification rates | |
CN109660320B (en) | Network end-to-end error control transmission method and device and electronic equipment |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210409 |