The text of a manual · part 4 of 36
Trakker Antares Application Development Tools System Manual: Part I - Trakker Antares PSK Reference Manual, pages 25 to 34
Pages 25 to 34 of 340, from Trakker Antares Application Development Tools System Manual
The original document is the PDF (1.6 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.
Filed in the catalog under the Intermec 2420, Intermec 2425, Intermec 2435 and Intermec 2481
Page 25
2
Programming Guidelines
This chapter explains the types of functions included in the PSK library and lists the Intermec-certified C runtime library functions. Refer to this chapter for guidance in selecting Intermec functions and valid Microsoft® C functions or the equivalent Borland® C functions. This chapter covers these topics: • What is the PSK library • Communications functions • Display functions • Input functions • Sound function • Status code macros • System functions • Viewport functions • Certified Microsoft C functions • Unsupported Microsoft C/C++ functions
Trakker Antares PSK Reference Manual
5
Page 26
Chapter 2, Programming Guidelines
What Is the PSK Library? The PSK library is a library of C functions for programming the Trakker Antares® terminals. You can program a terminal to display prompts and error messages, to collect and display data, and to transmit data to the Intermec Gateway, a DCS 30X, or a host. You can also design beep sequences for audio feedback. The PSK functions work with most standard Microsoft® C functions and the equivalent Borland® C functions. You can create complex applications that collect, store, manipulate, and transmit data to meet your system needs. The PSK is packaged as libc.lib and ships with these files: • imt24lib.h • imstdio.h • pollux.h Include the Intermec header file imstdio.h instead of the Microsoft header file stdio.h, and include imt24lib.h. You can put libc.lib and the header files in any folder or directory as long as you set up the project to retrieve the library at link time. Although libc.lib is sometimes referred to as the PSK, the term PSK also refers to Intermec-specific library functions. These functions are usually in the form of im_function_name.
Communications Functions Use the communications functions to send or receive data through a communications port, to check the buffer status for a port, or to cancel a transmission. You can transmit and receive the contents of a buffer or a file. You can also receive data or one or more characters from the keyboard, scanner, or communications port. You can specify several input sources, and then test for a specific source before acting on the input. You can transmit a maximum of 1024 bytes in one record. For more information about programming with the network communications functions, see “Programming Guidelines for Network Communications” on page 24.
6
Trakker Antares PSK Reference Manual
Page 27
Chapter 2, Programming Guidelines
Trakker PSK Communications Functions im_flush_rcv_buffer im_transmit_buffer im_get_rcv_errors im_transmit_buffer_no_wait im_get_rx_status im_transmit_buffer_no_wait_t im_get_tx_status im_transmit_file im_receive_buffer im_udp_close_socket im_receive_field im_udp_open_socket im_receive_file im_udp_receive_data im_receive_input im_udp_send_data im_set_eom im_xm_receive_file im_set_no_autosend im_xm_transmit_file im_set_validation_callback im_xm1k_receive_file im_standby_wait im_xm1k_transmit_file im_status_line im_ym_receive_file im_tcp_reconnect_notify im_ym_transmit_file
Example: Receiving Data From the NET Port or From the Keyboard // This segment 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. #include "imt24lib.h" void main() { char input[1024]; characters) IM_ORIGIN source; IM_STATUS status;
// Input buffer (input from network must be 1024 // Source(s) where input is to come from // Results of call
// Wait for input from either the keyboard or from NET status = im_receive_input (IM_KEYBOARD_SELECT | IM_NET_SELECT, IM_INFINITE_TIMEOUT, &source, input); // Data is now available in the buffer input // if (status == IM_SUCCESS) // Add your code segment here }
Trakker Antares PSK Reference Manual
7
Page 28
Chapter 2, Programming Guidelines
BSD Sockets The Trakker Antares TCP/IP terminals (firmware version 6.20 or later) support a subset of the BSD (Berkeley Software Distribution) sockets interface for network communications. The terminals support this subset of BSD 4.3 socket-specific functions: Trakker PSK BSD 4.3 Socket-Specific Functions bind im_get_IP_addr (gethostbyname)
closesocket recv connect send fcntlsocket socket
The Trakker Antares socket interface supports the BSD sockets function calls and requires function calls that are different for the client and the server. You can use the Trakker Antares socket interface to create the following types of sockets: • SOCK_STREAM
Stream socket (TCP/IP)
• SOCK_DGRAM
Datagram socket (UDP/IP)
When programming with BSD socket functions, keep these important points in mind: • A BSD socket can be any combination of an IP address and a port. However, the Trakker Antares socket interface operates with one host or controller IP address that is set using the TRAKKER Antares 2400 Menu System. The client port number can also be set using the Main Menu. • BSD socket functions do not support low power pending functions, such as the functional equivalent functions im_receive_input, im_receive_field, im_receive_buffer, and im_event_wait. Therefore, if you choose to use BSD socket functions for input, you may adversely affect battery life. • After a socket is created and before any read, you should use the fcntlsocket function to set up a non-blocking read there after. For more information, see “fcntlsocket” on page 50.
Using the sockaddr_in Structure
The socket functions use a sockaddr structure to pass internet addresses and port numbers. The generic sockaddr structure accepts communications protocols. Because the Trakker Antares terminals use the internet protocol (IP), the socket functions use the internet version of the structure sockaddr_in.
8
Trakker Antares PSK Reference Manual
Page 29
Chapter 2, Programming Guidelines
Although the generic sockaddr structure is not used by the Trakker Antares socket functions, it is provided as a reference for the standard socket interface. Values are assigned to sockaddr and passed to the socket routine through the sockaddr parameter. This action requires a typecast to a sockaddr*. For an example of a typecast to a sockaddr*, see “connect” on page . The generic sockaddr structure is defined as follows: struct sockaddr /* generic socket address */ { unsigned short sa_family; /* address family */ char sa_data[14]; /* up to 14 bytes of direct address */ }
For the socket functions used on Trakker Antares terminals, the structure that is passed to the socket routine is sockaddr_in. This structure is assigned values and typecast to a sockaddr* when it is passed to a socket function. For an example of a typecast to a sockaddr*, see “connect” on page . The sockaddr_in structure is defined as follows: struct in_addr { unsigned long s_addr; /* Internet address */ struct sockaddr_in /* Internet socket address */ { short sin_family; unsigned short sin_port; struct in_addr sin_addr; char sin_zero[8]; } }
Display Functions Use the display functions to change or retrieve the display attributes. You can define screen size, font size, inverse and blinking characters, and cursor shape. You can also send text to the screen, erase all or part of the display, and relocate the cursor. Trakker PSK Display Functions DisplayUserBMP im_get_display_type im_puts_dbyte * im_clear_screen im_get_follow_cursor im_puts_kana_8x16 * im_cputs im_get_screen_char im_puts_mixed * im_display_thai_char im_get_text im_set_cursor_style im_erase_display im_overlay_setup * im_set_cursor_xy im_erase_line im_overlay_status * im_set_display_mode
Trakker Antares PSK Reference Manual
9
Page 30
Chapter 2, Programming Guidelines
Trakker PSK Display Functions (continued) im_get_cursor_style im_put_text im_set_follow_cursor im_get_cursor_xy im_putchar im_set_mixed_mode * im_get_display_mode im_putchar_dbyte * im_set_screen_size im_get_display_size_physical im_putchar_kana_8x16 * im_set_thai_cursor_mode im_get_display_size_virtual im_puts im_setup_follow_cursor im_get_dbyte_font_info
Note: The 2460 and 2461 terminals do not support double-byte functions, which are indicated in the list with asterisks (*).
Example: Clearing the Screen // This segment clears the display and returns the cursor to the // upper left corner. // Next, it sets the cursor to an underline. // #include "imt24lib.h" void main() { IM_STATUS status;
// Results of call im_clear_screen(); status = im_set_cursor_style (IM_UNDERLINE); // Add your code segment here }
Input Functions Use the input functions to receive data or to retrieve the length or bar code symbology of previous input. You can receive a file, a field, a buffer, or one or more characters from the keyboard, scanner, or communications port. For compatibility with JANUS® devices, the PSK supports input mode functions. For more information on input modes, see Chapter 4, “Converting Trakker Antares and JANUS Applications.” Trakker PSK Input Functions
10 im_dbyte_symbology_set * im_get_sensor_all im_file_size im_get_sensor_input im_file_time im_input_status im_flush_rcv_buffer im_readdir im_free_mem im_receive_buffer im_free_space im_receive_field
Trakker Antares PSK Reference Manual
Page 31
Chapter 2, Programming Guidelines
Trakker PSK Input Functions (continued) im_get_input_mode im_receive_input im_get_label_symbology im_set_input_mode im_get_label_symbologyid im_set_repeat_key im_get_length im_set_scanning im_get_rcv_errors im_set_validation_callback im_get_relay
Note: The 2460 and 2461 terminals do not support double-byte functions, which are indicated in the list with asterisks (*).
Example: Setting Input Mode and Source // This segment sets the terminal in programmer mode to accept a // string of characters. // The string is NOT sent until you press Enter, and you can use backspace to // make a correction before pressing Enter. // #include "imstdio.h" #include "imt24lib.h" void main() { IM_UCHAR input [1024]; IM_STATUS status; // Results of call IM_USHORT source; // Input sources im_clear_screen(); im_set_input_mode(IM_PROGRAMMER); printf("Scan or Type data.\nPress Enter to \nend line.\n"); /* Request input from label or keypad*/ source = IM_LABEL_SELECT | IM_KEYBOARD_SELECT; status = im_receive_input(source, IM_INFINITE_TIMEOUT, &source, input);
}
Sound Function Use the im_sound function anytime to make the terminal beep. You can use this function to control the volume, pitch, and duration of the terminal beep.
Trakker Antares PSK Reference Manual
11
Page 32
Chapter 2, Programming Guidelines
Example: Sound // This segment beeps a high note, pauses 5 seconds, and then beeps a // low note. #include "imt24lib.h" void main() { im_sound( IM_HIGH_PITCH, IM_BEEP_DURATION, IM_NORMAL_VOLUME); im_standby_wait(5000); im_sound( IM_LOW_PITCH, IM_BEEP_DURATION, IM_NORMAL_VOLUME); }
Status Code Macros Use the status code macros to determine the success of a function without testing for an explicit value. Each PSK library function returns a specific status value. For most functions, you only need to know if the result was success or failure. Your program is easier to maintain, update, and port to another terminal type when you check for success or failure instead of checking for a specific value. Status Code Macros to Determine Success or Failure of a Function Status Code Macro IM_ISERROR(status) IM_ISSUCCESS(status) IM_ISGOOD(status) IM_ISWARN
Return Value nonzero
Meaning error zero (0)
success or warning nonzero success or warning zero (0)
error nonzero success zero (0)
warning or error nonzero warning zero (0)
success or error
For more information, see Chapter 5, “PSK Function Descriptions.” Note: For compatibility with other Intermec products, use the status code macros. You can use the exact status code for debugging programs, but you need to adjust the routines before you attempt porting the application to a JANUS device. For help, see Chapter 4, “Converting Trakker Antares and JANUS Applications.”
12
Trakker Antares PSK Reference Manual
Page 33
Chapter 2, Programming Guidelines
Example: Status Code Macros /* This segment requests label input and then checks for success. /* If successful, then retrieve the label symbology. /* If an error occurs, then display the error message. #include "imt24lib.h" void main() { char input[1024]; characters) IM_ORIGIN source; IM_STATUS status; IM_DECTYPE symbol;
*/ */ */
// Input buffer (input from network must be 1024 // Source(s) where input is to come from // Results of call // Symbology status = im_receive_input(IM_LABEL_SELECT, IM_INFINITE_TIMEOUT, &source, input); if ( IM_ISSUCCESS(status)) im_get_label_symbology( &symbol); if ( IM_ISERROR(status)) im_message(status); }
System Functions Use the system functions to control the terminal configuration or to set an event timer. Trakker PSK System Functions im_battery_status im_get_system_julian_date im_closedir im_message im_command im_offset_dbyte * im_event_wait im_opendir im_file_duplicate im_set_input_mode im_fmalloc im_set_optical_callback im_free im_set_relay im_free_mem im_set_time_event im_free_space im_tcp_reconnect_notify im_get_config_info im_timed_status_line
Note: The 2460 and 2461 terminals do not support double-byte functions, which are indicated in the list with asterisks (*).
Trakker Antares PSK Reference Manual
13
Page 34
Chapter 2, Programming Guidelines
Example: Configuring the Terminal // This segment turns on the terminal backlight and raises the volume. #include "imt24lib.h" void main() { char *setlite_vol="%.1$+BV9"; beep volume IM_USHORT length=8;
//
Turn on backlight and raise
//
Command is 8 characters long im_command(setlite_vol, length); }
Viewport Functions Use the viewport functions to turn on the virtual display and move around in the virtual display. The terminals can use a virtual display that is 25 lines high by 80 characters wide, the same as a CGA monitor. Trakker PSK Viewport Functions im_cursor_to_viewport im_viewport_getxy im_get_viewport_lock im_viewport_home im_get_viewporting im_viewport_move im_set_cursor_style im_viewport_page_down im_set_follow_cursor im_viewport_page_left im_set_viewport_lock im_viewport_page_right im_set_viewporting im_viewport_page_up im_setup_follow_cursor im_viewport_setxy im_setup_manual_viewporting im_viewport_to_cursor im_viewport_end
Note: The 2460 and 2461 terminals do not support viewporting functions.
Example: Moving the Viewport // This segment turns on the viewport and then moves the viewport one page to // the right. #include "imt24lib.h" void main() { IM_STATUS status;
// Results of call im_set_viewporting (IM_ENABLE); status = im_viewport_page_right(); }
14
Trakker Antares PSK Reference Manual