The text of a manual · part 22 of 36
Trakker Antares Application Development Tools System Manual: Part I - Trakker Antares PSK Reference Manual, pages 205 to 214
Pages 205 to 214 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 205
Chapter 5, PSK Function Descriptions
IM_ORIGIN iSource; IM_STATUS iStatus; im_set_viewporting( IM_DISABLE ); im_clear_screen(); im_command("$+DA1", 5); /* Turn on the time in seconds display */ dpHeader(); im_puts (" Default App ", IM_BOLD); puts ("\n\rKeypad input with\n\ra comma in the \n\rfirst 6 chars and\n\rscanned input will \n\rbe transmitted\n\r"); /* Set the timer event so can update clock once per second */ iStatus = im_set_time_event(1000); /* forever and ever just watch for input and send it up, */ /* and display any return messages */ for (;;) { /* event wait is only needed b/c IM_TIMER_SELECT is not an input event */ /* so not handled by im_receive_input. Normally next 2 lines not needed */ iSource = IM_ALL_SELECT | IM_TIMER_SELECT; im_event_wait ( IM_INFINITE_TIMEOUT, &iSource ); if ( !( iSource & IM_TIMER_SELECT )) /* not a timeout so get data */ { iStatus = im_receive_input(IM_ALL_SELECT , IM_INFINITE_TIMEOUT , &iSource, gszString); if ( iSource & IM_KEYBOARD_SELECT ) /**/ { ii =strcspn ( gszString, ","); if ( ( ii<= 6) && (ii < strlen(gszString) ) ) { TryTransmit (gszString); } } else if ( iSourse & IM_LABEL_SELECT ) /**/ { TryTransmit (gszString); } else if ( iSource & IM_NET_SELECT ) /* strip the data identifier and display */ { ii = strcspn ( gszString, ","); im_puts("\n\rReceived:", IM_INVERSE); if ( ( ii<= 6) && ( ii > 0 ) && (ii+i < strlen(gszString) ) ) { im_puts ( &gszString[ii+i], IM_BOLD ); } else im_puts ( gszString, IM_BOLD ); } } /* end of not timer */ do Header(); iStatus = im_set_time_event( 1000); } }
Trakker Antares PSK Reference Manual
185
Page 206
Chapter 5, PSK Function Descriptions im_transmit_file Purpose Syntax
IN Parameters
This function transmits a file to the Intermec Gateway, DCS 30X, or to a TFTP server via a TCP/IP direct connection. #include "imt24lib.h" IM_STATUS im_transmit_file (IM_UCHAR far *trakker_file, IM_UCHAR far *con_file);
trakker_file con_file
Drive letter and name for the source file on the Trakker Antares terminal. This parameter can be a string in quotes or a far pointer to a variable containing the filename. The Trakker Antares terminals do not use directories. All file names use the format: drive:abcdefgh.ext Destination name and path of the file on the Intermec Gateway, DCS 30X, or the TFTP server. This parameter can be a string in quotes or a far pointer to a variable containing the filename.
Note: If you are using UDP Plus, you must specify a path relative to D:\USERDATA on the Intermec Gateway or the DCS 30X to save the transmitted file. If you are using TCP/IP, you can use any valid path on the TFTP server to save the transmitted file. OUT Parameters Return Value
None This function returns one of these codes: IM_SUCCESS IM_GENERR
IM_NET_BAD_CTRL_BLOCK IM_NET_BAD_DATA IM_NET_FULL IM_NET_NOT_READY Notes
186
Successfully transferred file to the terminal. Error occurred. View the error log from the Trakker Antares menu system. Net control block pointer is null. Data pointer is null or invalid data length. Send buffer contains a previous application message. Network not active or not properly configured.
If the terminal has UDP Plus loaded, this function transmits a file to the Intermec Gateway or the DCS 30X. If the terminal has TCP/IP loaded, this function transmits a file to a TFTP server through a TCP/IP direct connection.
Trakker Antares PSK Reference Manual
Page 207
Chapter 5, PSK Function Descriptions
See Also im_cancel_rx_buffer, im_receive_buffer, im_receive_field, im_receive_input, im_rx_check_status
Example /********************* im_transmit_file ******************************/ #include <string.h> #include <conio.h> #include "imstdio.h" #include "imt24lib.h" void main ( void ) { char szControllerFileName1[] = "controlr.txt"; char szControllerFileName2[] = "check.txt"; char szAntaresFileName[] = "c:antares.txt"; IM_STATUS iStatus; im_clear_screen(); /* Receive file from the controller and place it on the Antares file system */ iStatus = im_receive_file ( szControllerFileName1, szAntaresFileName ); if(iStatus == IM_SUCCESS) { printf("Receive file \nsuccess\n"); } else { printf("Receive File Error: \n"); im_message(iStatus); } /* Transmit file from Antares file system back to the controller */ iStatus = im_transmit_file ( szAntaresFileName, szControllerFileName2 ); if(iStatus == IM_SUCCESS) { printf("\nTransmit file \nsuccess\n"); } else { printf("\nTransmit File Error: \n"); im_message(iStatus); } getch(); }
Trakker Antares PSK Reference Manual
187
Page 208
Chapter 5, PSK Function Descriptions im_udp_close_socket Purpose
Syntax
IN Parameters
This function requests the Intermec Gateway or the DCS 30X to close a direct socket connection on behalf of the client application. This function should only be used on terminals with UDP Plus. Do not use this function on terminals running TCP/IP. #include "imt24lib.h" IM_STATUS im_udp_close_socket (IM_UCHAR session_id, IM_USHORT error_code, IM_UCHAR far *error_text, IM_LTIME timeout);
session_id error_code error_text timeout
OUT Parameters Return Value Notes
Session number of the direct socket connection to close. Optional error code to be placed in the Intermec Gateway or the DCS 30X error log file. This code must be greater than 0 and is entirely the discretion of the client application. If no code is specified, this argument should be 0. Far pointer to optional null-terminated error text to be placed in the Intermec Gateway or the DCS 30X error log file. This text is entirely the discretion of the client application. If there is no text, this argument should be 0. Number in the range of 1 to 65,534 ms or one of these constants: IM_ZERO_TIMEOUT No wait IM_INFINITE_TIMEOUT Wait forever
None This function returns a status code that is defined in Appendix A. Do not use IM_INFINITE_TIMEOUT because this function will never return if the unit cannot send the CLOSE request.
See Also im_udp_send_data, im_udp_receive_data, im_udp_open_socket
Example See example for im_udp_receive_data on page 193.
188
Trakker Antares PSK Reference Manual
Page 209
Chapter 5, PSK Function Descriptions im_udp_open_socket Purpose
Syntax
IN Parameters
This function requests the Intermec Gateway or the DCS 30X to open a direct socket connection to a specified host on behalf of the client application. The host must be a server application that passively waits on a selected port for client connections. This function should only be used on terminals with UDP Plus. Do not use this function on terminals running TCP/IP. #include "imt24lib.h" IM_STATUS im_udp_open_socket (IM_UCHAR session_id, IM_USHORT port_num, IM_UCHAR far *host_name, IM_LTIME timeout);
session_id port_num host_name timeout
OUT Parameters Return Value Notes
Session number the Intermec Gateway or the DCS 30X uses to identify the connection. Any data sent or received regarding this connection uses this session number. A maximum of 255 sessions may be opened (0 - 254). Port number you are connecting to on the host. Name or IP address of the host. This name must be defined in the Intermec Gateway or the DCS 30X Telnet Terminal Emulation Configuration screen. An IP address may be used instead. Number in the range of 1 to 65,534 ms or one of these constants: IM_ZERO_TIMEOUT No wait IM_INFINITE_TIMEOUT Wait forever
None This function returns a status code that is defined in Appendix A. Do not use IM_INFINITE_TIMEOUT because this function will not return if the unit cannot send the OPEN request.
See Also im_udp_send_data, im_udp_receive_data, im_udp_close_socket
Example See example for im_udp_receive_data on page 193.
Trakker Antares PSK Reference Manual
189
Page 210
Chapter 5, PSK Function Descriptions im_udp_receive_data Purpose
Syntax
This function receives a UDP Plus packet from the Intermec Gateway or the DCS 30X and dissects the packet, placing the information into a structure for the calling routine. This function should only be used on terminals with UDP Plus. Do not use this function on terminals running TCP/IP. #include "imt24lib.h" IM_STATUS im_udp_receive_data (struct im_udp_packet far *in_packet, IM_LTIME timeout);
IN Parameters timeout
OUT Parameters in_packet
Number in the range of 1 to 65,534 ms or one of these constants: IM_ZERO_TIMEOUT No wait IM_INFINITE_TIMEOUT Wait forever Far pointer to a structure of type im_udp_packet. This structure is defined in imt24lib.h. struct im_udp_packet { IM_USHORT data_length; /* length of received data */ IM_UCHAR message_type; /* direct sockets message type */ IM_UCHAR session_id; /* direct sockets Session ID */ union { struct { IM_USHORT error_code; /* direct sockets error code */ IM_UCHAR error_text[IM_UDP_REC_ERROR_SIZE]; /* text */ } error; IM_UCHAR data_text[IM_UDP_REC_DATA_SIZE]; /* data */ } remaining_packet; };
data_length
190
Length of the received data.
Trakker Antares PSK Reference Manual
Page 211
Chapter 5, PSK Function Descriptions message_type session_id error_code error_text
Trakker Antares PSK Reference Manual
One of the following constants: IM_UDP_OPEN_ACK This value is returned in response to an OPEN request sent from the client application. It indicates that the connection was opened successfully. IM_UDP_OPEN_NAK This value is returned in response to an OPEN request sent from the client application. It indicates that the connection could not be opened. Error code and error text accompany this message. IM_UDP_DATA_CMD This value is returned upon a successful receipt of data from the Intermec Gateway or the DCS 30X. Data accompany this message. IM_UDP_CLOSE_CMD This value is returned if a connection has been closed by the host, the Intermec Gateway, or the DCS 30X, or has been closed for any other reason. Error code and error text will accompany this message. Any other value indicates an invalid message received from the Intermec Gateway or the DCS 30X. Session for which data was received. If message_type is IM_UDP_OPEN_NAK or IM_UDP_CLOSE_CMD, this element is one of the error codes listed in the following table. The client software should be aware of these conditions, handle the errors, and be able to recover. If message_type is IM_UDP_OPEN_NAK or IM_UDP_CLOSE_CMD, this element is the nullterminated text string associated with the error code listed in the following table.
191
Page 212
Chapter 5, PSK Function Descriptions im_udp_receive_data (continued) Error Code Descriptions
192
Code 0
Description Host session closed
1
Host Lookup failed
2
Session not active
3
ISM Terminated
4
ISM resource error
5
Map protocol name to number failed
6
Socket call failed
7
Connect call failed
10001
Not owner
10003
No such process
10004
Interrupted system call
10006
No such device or address
10009
Bad file number
10013
Permission denied
10014
Bad address
10022
Invalid argument
10024
Too many files open
10032
Broken pipe
10035
Operation would block
10036
Operation now in progress
10037
Operation already in progress
10038
Socket operation on non-socket
10039
Destination address required
10040
Message too long
10041
Protocol wrong for type of socket
10042
Protocol not available
10043
Protocol not supported
10044
Socket type not supported
10045
Operation not supported on socket
10046
Protocol family not supported
10047
Address family not supported by protocol family
10048
Address already in use
10049
Can't assign requested address
10050
Network is down
10051
Network is unreachable
10052
Network dropped connection on reset
Trakker Antares PSK Reference Manual
Page 213
Chapter 5, PSK Function Descriptions
Error Code Descriptions (continued) Code 10053
Description Software caused connection abort
10054
Connection reset by peer
10055
No buffer space available data_text Return Value Notes
If the message_type is IM_UDP_DATA_CMD, this element is the data from a successful receive request.
This function returns a status code that is defined in Appendix A. It is not recommended that you use IM_INFINITE_TIMEOUT because this function will not return if the unit cannot send the data.
See Also im_udp_close_socket, im_udp_send_data, im_udp_open_socket
Example /************************* im_udp_receive_data *********************/ #include <conio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include "imstdio.h" #include "imt24lib.h" #define
ESC_KEY 27
/******************************************************************/ /* The main program prompts the user for screen parameters and */ /* them sets them based on the user's selections. It then */ /* prompts for host name, port number and session ID and attempts */ /* to open a Direct Socket connection via the 0200 controller. */ /* It then goes into a loop checking keyboard & net port for data.*/ /* If data from the net port is received it is put on the display.*/ /* If a key is pressed, it is sent out the net port. */ /* This program is simply a dumb terminal. */ /* Keys pressed should be sent to a host echo server */ /* which sends the data right back. */ /******************************************************************/ void main ( void ) { IM_STATUS iStatus; /* return status for PSK functions */ char ch; /* character represented by keypress */ IM_ORIGIN source; /* source of input */ IM_BOOL scroll; /* scrolling on or off */ IM_BOOL wrap; /* line wrap on or off */ IM_CONTROL viewporting; /* viewporting on or off */ IM_CONTROL follow; /* viewport follow the cursor on/off */ char vp, fc, sc, wp; /* dummy variables */ IM_UCHAR session_id; /* session ID of connection */ IM_UCHAR session_id_str[3]; /* session_id in string format */ IM_USHORT port_num; /* server port number */ IM_UCHAR port_number_str[4]; /* port_num in string format */ IM_UCHAR host_name[20]; /* host name or IP address */
Trakker Antares PSK Reference Manual
193
Page 214
Chapter 5, PSK Function Descriptions im_udp_receive_data (continued) struct im_udp_packet packet; /* packet struct containing input */ IM_UCHAR close_str[20]; /* string to appear in 0200 error log */ IM_UCHAR key_buf[5]; /* keyboard buffer */ im_clear_screen(); printf("Direct Socket Demo\n\n"); /* get user's screen preferences printf("\n viewporting? Y/N:"); vp = getche();
*/ printf("\nfollow cursor? Y/N:"); fc = getche(); printf("\n scrolling? Y/N:"); sc = getche(); printf("\n line wrap? Y/N:"); wp = getche(); if (toupper(vp) == 'Y') viewporting = IM_ENABLE; else viewporting = IM_DISABLE; if (toupper(fc) == 'Y') follow = IM_ENABLE; else follow = IM_DISABLE; if (toupper(sc) == 'Y') scroll = IM_TRUE; else scroll = IM_FALSE; if (toupper(wp) == 'Y') wrap = IM_TRUE; else wrap = IM_FALSE; im_clear_screen(); printf(" UDP Socket Demo\n\n"); printf("When prompted for \n"); printf("for a host, choose \n"); printf("one with an echo \n"); printf("server port. \n\n"); printf("Each key you press \n"); printf("will be sent to the\n"); printf("host and echoed \n"); printf("back to the screen.\n\n"); printf(" ESC to quit \n\n"); printf(" Press any \n key to Begin"); getch(); /* set screen parms according to user's selections im_set_viewporting(viewporting); im_set_follow_cursor(follow);
194
*/
Trakker Antares PSK Reference Manual