The text of a manual · part 8 of 36
Trakker Antares Application Development Tools System Manual: Part I - Trakker Antares PSK Reference Manual, pages 65 to 74
Pages 65 to 74 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 65
5
PSK Function Descriptions
This chapter describes the syntax and parameters for each function in the Trakker Antares® Programmer’s Software Kit (PSK) library.
Trakker Antares PSK Reference Manual
45
Page 66
Chapter 5, PSK Function Descriptions
Understanding the Function Descriptions The function descriptions in this chapter use these conventions: • The descriptions refer to many named constant variables, such as IM_COM1. These variables always appear in uppercase and are described in IMT24LIB.H. • The descriptions use common C/C++ notation. • Italic type indicates a variable that you replace with a real value. • Straight quotation marks (" ") indicate literal string entries. Include the quotation marks in the command, such as: char *high_trast ="$+DJ7";.
• You can indent program statements with leading spaces to make your program easier to read. • C/C++ is case sensitive. Follow the capitalization used in the descriptions. The following example (function_name) explains the parts of the function descriptions.
function_name Purpose
Briefly describes the function and its typical use.
Syntax
Lists the C-language function prototype and the required include file.
IN Parameters
Describes the input parameters for the function and lists acceptable values.
OUT Parameters
Describes the output parameters for the function and lists acceptable values.
IN/OUT Parameters
Describes the parameters that are passed into and then back out of the function. Lists acceptable values. The function usually changes the value before returning.
Return Value
Notes
Describes the value returned by the function and lists acceptable values. For more information about the return values, look in the rc.h file, which is at \intermec\imt24\include\rc.h for a standard installation. Describes any additional information about the function.
See Also Lists similar PSK functions.
Example /* A short code segment showing how to use the function.
46
*/
Trakker Antares PSK Reference Manual
Page 67
Chapter 5, PSK Function Descriptions bind Purpose
Syntax
This BSD socket-specific function binds a name to an existing socket. The bind function call specifies the local port number and local IP address of a connection. You can use this function call before the connect call; however, it is not required. int bind(int s, struct sockaddr *name, int namelen);
IN Parameters s name namelen
OUT Parameters
None
Return Value
This function returns one of these values: 0 -1
Notes
Socket identifier. Port number and IP address of the remote host. Size of name.
Success Error
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.
Example /******************************* bind *******************************/ int rc /* return code */ int s; /* socket identifier */ struct sockaddr_in socka; /* IP address and port number */ •••• memset(&socka, 0, sizeof(socka)); socka.sin_family = AF_INET; socka.sin_port = 69;
/* clear socket structure */ rc = bind(s, (struct sockaddr *)&socka, sizeof(socka)); if (rc < 0) printf ("Error: binding\n");
closesocket Purpose Syntax IN Parameters OUT Parameters
This BSD socket-specific function closes the socket. int closesocket(int s)
s
Socket identifier.
None
Trakker Antares PSK Reference Manual
47
Page 68
Chapter 5, PSK Function Descriptions closesocket (continued) Return Value
This function returns one of these values: 0 -1
Notes
Success Error
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.
Example /****************************** closesocket ******************************/ int rc /* return code */ unsigned long addr; /* for octet IP address */ struct sockaddr_in socka; /* IP address and port number */ •••• rc = connect(s, (struct sockaddr *)&socka, sizeof(socka)); if (rc < 0) printf("Error: Error connecting to remote server\n"); •••• rc = closesocket(s); if (rc < 0) printf("Error: Error closing socket\n");
connect Purpose
This BSD socket-specific function initiates a connection on an existing socket. You use this call to perform an active client open and establish a connection with a remote server.
Syntax int connect(int s, struct sockaddr *name, int namelen);
IN Parameters s name namelen
OUT Parameters
None
Return Value
This function returns one of these values: 0 1 -1
48
Socket identifier. Port number and IP address of the remote host. Size of name.
Passive open success Active open success Error
Trakker Antares PSK Reference Manual
Page 69
Chapter 5, PSK Function Descriptions
Notes
You can use im_get_IP_addr to retrieve the IP address. In the example, Iid_SZ is defined as 4, which corresponds to four octets in the dot-quad notation. In the example, &socka, which is of type sockaddr_in*, must be cast to a sockaddr*.
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. See Also socket
Example /******************************** connect ********************************/ int rc /* return code */ unsigned long addr; /* for octet IP address */ struct sockaddr_in socka; /* IP address and port number */ •••• memset(&socka, 0, sizeof(socka));
/* clear socket structure */ rc = im_get_IP_addr(REMOTE_IP, &addr) if(rc < 0) printf("Error: im_get_IP_addr\n");
/* get host addr from HW setup */ socka.sin_family = AF_INET; memcpy((char *)socka.sin_addr, (char *)&addr, Iid_SZ); /* init IP addr */ socka.sin_port = 69; rc = connect(s, (struct sockaddr *)&socka, sizeof(socka)); if (rc < 0) printf("Error: Error connecting to remote server\n");
DisplayUserBMP Purpose Syntax IN Parameters
This function displays a .BMP file on the terminal screen at a specified location. USHORT far DisplayUserBMP(char *name, IM_SHORT row, IM_SHORT col);
name row col
OUT Parameters
Pointer to a string containing the file name of the .BMP file. The top row where the upper left corner of the .BMP file will be displayed. The left column where the upper left corner of the .BMP file will be displayed.
None
Trakker Antares PSK Reference Manual
49
Page 70
Chapter 5, PSK Function Descriptions
DisplayUserBMP (continued) Return Value
This function returns one of these codes: IM_SUCCESS E_MALOC E_FOPEN
Success Insufficient memory to process the .BMP file Cannot open or find the .BMP file fcntlsocket Purpose
This BSD socket-specific function sets or resets the non-blocking or blocking, respectively. You can also use the fcntlsocket function call to get the current state of the non-blocking flag. Networking only uses one flag, FNDELAY or O_NDELAY, for non-blocking I/O. The networking commands are: F_GETFL F_SETFL
Syntax int fcntlsocket(int s, int cmd, int arg);
IN Parameters s cmd arg
OUT Parameters
None
Return Value
Socket identifier. Command specifying a get or set. Argument specifying blocking or non-blocking.
This function returns one of these values: 0 -1 flag
Notes get flags set flags
Successful SETFL Error Current value of the flags for successful GETFL
After a socket is created and before any read, you should use the fcntlsocket function to set up a non-blocking read there after. 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.
Example /****************************** fcntlsocket ******************************/ int rc; /* return value */ int s; /* socket identifier */ •••• rc = fcntlsocket(s, F_SETFL, FNDELAY); /* set sockets for non-blocking */ if(rc < 0) printf("Error setting flag\n"); rc = fcntlsocket(s, F_SETFL, 0); /* set sockets for blocking */ if(rc < 0) printf("Error setting flag\n");
50
Trakker Antares PSK Reference Manual
Page 71
Chapter 5, PSK Function Descriptions im_battery_status Purpose
Syntax
IN Parameters OUT Parameters
Return Value
This function checks the status of the main battery and returns a number from 0 to 100 (in increments of 10) that indicates the amount of charge in the battery. #include "imt24lib.h" IM_STATUS im_battery_status (IM_SHORT *main_battery_level);
None main_battery_level
Specifies the status of the main battery and is a number from 0 to 100, in increments of 10, where a 0 indicates that the battery has no charge left, and a 100 indicates that the battery is fully charged.
This function returns one of these codes: IM_SUCCESS IM_MAIN_BATTERY_ERROR IM_MAIN_BATTERY_CHARGING
Success Error testing the battery, or the battery is not installed Battery is charging now
Example // example of checking battery status and printing the status. #include <stdio.h> #include "imt24lib.h" void main(void) { IM_STATUS iStatus; IM_USHORT bLevel;
//status //battery status iStatus = im_battery_status(&bLevel); if(iStatus==IM_OK && bLevel > 50) printf("Good Battery\n"); else printf(“No or bad battery - Replace\n”); }
Trakker Antares PSK Reference Manual
51
Page 72
Chapter 5, PSK Function Descriptions im_clear_screen Purpose Syntax
This function erases the entire display and moves the cursor to the upper left corner (home). #include "imt24lib.h" void im_clear_screen (void);
IN Parameters
None
OUT Parameters
None
Return Value
None
See Also im_erase_display; im_erase_line
Example See example for im_command on page 54.
im_closedir Purpose Syntax
IN Parameters OUT Parameters Return Value
This function closes the directory structure opened with im_opendir. #include "imstdio.h" IM_STATUS im_closedir (IM_READDIR *pzOpenDir)
pzOpenDir None
This function returns one of these codes: IM_SUCCESS Any other value
Notes
Pointer to the current open read directory structure.
Success Fail
This function works with im_opendir and im_readdir.
See Also im_opendir, im_readdir.
Example See example for im_opendir on page 123.
52
Trakker Antares PSK Reference Manual
Page 73
Chapter 5, PSK Function Descriptions im_command Purpose
Syntax
This function sends reader commands to the terminal. For example, you can use this function to toggle the backlight, set the contrast, or change the beep volume on the terminal. For more information on using terminal commands, see “Using Reader Commands” and “Using Configuration Commands” in the Trakker Antares 2400 Family System Manual (P/N 071389). #include "imt24lib.h" IM_STATUS im_command (IM_UCHAR far *command, IM_USHORT command_length);
IN Parameters command command_length OUT Parameters Return Value
Terminal command string that may include more than one command. For example, the command string %.1$+BV9 turns on the backlight and raises the beep volume. Your Trakker Antares terminal user’s manual lists all of the commands available to the terminal. Length of the terminal command string.
None This function returns one of these codes: IM_SUCCESS IM_PARSE_ERROR
Notes
Successfully parsed and implemented command Unable to parse command
Command strings must be included in quotation marks. If you are using ANSI escape sequences in the command string, such as “$+PF\x02”, and you are not using STRLEN() to get the length, the escape sequences count as one character. For example: im_command ("$+PF"\x02"",7); /*wrong*/ im_command ("$+PF"\x02"",5); /*right*/
For more information on using reader commands, see the Trakker Antares 2400 Family System Manual (P/N 071389).
Trakker Antares PSK Reference Manual
53
Page 74
Chapter 5, PSK Function Descriptions im_command (continued)
Example /********************* im_command ************************************/ #include <string.h> #include "imstdio.h" #include "imt24lib.h" void main (void) { /* Command string to set contrast */ char *high_trast ="$+DJ7"; /* 7 (dark) */ char *normal_trast ="$+DJ3"; char *low_trast ="$+DJ0"; /* 0 (light)*/ im_clear_screen(); /* Set high contrast */ printf("\nSet high contrast\n"); im_command(high_trast, strlen(high_trast)); /* Wait for two seconds */ im_standby_wait(2000); /* Set low contrast */ printf("Set low contrast\n"); im_command(low_trast, strlen(low_trast)); /* Wait for two seconds */ im_standby_wait(2000); /* Set normal contrast */ printf("Set normal contrast\n"); im_command(normal_trast, strlen(normal_trast)); } im_cputs Purpose Syntax
54
This function places a string on the screen at the current cursor location without appending a carriage return and line feed (CR LF) to the string. #include "imt24lib.h" IM_STATUS im_cputs (IM_UCHAR far *string, IM_ATTRIBUTES attrib);
Trakker Antares PSK Reference Manual