The text of a manual · part 25 of 40
2D JANUS PSK for C/C++ Reference Manual, pages 241 to 250
Pages 241 to 250 of 400
The original document is the PDF (793 KB). 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 Intermec J2020, Intermec J2010 and Intermec J2050
Page 241
4 Advanced Programming
Page 242
blank
Page 243
Advanced Programming
4
This chapter explains the various reader input modes and how to use the power management software.
Reader Input Modes Reader input modes affect how scanned input is interpreted and stored by the reader. You can control input modes by: • Using the reader commands described in your JANUS user’s manual. • Using the im_get_input_mode and im_set_input_mode commands described in Chapter 2, “C Language Support.” There are three different input modes: • Wedge mode • Programmer mode • Desktop mode
Wedge Mode In Wedge mode, keypad and label inputs go into the keyboard buffer with minimal filtering. Wedge mode is the default mode at the DOS prompt after reader services are loaded (RSERVICE.EXE). Use this mode when the reader is running an application that uses the Virtual Wedge. For more information about the Virtual Wedge, see Chapter 1, “Getting Started.” When the reader is in Wedge mode, use standard input functions such as getch to retrieve keypad or label input. Do not use the methods described for other modes. Wedge mode does not take full advantage of the reader power management capabilities. You will probably notice reduced battery life when the reader is in Wedge mode.
4-3
Page 244
2D JANUS PSK for C/C++ Reference Manual
Programmer Mode In Programmer mode, keypad input is echoed to the screen as the keys are pressed. Any reader commands that you enter are executed and saved. Use this mode when the reader is executing Interactive Reader Language (IRL) commands such as im_irl_a or im_irl_k.
Desktop Mode In Desktop mode, the application is responsible for retrieving and displaying keypad input. Use this mode when you need detailed information about the pressed key. Use the input function im_receive_input to capture the keys pressed. Each character returned uses the structure IM_KEYCODE, described in IM20LIB.H. This structure consists of four bytes: the ASCII code, the scan code, and two bytes of keyboard flags (Shift, Control, Alt).
Differences in Input Modes Programmer mode and Desktop mode differ only in how they handle keypad inputs. In programmer mode, keypad entry terminates when you press the Enter key. In desktop mode, keypad entry terminates each time you press a key. Do not use functions such as getch to retrieve input when the reader is in Desktop or Programmer modes. The internal software intercepts any input before functions such as getch can receive it, and the application waits forever on that instruction. In Wedge mode, label input is placed directly into the keyboard buffer. In Programmer and Desktop modes, label input is not placed into the keyboard buffer. It is, however, retrieved in a manner similar to the way keyboard data is retrieved. An example of handling reader input is given below. Note: For the reader to function as a bar code reader, LOADSYMB.EXE must be loaded. RDG.BAT loads both reader services (RSERVICE.EXE) and the decode algorithms (LOADSYMB.EXE).
4-4
Page 245
Advanced Programming
4
Example: Input Modes // This example demonstrates reader input from either the keyboard or a label. Additional // sources (or a single source) can be given. All possible sources, including COM ports, // can be selected using IM_ALL_SELECT. // // In programmer mode, the im_receive_input() function returns after the Enter key is // pressed. In desktop mode, the im_receive_input() function returns after each // key is pressed. // // This method is used primarily to receive input from multiple sources when you do not // know the input source. char input[80]; IM_ORIGIN source; IM_DECTYPE symbol; IM_STATUS istatus im_set_input_mode(IM_PROGRAMMER);
// Input buffer (user sets the length) // Source(s) where input is to come from // Symbology (for label input) // Can also be IM_DESKTOP (but not IM_WEDGE)
istatus = im_receive_input (im_keyboard_select | im_label_select, im_infinite_timeout, &source, input); if (source = = IM_KEYBOARD_SELECT) { printf("Input from keyboard\n"); } if (source = = IM_LABEL_SELECT) { printf("Input from scanner\n"); } printf("%s\n", input);
4-5
Page 246
2D JANUS PSK for C/C++ Reference Manual
Receiving Serial Data There are two methods for receiving serial data: • Reader service routines that allow multiple inputs • Communications routines that use the INT 14H BIOS extensions The method you use depends on how you want to receive keypad and label data. Both of these methods are valid in Desktop mode and Programmer mode. With minor modifications, these methods will work in Wedge mode.
CAUTION
Caution Do not mix reader service routines with communications routines: a usable response is not returned. Conseil Ne mélangez pas les routines de révision lecteur à des routines de communication: aucune réponse utilisable ne sera renvoyée.
Reader Services Routines You can use reader service routines that include communications port inputs by following these application requirements: • At the beginning of your application, link the reader service input functions using a call to im_link_comm. At the end of your application, unlink them with a call to im_unlink_comm. • Enable or disable the protocol using im_serial_protocol_control. The default is to have the protocol enabled. • Clear the receive buffer by disabling and then enabling the protocol. Do not use im_cancel_rx_buffer when using this method because it stops the reader from communicating.
4-6
Page 247
Advanced Programming
4
Example: Reader Services // This example shows how to accept input from either the keyboard or from a serial // port. The function im_receive_input( ) is given two sources: keyboard or COM1. // Additional sources (or a single source) can be given. Use IM_ALL_SELECT to select // all possible sources (including label input). // // This program waits for input, and then makes it available by calling // im_receive_input( ). // // Use this method when you want to receive input from multiple sources and you don’t know // the input source. // // This is not a complete program, but it demonstrates the required function calls. char input[300]; // Input buffer (user sets the length) char com_buff[300]; // Used by Communications link only IM_ORIGIN source; // Source(s) where input is to come from IM_STATUS status; // Results of call im_set_input_mode(IM_PROGRAMMER);
//
// In this example, the mode might be IM_DESKTOP // (but not IM_WEDGE). If the reader is in // IM_WEDGE mode, use a function like gets( ) // to retrieve keyboard and label input. // The only sources that can be ORed together in // IM_WEDGE mode are COM ports.
im_link_comm(IM_COM1, com_buff, 300); // Link to reader services input routines // Wait for input from either the keyboard or from COM 1 status = im_receive_input (IM_KEYBOARD_SELECT | IM_COM1_SELECT, IM_INFINITE_TIMEOUT, &source, input); // Data is now available in the buffer input if (status == IM_RW_SUCCESS) im_transmit_buffer(IM_COM1, strlen(input), input, 1000); im_unlink_comm(IM_COM1);
// Transmit data with // a 1-second timeout // Unlink from reader services input routines
4-7
Page 248
2D JANUS PSK for C/C++ Reference Manual
Communications Routines You can use communications routines with the INT 14H BIOS extensions by following these application requirements: • Do not link your application with the reader service input functions (do not call im_link_comm). • Use either im_receive_buffer or im_receive_buffer_noprot to select communications with or without protocol. • Use im_cancel_rx_buffer to clear the receive buffer.
Example: Communications Routines // This example shows how input is requested from a single source. This function waits // for input and then puts it into the specified buffer. // In programmer mode, keyboard entry terminates when you press the Enter key. In desktop // mode, keyboard entry terminates when you press each key. IM_UCHAR IM_USHORT far IM_DECTYPE input[300]; num_chars; symbol;
// Input buffer (user sets the length)
im_set_input_mode(IM_PROGRAMMER);
// Could be any mode im_receive_buffer(IM_COM1, 300, input, 1000, &num_chars); im_transmit_buffer(IM_COM1, strlen(input), input, 1000);
4-8
// Get serial input (timeout) // is 1-second) // Transmit data with a // 1-second timeout
Page 249
Advanced Programming
4
Transmitting Serial Data With Intermec protocol handlers, you transmit serial data by calling the communications routines included with the PSK. These routines are im_transmit_buffer, im_transmit_buffer_no_wait, and im_transmit_buffer_noprot. These communications routines all use the INT 14H BIOS extensions. You can transmit a maximum of 254 bytes in one record. Make the buffer size somewhat larger (300 bytes is typically used) to allow adequate memory for protocol characters that might also be transmitted. If the buffer is too small, you will overwrite other memory locations.
Communications Port UART Modes If you turn off your JANUS reader while running a communications application that uses COM1 or COM2, the reader cannot save the UART FIFO control register. The reader uses the UART restore configuration setting to reset the FIFO control register when the reader is turned back on. You need to set a restore value if the default value, 0 hex, is not appropriate for your reader. You must set a restore value in these two cases: • Your application is using COM1 without using an Intermec protocol handler. • Your application is using COM2 and changes the reader’s COM2 UART FIFO control register to use UART 16x550 mode. See the communications application’s manual to determine if it uses UART 16x550 mode. You can also reset the FIFO control register using software interrupts. For more information, see INT 78H, function 06H, in Chapter 3, “Software Interrupts.”
4-9
Page 250
2D JANUS PSK for C/C++ Reference Manual
Display “Color” You can set the reader display to various foreground and background shades. A SMARTMAP™ scheme compares and adjusts the foreground and background gray values on a character-by-character basis to produce adequate display contrast on monochrome LCD panels. With this scheme, commercially written color software packages can be used on a monochrome display with acceptable differentiation of colors using shades of gray. The default color setting on a PC is white on black. However, the best default setting on a monochrome display is black on white. For this reason, setting a color to black actually sets white on black, and setting a color to white actually sets black on white. To display colors other than just black and white, you should experiment with various color combinations to find an appropriate setting. The shade of a specific foreground color varies depending on the background color setting. Borland C/C++ changes the foreground color by using textcolor(int newcolor) where newcolor is an integer between 0 and 15. Adding 128 to newcolor sets the most significant byte and makes the character blink. The background color is set using textbackground(int newcolor) where newcolor is an integer between 0 and 7. These colors are only applicable when using functions that do direct video output (such as cprintf). Microsoft C/C++ changes the foreground color by using _settextcolor(short index) where index is an integer between 0 and 15. Adding 16 to index sets bit 4 and makes the character blink. The background color is set using _setbkcolor(long index) where index is an integer between 0 and 7. These colors are only applicable when using functions that do direct video output (such as _outtext).
4-10