Page 2
With regard to the supply of products, the current issue of the following document is applicable: The General Terms of Delivery for Products and Services of the Electrical Industry, published by the Central Association of the Electrical Industry (Zentralverband Elektrotechnik und Elektroindustrie (ZVEI) e.V.) in its most recent version as well as the supplementary clause: "Expanded reservation of proprietorship"...
Page 4
JavaScript Programming Guide 3.5.4 Let the Handheld Process the Decode ..............27 3.5.5 Ignore the Decode ....................28 3.5.6 Determine the Orientation of the Decode ..............28 Host Communication ................29 Data in Handheld Local Storage ............30 Demo Programs ................... 30 4 Class Reference ..............31 decode ....................
Introduction Introduction This manual describes the application programming interface for OHV300 handhelds. It is assumed the user will have programming knowledge and familiarity with the JavaScript language. Handhelds read code and can be programmed to transmit code data over a selected ...
Smart quotes are not valid in JavaScript. CodeViewer Application The CodeViewer Application runs as a JavaScript application on the OHV300. The menu driven application has features for changing configuration settings and for defining the applications that run on the reader.
Programming Environment Debugging The handheld reader contains a built-in error log that can be used when debugging scripts. To debug the script when an error has occurred, send the ‘(‘ command to the reader; the reader responds by sending the error log to the communications port. The error log may contain messages from the firmware that should be ignored.
It is an easy to code and understand application that illustrates how the programming environment works. In its simplest form, the “Hello World!” application in the OHV300 environment sends text to the display. With the following single line of code, you can display “Hello World!” in the screen defined by the standard OHV300 gui object (section 4.1).
The standard display consists of a status bar, a display area, and labels for the left and right software programmable keys (softkeys) at the top of the OHV300 key pad (see Figure The scroll bar on the right side of the screen indicates the relative position within the displayed object as the operator scrolls through forms, menus, or text using the up and down keys on the keypad.
Programming Concepts 3.2.1 Softkey Implementation Softkeys are general purpose, programmable keys. The softkeys are independent of the GUI display. The gui.showForm, gui.showMenu, and gui.showSubmenu methods include softkey definitions appropriate for the implementation. The following example shows the basic approach to programming the softkeys and implementing their event handlers.
= "form demo"; // show the form gui.showForm(myForm); When the Form Demo Script runs, the OHV300 displays the following image: Figure 3 – Form Demo Display The user enters an employee number into the edit control and presses the left button (OK) to submit the data.
Page 18
(optional) myMenu.setActiveChild(inventoryApp); subMenu.setActiveChild(capital); // set the caption text for the status bar myMenu.caption = "menu demo"; // show the menu gui.showMenu(myMenu); When the Menu Demo application is initiated, the OHV300 displays the following image: Figure 4 – Menu Demo Display...
Programming Concepts The Select button sends gui.softkey.enter to run the highlighted application. In this example, the Inventory option is selected. The script then displays the Inventory submenu shown in Figure 5. Figure 5 – Sub Menu Demo Display 3.2.4 Text Use the gui.Text object (section 4.2.3.11) to show text.
The clear, enter, and left and right buttons (softkeys) can be programmed to seamlessly integrate with user specific events. The possibilities are shown in Table 1. The GUI objects are documented in section 4.2.3. Figure 6 – OHV300 Keypad 1. Left Softkey 2. Right Softkey 3.
Programming Concepts Object Event Handler Property Any Other Buttons gui.Form onKey gui.Menu onKey gui.Text onKey 3.3.3 Command Execution The reader application defines a number of commands that can be sent to the firmware from the host or by reading codes. The reader (section 4.3) defines an event by the onCommand function.
A decode command from the reader.processCommand method. The reader.onDecode defines an event that allows the application to access data. To program the OHV300 to scan and transmit data, follow the below commands. function onDecode(decode) // Processing reader.onDecode = onDecode;...
Page 24
Programming Concepts Example: function onDecode(decode) data = decode.data; if (decode.symbology == some-special-symbology) data = transformed decode.data; else if (decode.symbology == some-other-special-symbology) data = differently transformed decode.data; if (data matches employee-badge format) loginForm.employeeField.text = decode.data; loginForm.pinField.text = ""; gui.showForm(loginForm); return null; else if (data matches part-number format) stockForm.partField.text = decode.data;...
Programming Concepts gui.showForm(warning); return null; else if (data matches format that is to be ignored) return false; // invalidate the decode else // code should be processed by handheld firmware if ( code should be processed with transformed data) decode.data = data; // replace the data field // with transformed data return decode;...
Programming Concepts 3.5.2 Evaluate Data Format After the data is converted into a common data format based on the symbology, the application determines the data format and processes according to data content. if (data matches employee-badge format) loginForm.employeeField.text = decode.data; loginForm.pinField.text = "";...
Programming Concepts 3.5.3 Detect Format Errors If the format matches a known format that should not be used in the current application context, the application can send a warning message, which is displayed in "warning" form. else if data matches wrong formats warning.text = "bad code for this application";...
Programming Concepts 3.5.5 Ignore the Decode You can ignore a particular format by exiting the function with a return value of false as shown in the following code segment from the example. else if (data matches format that is to be ignored) return false;...
Programming Concepts A code that is not “right side up” could be rejected by exiting the function with a return value of false as shown in the following example. if (decode.bounds[0].x > 0 && decode.bounds[0].y < 0 && decode.bounds[1].x > 0 && decode.bounds[1].y > 0 && decode.bounds[2].x <...
Programming Concepts Example: reader.onCommand = function(type, data) // intercept | command with app-data: prefix if( type == '|' && data.match(/^app-data\:/) ) return false; // Suppress the command return true; For more information on host communications, refer to the Interface Configuration Document.
Class Reference Class Reference The built-in objects described in this section enable a JavaScript program to receive data from the handheld and control its behavior. decode The decode object provides data and metadata on the currently decoded barcode. Since the decode object is passed from the decode engine to the JavaScript engine, any valid variable name can be used to hold the data.
Class Reference 4.1.1.3 symbology_ex The decode.symbology_ex property is a read only property that contains extended symbology information for the barcode decoded by the decode engine. Valid values for symbology_ex are defined in 9. This property is seldom used, but is used in the same way as symbology. 4.1.1.4 symbologyModifier The decode.symbologyModifier property is a read only property that contains...
Class Reference 4.1.1.9 time The decode.time property is a read only property that defines the amount of time, in milliseconds, it took the decode engine to decode the barcode that was just analyzed. 4.1.1.10 quality_percent The decode.quality_percent property is a read only property that defines an internally-defined image quality value determined by the decode engine while analyzing the captured image.
Class Reference pos.tL = (decode.bounds[1].x, decode.bounds[1].y) //The x and y coordinates of the bottom left corner of the barcode in the image: pos.bL = (decode.bounds[2].x, decode.bounds[2].y) //The x and y coordinates of the bottom right corner of the barcode in the image: pos.bR = (decode.bounds[3].x, decode.bounds[3].y) 4.1.1.16 numExtraFields...
Class Reference default: newSymbol = aimSymbol return newSymbol + decode.data; 4.1.1.19 aimModifier The decode.aimModifier property is a read only property that gives the AIM (Automatic Identification and Mobility) Modifier determined by the decode engine of the barcode that was just decoded. More information on AIM Standards can be found at the Association for Automatic Identification &...
Class Reference The gui object provides application programming access to the OHV300 display screen. The OHV300 application development environment defines a standard software GUI format (section 4.2.3) consisting of a status bar, a display area, and labels for the left and right software programmable keys (softkeys) on the OHV300 key pad.
Class Reference 4.2.1.2 confirm The gui.confirm function displays text in the display area of the standard GUI display and returns a value based on the key pressed. Do not call this function within onDecode and onCommand event handlers. Format: gui.confirm(yesFunc, noFunc, text, title, leftSoftkeyLabel, rightSoftkeyLabel);...
Class Reference 4.2.1.3 prompt The gui.prompt function displays text in the display area of the standard GUI display and returns a value based on the key pressed. Do not call this function within onDecode and onCommand event handlers. Format: gui.prompt(func, text, initial, title); Where: func –...
Class Reference The value of string depends on the operator action. If the operator presses the right softkey (Cancel), the value of string is null. If the operator presses the “enter” key or the left softkey (OK) the value of string is: ...
Sends the enter key event to the OHV300 firmware as though the operator had pressed the enter key. 4.2.1.6 sendText The gui.sendText method sends a text string to the OHV300 gui object as though it had been entered from the keypad. Format: result = gui.sendText(text);...
4.2.1.9 showMenu The gui.showMenu method instructs the OHV300 to display the specified menu on the OHV300 display as a standard gui object (section 4.2.3). This menu is the top level menu; sub-menus can be created using the gui.showSubMenu method. Format: gui.showMenu(yourMenu);...
Class Reference 4.2.1.10 showSubMenu The gui.showSubMenu method instructs the OHV300 to display the specified menu on the OHV300 display as a standard gui object (section 4.2.3). Format: gui.showSubMenu(yourMenu, parentMenu); Where: yourMenu – menu object to show on the display. The object must be a gui.Menu object (section 4.2.3.6).
This function will clear the image from the OHV300 screen. The gui.clearSplash method should only be called after calling gui.splash method. The OHV300 supports only its native format, which uses the extension .img. The image must be 128x128 pixels (for splash screen only). Images are not cropped; they will either display in their entirety or will not display at all.
The gui.leftSoftkey property identifies an event handler for the onClick property of a gui.Softkey object and the key label, associated with the left programmable key on the OHV300. The application program defines a gui.Softkey object. See the example in section 0 Setting gui.leftSoftkey to null disassociates the softkey object from the property...
4.2.3 Objects The OHV300 application development environment provides the user classes described in this section for use in building forms for the OHV300 gui object. The instances of these classes are referred to as controls in this document. 4.2.3.1 gui.Button The gui.Button constructor creates a button control for a GUI form.
RS232. Note: The active control is highlighted. 4.2.3.2 gui.Edit The gui.Edit constructor creates an edit control for a GUI form. The OHV300 operator can enter data into the edit control. Format: var <edit_name> = new gui.Edit(text, defaultInputMode, validInputModes, onChar,...
Page 47
Class Reference validInputModes – number; a bitwise combination of input modes as defined by gui.inputMode (section 4.2.2.1); defines the input modes that are valid in the edit control. onChar – function; the function to run when a character is entered into an edit control. readOnly –...
4.2.3.3 gui.Form The gui.Form constructor creates a Form object for the OHV300 GUI. The gui.Form constructor defines three event handlers for key events. Event handlers are null if not specified. The following controls can be used in a form: ...
– function for handling the CLEAR key. The OHV300 calls this function when the operator presses the key on the OHV300 keypad and the active control is not an edit control. This function is also called when the escape key is issued as a softkey.
<menu_name> – program-provided menu. onOk – function for handling the enter key. The OHV300 calls this function when the operator presses the enter key on the OHV300 keypad when the active control is not a button. onCancel – function for handling the CLEAR key. The OHV300 calls this function when the operator presses the CLEAR key on the OHV300 keypad and the active control is not an edit control.
– function for handling the MenuItem. The OHV300 calls this function when the operator presses the enter key on the OHV300 keypad when the MenuItem is the active control. Code the function to return Boolean true if the control's default processing of the key should continue.
= ""; gui.showMenu(main); }); 4.2.3.9 gui.Separator The gui.Separator constructor creates a separator control for display in a OHV300 GUI menu or form. Use the separator to insert white space or lines into a form to increase separation between controls.
– string; a label for the softkey; displays on the GUI. onClick – function; the function to be executed when the softkey is pressed. Set the gui.leftSoftkey or gui.rightSoftkey property to <softkey> as appropriate. The OHV300 JavaScript library defines a set of useful softkey objects (section 4.2.4).
Where: <text_name> – program-provided text control. text – string; text data to display on the OHV300 GUI. To display multi-line text, insert the new-line character (“\n”) in the text string. This property can be changed after the object is created.
– function for handling the button click event. It passes a single Boolean parameter; true, the button is checked; false, the button is not checked. The OHV300 calls this function when the operator presses the OK enter key on the OHV300 keypad when the GUI button is the active control.
Page 56
Figure 14 – Toggle Not Selected Pressing the left softkey (OK) toggles the indicator, as shown in Figure 15, and turns on the vibrate feature of the OHV300. Pressing OK again turns off the indicator and the vibrate feature. Figure 15 – Toggle Selected...
Class Reference 4.2.4 Predefined Softkey Objects The softkey objects described in this section are defined by the OHV300 JavaScript library. 4.2.4.1 backSoftkey The gui.backSoftkey object defines a softkey object. It labels the softkey “Back” and sends the escape key when the softkey is clicked.
4.2.6.1 caption The caption property is a string that is used by gui.showForm, gui.showMenu, and gui.showSubMenu to display a caption in the status bar of the OHV300 gui object. Format: <MenuOrForm_name>.caption = "<caption_string>"; Example: See forms example in section 3.2.2.
Class Reference 4.2.6.2 onKey The onKey property is a property of type function that is used by gui.Form, gui.Menu, and gui.Text to provide control for any key not consumed by the active control. Key constants are defined in section 0. Format: function processKey(key) /* processing code */...
Class Reference 4.3.1.2 defaultSettings The defaultSettings method resets selected handheld settings to manufacturing defaults; it is equivalent to sending the 'J' command using the reader.processCommand method (section 4.3.1.3). Format: reader.defaultSettings(); Note: This method has no arguments and no return value. Default settings may vary by unit depending on the configuration purchased.
Class Reference 4.3.1.4 processCommand The processCommand method instructs the handheld to execute a command. Format: result = reader.processCommand(commandType, data); Where: commandType – string, 1 character; the command to be processed on the handheld. data – string; data as required to process the command. result –...
– Boolean; false if the flash write fails; true otherwise. Note: There are no arguments to this method. 4.3.1.8 setDisplayLed The setDisplayLed method activates the LED of the OHV300 above the display. Format: reader.setDisplayLed(color); Where, color – must be reader.green, reader.red, reader.amber or reader.none.
Class Reference 4.3.1.9 setInterval The setInterval method calls a function or evaluates an expression at specified intervals in seconds. The setInterval method will continue calling the function until clearInterval is called, or the window is closed. The ID value returned by setInterval is used as the parameter for the clearInterval method.
Class Reference 4.3.1.12 clearTimeout The clearTimeout method removes the instance of setTimeout that has the handle timeoutId. Format: reader.clearTimeout(timeoutId); Where: timeoutId – program provided timeout ID. 4.3.1.13 shiftJisToUnicode The shiftJisToUnicode method converts a string from Shift-JIS encoding to Unicode encoding. Format: unicodeString = reader.shiftJisToUnicode(text);...
Class Reference Sets the reader communications mode to Bluetooth RF. See also the gui.Button example in section 4.2.3.1. Example: reader.writeSetting(2, 0x7FFFFFFF); Sets the reader Battery Trigger Confirmation Time to 0x7FFFFFFF milliseconds or ~596 hours (effectively infinite time). 4.3.1.15 unicodeToShiftJis The unicodeToShiftJis method converts a string from Unicode encoding to Shift-JIS encoding.
Class Reference Format: function filterCommand(commandType, commandData) var shouldSuppressCommand = false; /* Processing statements */ return !shouldSuppressCommand; reader.onCommand = filterCommand; Where: commandType – string; 1 character; specifies the command being processed. commandData – string; data to be process by the command. Example: function notifyErase(commandType) if ( commandType == ')' )
Class Reference responseData – string; the response data. Example: function finishedCommand(commandSuccess, responseType, responseData) if( !commandSuccess ) alert(postAlertFunc, "Command failed (" + responseType + ":" + responseData + ")"); reader.onCommandFinish = finishedCommand; sends an alert when a command fails. 4.3.2.3 onDecode The onDecode property of the reader object provides processing control to the application program at the completion of a decode action.
Class Reference return null; return decode; reader.onDecode = onDecode; See the discussion of the decode object in section 4.1 Example: See the discussion of symbol decoding in section 0. 4.3.2.4 onDecodeAttempt The onDecodeAttempt property of the reader object provides processing control to the application program at the completion of a decode action, before any of the decoded symbols are passed to reader.onDecode.
Example: function onIdle() reader.processCommand(‘.’, “\x22\x05\x32\x64”); reader.onIdle = onIdle; Flashes both LEDs on the OHV300 green 5 times, with LEDs on for ½ second and off for 1 second. 4.3.2.6 onStandby The onStandby property of the reader object provides processing control to the application program whenever the reader is about to enter the standby mode.
Class Reference Where: return – Boolean; true if the reader should be allowed to enter the standby mode; false to prevent it. Example: function onStandby() if (comm.isConnected) return false; else return true; reader.onStandby = onStandby; Prevents the reader from entering standby if it is connected and allows it to enter standby otherwise.
Class Reference 4.3.2.12 cabled The cabled property of the reader object contains a read only Boolean value containing the cabling state of the handheld hardware. The value will be true if cabled and false if not cabled. Example: cabled = reader.cabled; 4.3.2.13 charging The charging property of the reader object contains a read only Boolean value...
Class Reference 4.3.2.18 bdAddr The bdAddr property of the reader object contains a read only string containing the Bluetooth address of the radio installed in the handheld. Example: bdAddrString = reader.bdAddr; storage The storage object provides application software access to handheld file storage. Files are written to storage by the storage.write method and by downloading from the host (see section 3.7).
Class Reference Format: result = storage.erase(name); Where: name – string; the name of the object to erase. result – Boolean; true if the file existed (the object is deleted); false if the file did not exist. Example: storage.erase("TimeCard” + employeeNumber); Erases the time card record for the employee specified by employeeNumber.
Class Reference Example: name = storage.findNext(); Sets name to the name of the next time card record file. 4.4.1.5 read The storage.read method reads a file. Format and Example: data = storage.read(name); Where: name – string; the name of a file. data –...
Class Reference Format: result = storage.upload(name, withHeaderAndFooter); Where: name – string; the name of a file. withHeaderAndFooter – Optional boolean; If set to false the file is uploaded without the header (ap/g(file size) )and footer (ap/d(checksum)). If the parameter is not included the header and footer will be included with the upload.
Class Reference Example: result = storage.write("TimeCard" + employeeNumber, tcRecord); Writes a time card record to a file. 4.4.1.10 getHeader The storage.getHeader method returns the first multiline comment block from a JavaScript file. This includes encrypted files if the proper developer key is installed. Format and Example: data = storage.getHeader(name);...
Class Reference 4.4.2.2 isFull The storage.isFull property is a read-only Boolean value; true if storage is full and cannot be added to; otherwise, false. 4.4.2.3 logFullness_percent The storage.fullness_percent property is a read-only integer containing the percent of storage in use. comm The comm object models the host commutation feature of the handheld reader.
Class Reference Format: result = comm.sendPacket(type, data); Where: type – string, length 1; the type of packet to send. The packet types are documented in the Interface Configuration Document. data – string; data to be inserted into the packet. result – Boolean; false if there was a failure on the communications port; otherwise, true.
These functions interact with the OHV300 standard GUI display. The OHV300 displays the name of the function in the GUI status bar and the text associated with the function, and then waits until a key is pressed. The following subsections describe the operation of each function in the OHV300 environment.
Class Reference Example: alert(samplefunction, "Status Alert"); Displays the alert shown in Figure 717 and waits until the operator presses the enter key or the left softkey (OK). Once the operator presses a key, it calls samplefunction() to continue. Figure 16 – Alert Example 4.6.1.2 confirm The confirm function displays text in the display area of the standard GUI display and...
Class Reference Figure 17 – Confirm Example If you want softkey labels other than OK and Cancel (for example, Yes and No), use the gui.confirm method (section 4.2.1.2). 4.6.1.3 prompt The prompt function displays text in the display area of the standard GUI display and returns a value based on the key pressed.
“including” script. 4.6.2.3 print The print function sends text to stdout (the active communication port), not to the OHV300 display. Limit the use of the print function to debugging. Use the comm object methods for normal data output to communication ports.
Class Reference 4.6.2.4 setStandbyMessage The setStandbyMessage allows you to create a custom standby message to display when the reader enters standby mode. Format: setStandbyMessage(text); Where: text – string; message to display when the reader enters standby mode. 4.6.2.5 Long processes may require the firmware watchdog to be petted during the operation. If the watchdog times out during a processor intensive operation, the reader will reboot and an error will be logged in the error log (see section 0).
Glossary and Acronyms Glossary and Acronyms Term Definition Control User Class object instantiated in a OHV300 GUI form. OHV300 Handheld reader with Bluetooth for all standard 1-D and 2-D codes with LC display and keyboard Radio Frequency Code Data Data resulting from the decode process after data capture or bar code read...
Input Modes Input Modes The input mode determines the character set that is active for the OHV300 keypad. The modes are described in Table 2. Table 2 – Keypad Input Modes inputMode characters numeric 0123456789 caps A-Z, 0-9 and all ASCII non-alphanumeric symbols: '!', '"', '#', '$', '%', '&', '\'', '(',...
Format Specifiers Format Specifiers The control string of the format function accepts the following codes from the standard C library: signed decimal integers signed decimal integers lowercase scientific notation uppercase scientific notation floating point decimal uses %e or %f , whichever is shorter uses %E or %f, whichever is shorter unsigned octal character string...
Supported JavaScript Core Supported JavaScript Core Objects, Methods, and Properties do...while Array export Boolean Date for...in Function function Math if...else Number import Object label Packages return RegExp switch String throw try...catch Top-Level Properties and Functions while decodeURI with decodeURIComponent Operators encodeURI encodeURIComponent Assignment Operators...
Page 88
Supported JavaScript Core delete function this typeof instanceof void...
Symbology ID & Modifier Information Symbology ID & Modifier Information There are several elements of the decode object that describe properties of the symbology read by the handheld reader. These elements are: decode.symbology – Main Symbology Identifier (ID) decode.symbology_ex – Extended Symbology Identifier (ID_EX) ...
Page 90
Symbology ID & Modifier Information EAN_JAN_8_plus5 EAN_JAN_13_plus2 EAN_JAN_13_plus5 EAN Bookland EAN_UCC 14 Interleaved_2_of_5 (Full symbol decoded) Interleaved_2_of_5 (Partial left-half symbol issued) +1 (add one to existing value) Interleaved_2_of_5 (Partial right-half symbol issued) +2 (add two to existing value) ITF-14 Code39 (Full symbol decoded) Code39 (Partial left-half symbol issued) +1 (add one to existing value)
Page 91
Symbology ID & Modifier Information EAN_JAN_13_w_Code_128_Supplemental 26† num_IBM_symbologies 28† Australia Post Aztec Data Matrix Straight_2_of_5_2_Bar_Start_Stop 32† Straight_2_of_5_3_Bar_Start_Stop Japan Post MSI_Plessey Maxi PDF417 Micro PDF417 PLANET POSTNET Micro QR Royal_Mail_4_State_Customer RSS_Expanded RSS_Expanded_Stacked RSS_Limited RSS_14 RSS_14_Stacked / RSS_14_Stacked_Omni GoCode...
Page 92
Symbology ID & Modifier Information Codablock F Code11 Pharmacode Telepen Hong Kong 2 of 5 Matrix 2 of 5 (checksum not checked) Matrix 2 of 5 (Checksum checked and included in output string) Matrix 2 of 5 (Checksum checked and stripped from output string) NEC 2 of 5 (checksum not checked) NEC 2 of 5 (Checksum checked and included in output...