CN107423654B - Method for receiving bar code with indefinite length - Google Patents
Method for receiving bar code with indefinite length Download PDFInfo
- Publication number
- CN107423654B CN107423654B CN201710685033.8A CN201710685033A CN107423654B CN 107423654 B CN107423654 B CN 107423654B CN 201710685033 A CN201710685033 A CN 201710685033A CN 107423654 B CN107423654 B CN 107423654B
- Authority
- CN
- China
- Prior art keywords
- receiving
- asynchronous thread
- bar code
- information code
- code
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/14—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
- G06K7/1404—Methods for optical code recognition
- G06K7/1408—Methods for optical code recognition the method being specifically adapted for the type of code
- G06K7/1413—1D bar codes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K7/00—Methods or arrangements for sensing record carriers, e.g. for reading patterns
- G06K7/10—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
- G06K7/10544—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation by scanning of the records by radiation in the optical part of the electromagnetic spectrum
- G06K7/10821—Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation by scanning of the records by radiation in the optical part of the electromagnetic spectrum further details of bar or optical code scanning devices
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Electromagnetism (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Toxicology (AREA)
- Artificial Intelligence (AREA)
- Computer Vision & Pattern Recognition (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Communication Control (AREA)
Abstract
The invention belongs to the technical field of electronic product software, and discloses a method for receiving a bar code with an indefinite length, which is compatible with receiving bar codes with indefinite lengths and different end characters. The method comprises the following steps: a. after receiving a first information code of a bar code with an indefinite length, a receiving end creates an asynchronous thread started in a delayed way, wherein the asynchronous thread is used for executing the checking and storing operation of the bar code; b. when the receiving end receives the information code again, judging whether an asynchronous thread started in a delayed mode exists at present, if so, closing the thread, and then executing the step c, otherwise, directly entering the step c; c. combining the information code received this time with the information code received before, and creating a new asynchronous thread started in a delayed manner; d. and repeating the steps b and c until the delay time of the asynchronous thread started by the delay is exceeded, and executing the checking and storing operation of the bar codes by the asynchronous thread.
Description
Technical Field
The invention belongs to the technical field of electronic product software, and particularly relates to a method for receiving a bar code with an indefinite length.
Background
At present, a plurality of electronic products all have a bar code as a unique product Identity (ID), and the bar code ID needs to be stored in a memory of electronic equipment, so that the electronic equipment is convenient for manufacturers to carry out after-sale check, maintenance confirmation, operation record and the like. Since the overseas market aims at different regions and customers, the bar codes are compiled in different lengths and formats, and meanwhile, the bar codes are input by using different bar code scanning devices, electronic products cannot be well compatible when receiving and storing the bar codes. Because the length is not fixed, the receiving end does not know how many information codes are received, and the receiving end finishes receiving and carries out verification storage. Of course, some bar codes have end characters, but some bar codes have no end characters, the end characters used by the bar codes of different customers are not uniform, and some bar code scanning equipment can freely set different end characters by self. These uncertainties all contribute to the difficulty in uniformly receiving and storing bar codes for products.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: a method for receiving bar code with indefinite length is disclosed, which is compatible with receiving bar code with indefinite length and different end characters.
The technical scheme adopted by the invention for solving the technical problems is as follows:
a method of receiving an indefinite length bar code comprising the steps of:
a. after receiving a first information code of a bar code with an indefinite length, a receiving end creates an asynchronous thread started in a delayed way, wherein the asynchronous thread is used for executing the checking and storing operation of the bar code;
b. when the receiving end receives the information code again, judging whether an asynchronous thread started in a delayed mode exists at present, if so, closing the thread, and then executing the step c, otherwise, directly entering the step c;
c. combining the information code received this time with the information code received before, and creating a new asynchronous thread started in a delayed manner;
d. and repeating the steps b and c until the delay time of the asynchronous thread started by the delay is exceeded, and executing the checking and storing operation of the bar codes by the asynchronous thread.
As a further optimization, the delayed starting time of the delayed starting asynchronous thread is far longer than the processing time interval of two adjacent information codes.
As a further optimization, in step d, when the examination and storage operations on the bar code are performed, if the received information code has an end symbol, the end symbol is filtered.
The invention has the beneficial effects that:
the receiving and storing of the bar code with different lengths can be compatible: when the information codes of the bar code are sequentially received, the bar code is checked and stored by adopting a delay asynchronous thread, the execution delay of the asynchronous thread is far longer than the time interval for processing two information codes, therefore, before the asynchronous thread is executed, if the next information code is continuously received, the receiving of the bar code is judged not to be finished, the asynchronous thread is terminated, after a new information code is received, a new delay asynchronous thread is created, the operation is repeated until the information code is not received, then the delay time is finished, the receiving of the complete bar code is shown to be finished, and the actions of checking and storing the bar code are executed. The method ensures that the whole machine can compatibly receive the bar codes with different lengths of different customers, and has high efficiency.
Drawings
Fig. 1 is a flowchart of a method for receiving an indefinite length barcode according to the present invention.
Detailed Description
The existing universal bar code scanning equipment is connected with a receiving end through a USB interface, when the scanning of the scanning equipment recognizes a bar code through infrared reflection, bar code information is sequentially sent to the receiving equipment through the USB interface, and for the bar code with an indefinite length, the receiving end cannot judge whether the bar code is the last information code or not and whether the sending of the bar code is finished or not when receiving one information code, and the application does not know how to process the bar code subsequently. In the prior art, some bar codes are judged by using end marks, while other bar codes are compiled without end marks, and the bar codes using the end marks are arranged in various ways. Therefore, the invention aims to solve the problem of the compatibility of receiving the indefinite bar codes.
As shown in fig. 1, the method for receiving an indefinite length barcode according to the present invention includes the following steps:
a. after receiving a first information code of a bar code with an indefinite length, a receiving end creates an asynchronous thread started in a delayed way, wherein the asynchronous thread is used for executing the checking and storing operation of the bar code;
b. when the receiving end receives the information code again, judging whether an asynchronous thread started in a delayed mode exists at present, if so, closing the thread, and then executing the step c, otherwise, directly entering the step c;
c. combining the information code received this time with the information code received before, and creating a new asynchronous thread started in a delayed manner;
d. and repeating the steps b and c until the delay time of the asynchronous thread started by the delay is exceeded, and executing the checking and storing operation of the bar codes by the asynchronous thread.
According to the scheme, in the receiving process of the information code, if the information code is received within the delay time of the asynchronous thread started in a delay mode, the receiving of the bar code is not finished, so that the existing asynchronous thread is closed, a new asynchronous thread is created again after the information code received this time is processed (combined with the previous information code), the delay time is timed again until the delay time of the asynchronous thread created after receiving a certain information code reaches, and the bar code is received completely because the setting of the delay time is far larger than the processing time interval of two adjacent information codes, at this time, the operation of checking and storing the bar code in the asynchronous thread is executed. Upon examination, if there is an end symbol, the end symbol is filtered out, since the end symbol is typically a format character. The actual bar code is then stored in a storage device.
By the scheme, the bar code with any length from 1 to n can be received, whether the bar code is provided with the end symbol or not can be avoided, and the end symbol can be ignored. Meanwhile, the receiving is relatively time-saving, and the efficiency is relatively high in the actual operation. It is more flexible and compatible than fixed length and bar codes with fixed terminators.
Example (b):
taking the example of receiving the bar code by the smart television, the method comprises the following steps:
1. and starting a display interface for receiving the bar code at the receiving end of the whole machine to prepare for receiving the bar code. And the scanning equipment sends the scanned and identified bar code to the receiving end of the whole machine through the USB. The whole system can be converted into remote control codes for processing.
2. The time interval for receiving two information codes is T15 ms when the application at the whole machine end processes, a delayed asynchronous thread is created when the first information code is received, the delay time is T300 ms, and the delay time is far longer than the time T between two information codes. That is, the asynchronous delay thread created by the previous message code is waiting to be executed when the next message code is received for processing.
3. When the next information code is received in the delay time, the asynchronous delay thread is immediately closed, the received information code and the previously received information code are combined together, and a new delayed asynchronous thread is created;
4. and repeating the step 3 until the waiting time is delayed for 300ms and no information code is sent, and triggering an asynchronous thread to perform checking and store the bar code when the bar code is sent. The end of the bar code is filtered before storage, if the character is displayed, it is not processed, and if the character is a format end character, it is filtered. And then the real bar code is stored in the EEPROM of the whole machine.
Claims (3)
1. A method of receiving an indefinite length bar code, comprising the steps of:
a. after receiving a first information code of a bar code with an indefinite length, a receiving end creates an asynchronous thread started in a delayed way, wherein the asynchronous thread is used for executing the checking and storing operation of the bar code;
b. when the receiving end receives the information code again, judging whether an asynchronous thread started in a delayed mode exists at present, if so, closing the thread, and then executing the step c, otherwise, directly entering the step c;
c. combining the information code received this time with the information code received before, and creating a new asynchronous thread started in a delayed manner;
d. and repeating the steps b and c until the delay time of the asynchronous thread started by the delay is exceeded, and executing the checking and storing operation of the bar codes by the asynchronous thread.
2. The method for receiving an indefinite length barcode according to claim 1, wherein the delayed start time of the delayed start asynchronous thread is longer than the processing time interval of two adjacent information codes.
3. The method for receiving an indefinite length barcode according to claim 1, wherein in the step d, when the operation of checking and storing the barcode is performed, if the terminator is found in the received information code, the terminator is filtered.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710685033.8A CN107423654B (en) | 2017-08-11 | 2017-08-11 | Method for receiving bar code with indefinite length |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710685033.8A CN107423654B (en) | 2017-08-11 | 2017-08-11 | Method for receiving bar code with indefinite length |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107423654A CN107423654A (en) | 2017-12-01 |
CN107423654B true CN107423654B (en) | 2020-06-09 |
Family
ID=60437015
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710685033.8A Active CN107423654B (en) | 2017-08-11 | 2017-08-11 | Method for receiving bar code with indefinite length |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107423654B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112949332B (en) * | 2021-02-20 | 2023-04-28 | 深圳市民德电子科技股份有限公司 | Sighting device auxiliary reading method and system of bar code reading equipment |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101556564A (en) * | 2008-04-11 | 2009-10-14 | 联芯科技有限公司 | Data receiving/sending method and device |
CN202171812U (en) * | 2011-07-05 | 2012-03-21 | 北京爱创科技股份有限公司 | Bar code identification device |
CN106326157A (en) * | 2015-06-30 | 2017-01-11 | 深圳市科陆电子科技股份有限公司 | Method and device for receiving variable-length data of serial port |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7644172B2 (en) * | 2002-06-24 | 2010-01-05 | Microsoft Corporation | Communicating via a connection between a streaming server and a client without breaking the connection |
-
2017
- 2017-08-11 CN CN201710685033.8A patent/CN107423654B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101556564A (en) * | 2008-04-11 | 2009-10-14 | 联芯科技有限公司 | Data receiving/sending method and device |
CN202171812U (en) * | 2011-07-05 | 2012-03-21 | 北京爱创科技股份有限公司 | Bar code identification device |
CN106326157A (en) * | 2015-06-30 | 2017-01-11 | 深圳市科陆电子科技股份有限公司 | Method and device for receiving variable-length data of serial port |
Also Published As
Publication number | Publication date |
---|---|
CN107423654A (en) | 2017-12-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109361703B (en) | Voice equipment binding method, device, equipment and computer readable medium | |
CN107730859B (en) | Wireless device pairing method, device and storage medium | |
JP6618310B2 (en) | Termination system having a communication device | |
EP2594055B1 (en) | Method in which a mobile phone reads a bar code located on a defective domestic appliance and is automatically connected to customer service | |
CN105898490A (en) | Upgrading method for remote controller, television and remote controller | |
US10341202B2 (en) | Smartphone-assisted maintenance of a self-service terminal | |
CN107980233A (en) | Automatic test approach, the apparatus and system of Bluetooth POS terminal | |
CN109309791B (en) | Method and system for controlling camera to take pictures | |
CN112637842B (en) | Screen projection equipment connection method, system, equipment and storage medium | |
CN107423654B (en) | Method for receiving bar code with indefinite length | |
CN104182779A (en) | Method and equipment for programming product information | |
EP2911132A1 (en) | Control device, remote control, and key value information processing method for remote control | |
CN109451095B (en) | Remote controller detection method and device, storage medium and terminal | |
CN113347618B (en) | Bluetooth pairing method, device and system, bluetooth intelligent terminal and storage medium | |
CN107659933B (en) | Bidirectional pairing connection method for wireless equipment, wireless equipment and storage medium | |
CN114328256A (en) | Test method, test device, computer-readable storage medium and electronic equipment | |
CN112015540B (en) | Program management method, device, system and readable storage medium | |
CN110780625B (en) | Automatic control method, device and equipment for pre-assembly line and storage medium | |
CN111045529B (en) | Data input method, system and related equipment | |
CN101197959B (en) | Terminal control method, system and equipment | |
CN107864467B (en) | Information transmission method and device for improving transmission speed between mobile terminal and equipment | |
CN102968609A (en) | Bar code reading equipment setting device based on one-dimensional Code 128 bar codes | |
CN111061630A (en) | Product debugging method, debugging device and readable storage medium | |
CN101853366B (en) | Method and device for executing data access according to communication protocol processing | |
CN112423284A (en) | Zigbee equipment pairing method and device, gateway, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |