GM65 Barcode Reader
This library is a built-in class that provides functions to control the Hangzhou Grow Technology GM65 barcode reader.
Library usage requirements | |
---|---|
Type | UART |
Name | GM65 |
Version | 1_00_00 |
Code size used | 9.9KB |
Resources used | UART × 1, Timer × 1 |
Related Documents
- GM65 Bar Code Reader Module User Manual (Obtain the user manual from the vendor where it was purchased)
Pre-initialization
When using the GM65 barcode reader for the first time, the barcode reader must be factory-initialized once as the settings stored in the barcode reader are unknown. In addition, the baudrate of the UART interface must be set in advance.
Please follow the steps below to proceed with the initialization.
The separate User Manual is required.
1. Allow the use of the QR code for setup
Refer to User Manual - Setup Code and scan the QR code for Setup code on
.
2. Perform factory reset
Refer to User Manual - Reset and scan the QR code for Reset
.
It will take some time to initialize. Please wait until the buzzer sounds.
3. Configure the baudrate of the UART interface
Refer to User Manual - Series Communication Interface and scan the QR code for the baudrate to be used from the Baud Rate Settlement
options.
Abstracts
Methods()/Properties | Summary | Note |
---|---|---|
new GM65() | Creates a GM65 instance. |
{GM65} Instance
Methods()/Properties | Summary | Note |
---|---|---|
.init() | Initializes the barcode reader. | |
.onScanned() | Registers the event handler for scan result notification. | |
.getScanned() | Uses the scan execution command to get the scan results. | |
.VERSION | Version information maj : {number} Main Version min : {number} Minor Version rev : {number} Revision |
Details
new GM65(uart[,config])
Creates a GM65 instance.
Name | Type | M/O | Description | Note |
---|---|---|---|---|
uart | {UART} | mandatory | Specify a UART instance that has been opened in advance. The UART settings should be the same baudrate set during pre-initialization, hardware flow disabled, and parity mode disabled. | |
config | Object | optional | Configurations For details, refer to config. | |
return | {GM65} | - | {GM65} : Generated {GM65} | When an error occurs, an exception is raised. |
config
Name | Type | M/O | Description | Note |
---|---|---|---|---|
READ_MODE | number | optional | Read Mode 0: Manual mode 1: Command Triggered Mode 2: Continuous mode 3: Induction Mode The default value is 3. For more information, refer to the User Manual - Read Mode. | |
LIGHT | number | optional | Head lamp setting 0: Always OFF 1: ON when reading 2: Always ON The default value is 1. | |
COLLIMATION | number | optional | Pointing light beam setting 0: Always OFF 1: ON when reading 2: Always ON The default value is 1. | |
READ_TIME | number | optional | Read time [x0.1s] Range: 0 - 255(25.5s) The default value is 50. This is used when READ_MODE is 1, 2, or 3. | |
BREAK_TIME | number | optional | Break time [x0.1s] Range: 0 - 255(25.5s) The default value is 10. This is used when READ_MODE is 2, or 3. | |
STABLE_TIME | number | optional | Image stabilization time [x0.1s] Range: 0 - 255(25.5s) The default value is 4. This is used when READ_MODE is 3. | |
BUZZER_TONE | number | optional | Buzzer tone Range: 0 - 255 The default value is 100. | |
BUZZER_MS | number | optional | Buzzer duration time [ms] Range: 0 - 255 The default value is 60. | |
SCAN_BUZZER | number | optional | Scanning success sound 0: OFF 1: ON The default value is 1. | |
EAN | Array | optional | Reading enable/disable setting (EAN) Array[0]: Setting value for Zone bit 0x002E Array[1]: Setting value for Zone bit 0x002F Allow: [0x01,0x01] Forbid: [0x00,0x00] The default value is Forbid. | * |
UPC | Array | optional | Reading enable/disable setting (UPC) Array[0]: Setting value for Zone bit 0x0030 Array[1]: Setting value for Zone bit 0x0031 Array[2]: Setting value for Zone bit 0x0032 Allow: [0x01,0x01,0x01] Forbid: [0x00,0x00,0x00] The default value is Forbid. | * |
CODE128 | Array | optional | Reading enable/disable setting (CODE128) Array[0]: Setting value for Zone bit 0x0033 Array[1]: Setting value for Zone bit 0x0034 Array[2]: Setting value for Zone bit 0x0035 Allow: [0x01,0x04,0x40] Forbid: [0x00,0x04,0x40] The default value is Forbid. | * |
CODE39 | Array | optional | Reading enable/disable setting (CODE39) Array[0]: Setting value for Zone bit 0x0036 Array[1]: Setting value for Zone bit 0x0037 Array[2]: Setting value for Zone bit 0x0038 Allow: [0x01,0x04,0x40] Forbid: [0x00,0x04,0x40] The default value is Forbid. | * |
CODE93 | Array | optional | Reading enable/disable setting (CODE93) Array[0]: Setting value for Zone bit 0x0039 Array[1]: Setting value for Zone bit 0x003A Array[2]: Setting value for Zone bit 0x003B Allow: [0x05,0x04,0x40] Forbid: [0x04,0x04,0x40] The default value is Forbid. | * |
CODEBAR | Array | optional | Reading enable/disable setting (CODEBAR) Array[0]: Setting value for Zone bit 0x003C Array[1]: Setting value for Zone bit 0x003D Array[2]: Setting value for Zone bit 0x003E Allow: [0x03,0x04,0x40] Forbid: [0x02,0x04,0x40] The default value is Forbid. | * |
QR | Array | optional | Reading enable/disable setting (QR) Array[0]: Setting value for Zone bit 0x003F Allow: [0x01] Forbid: [0x00] The default value is Forbid. | * |
ITF | Array | optional | Reading enable/disable setting (ITF) Array[0]: Setting value for Zone bit 0x0040 Array[1]: Setting value for Zone bit 0x0041 Array[2]: Setting value for Zone bit 0x0042 Array[3]: Setting value for Zone bit 0x0043 Array[4]: Setting value for Zone bit 0x0044 Array[5]: Setting value for Zone bit 0x0045 Array[6]: Setting value for Zone bit 0x0046 Array[7]: Setting value for Zone bit 0x0047 Array[8]: Setting value for Zone bit 0x0048 Allow: [0x01,0x04,0x40,0x01,0x04,0x40,0x01,0x04,0x40] Forbid: [0x00,0x04,0x40,0x00,0x04,0x40,0x00,0x04,0x40] The default value is Forbid. | * |
CODE11 | Array | optional | Reading enable/disable setting (CODE11) Array[0]: Setting value for Zone bit 0x0049 Array[1]: Setting value for Zone bit 0x004A Array[2]: Setting value for Zone bit 0x004B Allow: [0x01,0x04,0x40] Forbid: [0x00,0x04,0x40] The default value is Forbid. | * |
MSI | Array | optional | Reading enable/disable setting (MSI) Array[0]: Setting value for Zone bit 0x004C Array[1]: Setting value for Zone bit 0x004D Array[2]: Setting value for Zone bit 0x004E Allow: [0x05,0x01,0x40] Forbid: [0x04,0x01,0x40] The default value is Forbid. | * |
RSS | Array | optional | Reading enable/disable setting (RSS) Array[0]: Setting value for Zone bit 0x004F Array[1]: Setting value for Zone bit 0x0050 Array[2]: Setting value for Zone bit 0x0051 Array[3]: Setting value for Zone bit 0x0052 Array[4]: Setting value for Zone bit 0x0053 Allow: [0x01,0x01,0x01,0x04,0x40] Forbid: [0x00,0x00,0x00,0x04,0x40] The default value is Forbid. | * |
MATRIX | Array | optional | Reading enable/disable setting (Data Matrix) Array[0]: Setting value for Zone bit 0x0054 Allow: [0x01] Forbid: [0x00] The default value is Forbid. | * |
PDF417 | Array | optional | Reading enable/disable setting (PDF417) Array[0]: Setting value for Zone bit 0x0055 Allow: [0x01] Forbid: [0x00] The default value is Forbid. | * |
BARCODE_FILTER | regexp | optional | String filter for scanned data regexp: The RegExp object Verifies the scanned data using regular expressions, and discards the data in the case of a mismatch. For example, to allow only numeric barcodes, specify /^[0-9]+$/ .If omitted or if the scan data is in binary format, no verification is performed. | |
SCAN_LIMIT | number | optional | Maximum scan data size [byte] Range: 1 - 510 The default value is 256. Discards the data when the scanned data exceeds the specified size. | |
errEvent(code) | function | optional | Executes a callback process when an error event occurs. code : {number} Error code For details, refer to List of error codes. |
- *: The setting value of the Zone bit is a number type from 0 to 255. For detailed specifications of each Zone bit, refer to User Manual - List of zone bit.
List of error codes
code | Description | Note |
---|---|---|
-1 | Barcode reader command timeout | |
-2 | Barcode reader command response error | |
-3 | Scan data error | |
-4 | Scan data overflow | If the maximum scan data size specified by SCAN_LIMIT in config is exceeded |
.init()
Initializes the barcode reader.
Only execute it once after creating an instance.
Name | Type | M/O | Description | Note |
---|---|---|---|---|
return | boolean | - | true: Success false: Failure | In the case of failure, try pre-initialization. |
.onScanned(callback[,isBin])
Registers the event handler for scan result notification.
Note that registration cannot be unregistered.
This method cannot be used if READ_MODE is 1.
Name | Type | M/O | Description | Note |
---|---|---|---|---|
callback(data) | function | mandatory | Executes a callback process when barcode reading is completed. data : {ArrayBuffer|string} Scanned data The type of the argument is determined by isBin . | |
isBin | boolean | optional | Specifies the output format of the scan data. true: Binary data format false: String format The default value is false. | Only ASCII code is supported for scan data. |
return | boolean | - | true: Success false: Failure |
.getScanned([isBin])
Uses the scan execution command to get the scan results.
This method is available only when READ_MODE is 1.
Name | Type | M/O | Description | Note |
---|---|---|---|---|
isBin | boolean | optional | Specifies the output format of the scan data. true: Binary data format false: String format The default value is false. | Only ASCII code is supported for scan data. |
return | ArrayBuffer, string, null, undefined | - | Scanned data The return type is determined by isBin . | If the read time specified by READ_TIME in config is exceeded, null will be returned.If READ_MODE is not 1, undefined is returned. |
Usage Examples
Sample 1
This is a sample for scanning using Induction Mode (READ_MODE: 3).
Acquires only QR Code and 16-digit alphanumeric uppercase scanned data.
log.setLevel(0,2); //-1:NONE 0:ERROR 1:WARNING 2:DEBUG 3:TRACE, 0:DISABLE 1:LOG 2:CONSOLE 3:BOTH
log.printLevel(2); //0:DISABLE 1:LOG 2:CONSOLE 3:BOTH
if(!('GM65' in this)) { throw new Error('Please import the GM65 library.'); }
//Specify the UART connection settings for the GM65 barcode reader.
var uart = new UART(1); //UART node number
var ready = uart.open(115200, false, 0); //UART baudrate
if(!ready) {
throw new Error('uart.open');
}
var config = {
READ_MODE: 3, //Induction Mode
QR: [0x01], //Allow QR Code
BARCODE_FILTER: /^[0-9A-Z]{16}$/, //A 16-digit string consisting of "0" to "9" and "A" to "Z"
errEvent: function(code) { print('error:' + code); }
};
var gm65 = new GM65(uart, config);
ready = gm65.init();
if(!ready) {
throw new Error('gm65.init');
}
var scanCb = function(data) {
print('scan:', data);
};
if(!gm65.onScanned(scanCb)) {
throw new Error('gm65.onScanned');
}
Sample 2
This is a sample for scanning using Command Triggered Mode (READ_MODE: 1).
Acquires only QR Code and 16-digit alphanumeric uppercase scanned data.
log.setLevel(0,2); //-1:NONE 0:ERROR 1:WARNING 2:DEBUG 3:TRACE, 0:DISABLE 1:LOG 2:CONSOLE 3:BOTH
log.printLevel(2); //0:DISABLE 1:LOG 2:CONSOLE 3:BOTH
if(!('GM65' in this)) { throw new Error('Please import the GM65 library.'); }
//Specify the UART connection settings for the GM65 barcode reader.
var uart = new UART(1); //UART node number
var ready = uart.open(115200, false, 0); //UART baudrate
if(!ready) {
throw new Error('uart.open');
}
var config = {
READ_MODE: 1, //Command Triggered Mode
QR: [0x01], //Allow QR Code
BARCODE_FILTER: /^[0-9A-Z]{16}$/, //A 16-digit string consisting of "0" to "9" and "A" to "Z"
errEvent: function(code) { print('error:' + code); }
};
var gm65 = new GM65(uart, config);
ready = gm65.init();
if(!ready) {
throw new Error('gm65.init');
}
var scanCb = function(data) {
print('scan:', data);
};
while(1) {
var c = gm65.getScanned();
if(c) {
scanCb(c);
}
setTimeout(1000).wait();
}