C Language Development Kit/Functions/ReadBarcode
From OptiWiki
< C Language Development Kit | Functions(Redirected from C Language Development Kit/Functions/readbarcode)
| Description | This function tries to fetch a barcode from the scanner. | ||||||||||||
| Syntax | unsigned int readbarcode(struct barcode * barcodep); | ||||||||||||
| Arguments | The structure barcode is defined as follows:
struct barcode * barcodep struct barcode { char *text; int length; int id; int min; int max; };
| ||||||||||||
| Returns |
| ||||||||||||
| Remarks | readbarcode() tries to find a barcode in a buffer with data supplied by the scan-engine.
If readbarcode() finds a barcode in the buffer, it fills the barcode structure, and returns. If no barcode was read, readbarcode() calls idle() and returns. Use the systemsetting() function to select which barcode symbologies must be read. | ||||||||||||
| Example | // This program reads and displays a barcode. After each successful barcode reading, // it gives a good read signal on the LED, a buzzer signal. // // Note that an extra check is made on the minimum length when the barcode symbology // is one of the 2 of 5 codes, or Codabar. This is done because of the poor // specifications of these symbologies. // Note the use of a loop, repeatedly invoking readbarcode(). #include "lib.h" #include <stdio.h> void main( void ) { char bcr_buf[42]; struct barcode code; code.min = 1; code.max = 41; code.text = bcr_buf; for(;;) { if( !scanneroff()) { if( readbarcode( ) == OK) { if( (code.id != CODABAR) && ( code.id != I2OF5) && ( code.id != D2OF5) || ( code.length > 5)) { goodreadled( RED, 10); sound( TSTANDARD, VHIGH, SMEDIUM, SHIGH, 0); scannerpower( OFF, 0); printf("%s\n",code.text); } } } else { delay( 50 ); scannerpower( ON, 250); } idle(); } } |
