The text of a manual · part 3 of 11
HT Series/PA Series/RH Series Programming Manual, pages 17 to 26
Pages 17 to 26 of 98
The original document is the PDF (1.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Unitech HT660 and Unitech HT680
Page 17
2.6 Returns the system error code Function Description: Returns the system error code, which is returned by GetLastError. It will also return the description of the error in buffer if it is not NULL. Function call: DWORD USI_GetLastSysError(LPTSTR buffer, int len); Parameter: (output) buffer: LPTSTR: len: int:
Data buffer for error message Length of error message.
Return: Returns the system error code, which is returned by system function GetLastError. It will also return the description of the error in buffer retrieved by system function FormatMessage if it is not NULL. For a complete list of error codes, refer to the SDK header file WINERROR.H.
2.7 Get scan data Function Description: Retrieves the scan data into the buffer. Returns the length of characters. It also returns the barcode type if type is not NULL. Return 0 means that the buffer is too short to hold the data. USI_GetData should be called when SM_DATAREADY message is received. Or call USI_ResetData to discard the data. Both of them will reset the data buffer so that next scan data can come in. If the data buffer is not empty and a new scan data occurs, it will be discarded and an error message SM_ERROR with code of SERR_DATALOST will be sent. Function call: UINT USI_GetData(LPBYTE buffer, UINT len, UINT* type); Parameter: (input) len : UINT:
Len specifies the maximum length of the buffer.
Parameter: (output) buffer: LPBYTE: type: UINT:
Data buffer for storing scanned data barcode type which is defined on USI.H.
Please refer to below list BCT_CODE_39 BCT_CODABAR BCT_CODE_128 BCT_INTERLEAVED_2OF5 BCT_CODE_93 BCT_UPC_A BCT_UPC_A_2SUPPS BCT_UPC_A_5SUPPS BCT_UPC_E0 BCT_UPC_E0_2SUPPS BCT_UPC_E0_5SUPPS BCT_EAN_8 BCT_EAN_8_2SUPPS BCT_EAN_8_5SUPPS BCT_EAN_13 BCT_EAN_13_2SUPPS BCT_EAN_13_5SUPPS BCT_MSI_PLESSEY
// Code 39 // CodaBar // Code 128 // Interleaves 2 of 5 // Code 93 // UPC A // UPC A with 2 Supps // UPC A with 5 Supps // UPC E // UPC E with 2 Supps // UPC E with 5 Supps // EAN 8 // EAN 8 with 2 Supps // EAN 8 with 5 Supps // EAN 13 // EAN 13 with 2 Supps // EAN 13 with 5 Supps // MSI Plessey 17 -
Page 18
BCT_EAN_128 BCT_UPC_E1 BCT_UPC_E1_2SUPPS BCT_UPC_E1_5SUPPS BCT_TRIOPTIC_CODE_39 BCT_BOOKLAND_EAN BCT_COUPON_CODE BCT_STANDARD_2OF5 BCT_CODE_11_TELPEN BCT_CODE_32 BCT_DELTA_CODE BCT_LABEL_CODE BCT_PLESSEY_CODE BCT_TOSHIBA_CODE Return: UINT:
// EAN 128 // UPC E1 // UPC E1 with 2 Supps // UPC E1 with 5 Supps // TRIOPTIC CODE 39 // Bookland EAN // Coupon Code // Standard 2 of 5 // Code 11 Telpen // Code 32 // Delta Code // Label Code IV & V // Plessey Code // Toshiba Code China Postal Code / Matrix 2 of 5
Data length
2.8 Get length of scanned data Function Description: Returns the data length of the scan data. When allocate the memory to hold the scan data, add at least one additional byte for string terminator. Function call: UINT USI_GetDataLength(); Return: UNIT:
data length
2.9 Get Symbology name Function Description: Returns the barcode name of the type. Function call: LPCTSTR USI_GetBarcodeName(UINT type, LPBYTE buffer, UINT len); Parameter: (input) type: UINT buffer: LPBYTE Type BCT_CODE_39 BCT_CODABAR BCT_CODE_128 BCT_INTERLEAVED_2OF5 BCT_CODE_93 BCT_UPC_A BCT_UPC_A_2SUPPS BCT_UPC_A_5SUPPS BCT_UPC_E0 BCT_UPC_E0_2SUPPS BCT_UPC_E0_5SUPPS BCT_EAN_8 BCT_EAN_8_2SUPPS BCT_EAN_8_5SUPPS BCT_EAN_13 BCT_EAN_13_2SUPPS
: barcode type. (refer to 4 for type definition : Please refer to below table Buffer Code 39 Codabar Code 128 Interleaved 2 of 5 Code 93 UPC A UPC A with 2 Supps. UPC A with 5 Supps. UPC E UPC E with 2 Supps. UPC E with 5 Supps. EAN 8 EAN 8 with 2 Supps. EAN 8 with 5 Supps. EAN 13 EAN 13 with 2 Supps. 18 -
Page 19
BCT_EAN_13_5SUPPS BCT_MSI_PLESSEY BCT_EAN_128 BCT_TRIOPTIC_CODE_39 BCT_BOOKLAND_EAN BCT_COUPON_CODE BCT_STANDARD_2OF5 BCT_CODE_11_TELPEN BCT_CODE_32 BCT_DELTA_CODE BCT_LABEL_CODE BCT_PLESSEY_CODE BCT_TOSHIBA_CODE len:
Return: TRUE: FALSE:
UINT
EAN 13 with 5 Supps. MSI Plessey EAN 128 Trioptic Code 39 Bookland EAN Coupon Code Standard 2 of 5 Code 11 or Telpen Code 32 (Pharmacy Code) Delta Code Label Code IV & V Plessey Code Toshiba Code (China Postal Code), Matrix 25 nd
: length of string on the 2 parameter buffer if it found name for the barcode type, if not (type may be wrong
19 -
Page 20
2.10 Clear scan data system buffer Function Description: Reset the data buffer so that next new scan data can come in. Function call: void USI_ResetData();
2.11 Good read indicator Function Description: Inform a good receiving of scan data, this will play a sound (wave file scanok.wav) and light the LED lasting for 1 second. Function call: void USI_ReadOK(); Note: USI will call the function GoodReadLEDOn function exported by the DLL defined in the registry described below (UPI300.DLL is an example) to turn on and off the LED. If the DLL is not defined or the function is not found, USI will bypass the call of GoodReadLEDOn. [HKEY_LOCAL_MACHINE\SOFTWARE\Unitech America Inc.\Scanner\Settings] "DLLLEDCONTROL"="UPI300.DLL" The function prototype of GoodReadLEDOn is: VOID WINAPI GoodReadLEDOn(BOOL fon); Turn on when fon is TRUE, and turn off when fon is FALSE.
2.12 Wait for acknowledgement of the last sent command Function Description: Wait for acknowledgement of the last sent command until timeout. It is useful when a serial of commands needs to be sent at a time. Before call USI_SendCommand, call USI_WaitForSendEchoTO to make sure that the previous command is done. Function call: BOOL USI_WaitForSendEchoTO(DWORD timeout); Parameter: (input) timeout: DWORD
: Specifies the timeout in millisecond.
Return: Returns FALSE if timeout.
2.13 Save setting to profiles Function Description: Save current settings of scanner so that the settings will be persistent when the unit get power off and on again. Function call: BOOL USI_SaveCurrentSettings(); Return : TRUE: FALSE:
Success, Fail
20 -
Page 21
2.14 Save scanner setting into specified file Function Description: Save the current settings to file. The file takes “*.USI” as extension name. Function call: BOOL USI_SaveSettingsToFile(LPCTSTR filename) Parameter: (input) filename : LPCTSTR: file name for setting profile Return: TRUE: FALSE:
Success, Fail
2.15 Change scanner setting from specified setting profile Function Description: Load and activate the settings from file. Function call: BOOL USI_LoadSettingsFromFile(LPCTSTR filename, BOOL formulaOnly); Parameter: (input) filename: LPCTSTR : formulaOnly: BOOL: remain unchanged Return: TRUE: Success, FALSE: Fail name of scanner setting profile (*.USI) if TRUE, only data editing formulas are load. The other settings
2.16 Automatically enable scanner beam with pressing trigger key Function Description: Start auto scanning. Scan engine will be automatically triggerrd on. Function call: BOOL USI_StartAutoScan(DWORD interval); Parameter: (input) interval: DWORD: Return: TRUE: FALSE:
Specifies the interval in milli-second
Success, Fail
Note: USI will call the function SetScannerOn function exported by the DLL defined in the registry described below (UPI300.DLL is an example) to start and stop the scanner. If the DLL is not defined or the function is not found, then auto scanning is not available. [HKEY_LOCAL_MACHINE\SOFTWARE\Unitech America Inc.\Scanner\Settings] "DLLSCANNERCONTROL"="UPI300.DLL" The function prototype of SetScannerOn is: VOID WINAPI SetScannerOn(BOOL fon); Start when fon is TRUE, and stop when fon is FALSE. 21 -
Page 22
2.17 Stop auto scanning function Function Description: Stop auto scanning Function call: void USI_StopAutoScan();
2.18 Check if auto scanning is enable Function Description: Check if auto scanning function is enabled or not Function call: BOOL USI_IsAutoScanning() Return: BOOL:
TRUE: FALSE:
auto-scanning is running auto-scanning is disabled.
2.19 Check if Scan2Key.exe program is running or not Function Description: Test whether Scan2Key application is running at background. (It doesn’t mean Scan2Key is routing scanner input to keyboard, please call S2K_IsEnabled() to check if routing function is enable or not) Function call: HWND S2K_IsLoaded(); Return: NULL: Scan2Key is not running Non-NULL: Indicates scan2key is running. It actually returns window handle for scan2key, but it is for internal use – send messages.
2.20 Test if Scan2Key is enabled Function Description: Test whether Scan2Key is enabled. Scan2Key routes scanning input from scanner to keypad buffer, so that barcode data can be input as like from keystrokes on keypad. Function call: BOOL S2K_IsEnabled(); Return: TRUE: FALSE:
Enabled. Disabled
22 -
Page 23
2.21 Load/Unload Scan2Key.exe Function Description: Load or unload Scan2Key Function call: BOOL S2K_Load(BOOL load, DWORD timeout); Parameter: (input) load: BOOL:
TRUE = load Scan2Key FALSE = unload Scan2Key timeout: DWORD: when unload Scan2Key, it will wait until Scan2Key has been removed from memory or timeout specified by this parameter.
Return: TRUE = successfully loaded.
2.22 Enable/Disable Scan2Key Function Description: Enable or disable Scan2Key to put scanned data to standard keyboard input buffer. Scan2Key is enabled by default. Function call: BOOL S2K_Enable(BOOL enable, DWORD timeout); Parameter: (input) enable: BOOL:
TRUE = Enable scanned data to keyboard buffer FALSE = Disable scanned data to keyboard timeout: DWORD: when enable or disable Scan2Key, it will wait until Scan2Key has been removed from memory or timeout specified by this parameter. Return: TRUE: if successfully enabled Scan2Key, otherwise FALSE
2.23 Send scanner command to decoding chip Function Description: Send scanner command to decoder chip. This command will send a serial of bytes to decoder chip as following: (Esc and BCC will be calculated and added automatically) Esc, high-length, low-length, command-ID, operation, set, BCC Please refer to complete command reference on section Error! Reference source not found. BOOL HAM_SendCommand(BYTE highlen, BYTE lowlen, BYTE cmdID, BYTE op, BYTE set); Parameter: (input) highlen: lowlen: cmdID: op: set:
BYTE: BYTE: BYTE: BYTE: BYTE:
high byte of command length low byte of command length command ID operation mode for this command operand for this command
Return: TRUE = Indicates the command has been successfully sent to queue to output.
23 -
Page 24
2.24 Only send single command decoding chip Function Description: Send command to decoder chip. This is a variation of command HAM_SendCommand. It sends following command to Hamster: (note, only two bytes without BCC) Esc, 0x80+cmd Function call: BOOL HAM_SendCommand1(BYTE cmd); Parameter: (input) cmd: BYTE:
command
Return: TRUE = indicates the command has been successfully sent to queue to output.
2.25 Send command to decoding chip Function Description: Send command to decoder chip. This is a variation of command HAM_SendCommand. It will read a number of parameters and packet them as in following format and send it to decoder chip. Esc, parameter1, parameter2, …, BCC The total number of parameters is specified by first parameter num. Function call: BOOL HAM_SendCommand2(BYTE num, BYTE parameter1, …); Parameter: (input) num: BYTE: parameterx BYTE:
number of total parameters Parameter
Return: TRUE = indicates the command has been successfully sent to queue to output.
2.26 Send scanner command set to decoding chip Function Description: This function call has the same function as HAM_SendCommand except that it takes a single WORD parameter for the length and an extra timeout parameter. This is a synchronized function, it returns when command has been sent to and got response from scanner. USI_WaitForSendEchoTO is not needed before a next continuous send command call. To send a string please call HAM_SendCommand_SetString. BOOL HAM_SendCommand_Set(WORD len, BYTE cmdID, BYTE op, BYTE set, DWORD timeout) Parameter: (input) len: BYTE : Specifies length of command, which is actually always be 4. cmdID: BYTE : command ID op: BYTE : operation mode for this command set: BYTE : operand for this command timeout: DWORD : Specifies the timeout in millisecond Return: TRUE = indicates the setting has been set successfully.
2.27 Get scanner command set from decoding chip Function Description: This function call has the similar function as HAM_SendCommand_Set except that it retrieves setting from scanner. This is a synchronized function, it returns when command has been sent to 24 -
Page 25
and got response from scanner. USI_WaitForSendEchoTO is not needed before a next continuous send command call. BOOL HAM_SendCommand_Get(WORD len, BYTE cmdID, BYTE op, BYTE* get, DWORD timeout) Parameter: (input) len: BYTE : Specifies length of command, which is actually always be 4. cmdID: BYTE : command ID op: BYTE : operation mode for this command get: BYTE* : Pointer to a byte which will hold the setting retrieved from scanner. timeout: DWORD : Specifies the timeout in millisecond Return: TRUE = indicates the setting has been retrieve successfully.
2.28 Send scanner command set string to decoding chip Function Description: This function call has the same function as HAM_SendCommand_Set except that it sends a serial of data instead of a single byte to scanner. BOOL HAM_SendCommand_SetString(WORD len, BYTE cmdID, BYTE op, LPCSTR sets, int slen, DWORD timeout) Parameter: (input) len: BYTE : Specifies length of command, which will be calculated and adjusted automatically cmdID: BYTE : command ID op: BYTE : operation mode for this command sets: LPCSTR : Specifies the string data slen: int : Specifies the length of string data. Set to -1 to calculate automatically timeout: DWORD : Specifies the timeout in millisecond Return: TRUE = indicates the setting has been set successfully.
2.29 Get scanner command set string from decoding chip Function Description: This function call has the similar function as HAM_SendCommand_SetString except that it retrieves setting from scanner BOOL HAM_SendCommand_GetString(WORD len, BYTE cmdID, BYTE op, LPSTR gets, int* slen, DWORD timeout) Parameter: (input) len: BYTE : Specifies length of command, which will be calculated and adjusted automatically cmdID: BYTE : command ID op: BYTE : operation mode for this command gets: LPSTR : Buffer which will hold the setting retrieved from scanner slen: int* : Specifies the length of buffer and returns actual data length in the buffer timeout: DWORD : Specifies the timeout in millisecond Return: TRUE = indicates the setting has been retrieve successfully.
25 -
Page 26
2.30 Get scanner related version information Function Description: Get Scanner related version information. It does not need to call USI_Register to use this function. Function call: BOOL USI_GetScannerVersion(LPTSTR model, LPTSTR firmware, LPTSTR sdk, int blen); Parameter: (output) model: LPTSTR : scanner model. firmware: LPTSTR : firmware version number. sdk: LPTSTR : sdk version number if available. blen: int : specifies buffer length for parameters of model, firmware and sdk. Return: Always True.
2.31 Enable prompt warming message from USI Function Description: Enables USI to report working information in a popup window Function call: BOOL USI_EnablePromptMessage(BOOL enable); Parameter: (output) enable: BOOL : True= enable, Fail:Disable Return: Always True.
2.32 Scanner working mode (available for 2D model) Function Description: Sets scanner engine to working mode of barcode decoding/Image/Preview (mode = SWM_BARCODE) or image capture (mode = SWM_IMAGE) or preview and image capture (mode = SWM_IMAGE_PREVIEW) for 2D scanner Function call: BOOL USI_SetWorkingMode(int mode); Parameter: (output) mode: int : mode = SWM_BARCODE – Barcode mode = SWM_IMAGE – image capture mode = SWM_IMAGE_PREVIEW – preview and image capture for 2D scanner Return: Always True.
2.33 Get image (available for 2D model) Function Description: Retrieves captured image in bitmap format, and returns image size. Function call: HBITMAP USI_GetImageBitmap(SIZE* imagesize); Parameter: (output) imagesize: SIZE : Bitmap image size Return: HBITMAP : image
26 -