The text of a manual · part 18 of 42
JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 171 to 180
Pages 171 to 180 of 414
The original document is the PDF (690 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 171
im_standard_trx
The *send_var_array[] parameter is valid only when request_type is “D.” It is a pointer to the array containing the data to send to the database. Each element in the array corresponds to a DCM transaction field. The max_str_len parameter is the maximum length of the return string buffer. OUT Parameters:
The *ret_string parameter is a pointer to the return string buffer. The buffer contains the database server’s transaction message unless a timeout occurred. If the reader receives IM_DCM_TIMEOUT, then the communication error status is placed in the first two bytes of the return buffer. You can check this communication status code against the list in Appendix A, “Status Codes.” The return string buffer must be large enough to hold a complete packet from the controller. The ret_array[] parameter is the array containing pointers to the variables that hold the data returned from the database. The received data field is parsed and then placed into the variables. The *oper_type parameter is a pointer to the operation type returned by the remote database and is one of these constants: IM_DB_READ IM_DB_INSERT IM_DB_UPDATE IM_DB_DELETE IM_DB_UNKNOWN
Return Value:
2-142
R W U D X
Read records from the database Write records to the database Update records in the database Delete records from the database Unknown
This function returns one of the status codes from the following table. For more information on these return codes, see Chapter 5, “Using the PSK With DCM.”
Page 172
im_standard_trx
Notes:
2
Return Code
Hex
Description
IM_DCM_OK
1A00
Transaction successful Retrieved record from standby file All standby records sent successfully
IM_DCM_ACK_RCD
1A01
Transaction successful, ACK
IM_DCM_MSG_RCD
1A10
Received message on Read operation
IM_DCM_NAK_RCD
5A02
Transaction failed, NAK received
IM_DCM_NO_RECORD
5A07
Standby file is empty
IM_DCM_TRUNCATED
5A11
Data was truncated
IM_DCM_EXCESSFIELD
5A12
Too many fields
IM_DCM_STANDBY
5A20
Record stored in standby file successfully
IM_DCM_STANDBY_TXERR
5A21
Record stored in standby file, but upload standby error
IM_DCM_NOTRANSMIT
9A03
Transmit failed Transmit channel error
IM_DCM_TIMEOUT
9A04
Receive port timeout
IM_DCM_HEAD_ERR
9A05
Packet header error
IM_DCM_TRANSID_ERR
9A06
Missing transaction ID
IM_DCM_FILE_ERR
9A08
Standby file I/O error
IM_DCM_NO_HANDLE
9A09
Missing standby file
IM_DCM_FILLED
9A40
Buffer overflow
IM_DCM_FILLED_TXERR
9A41
Buffer overflow with upload standby error
You can use the *oper_type and request_type to verify that the database, the DCM interface, and the JANUS transaction are configured properly. For example, if the request_type is IM_DBRQT_DATA (read or write), but the *oper_type is IM_DB_DELETE (delete), then you need to correct the configuration. See Chapter 5, “Using the PSK With DCM.”
See Also:
im_setup_trx, im_parse_host_response
Example See the sample program in Chapter 5, “Using the PSK With DCM.”
2-143
Page 173
im_standby_wait im_standby_wait Purpose:
This function requests that reader services wait in standby mode for a specific period of time. You use this function to suspend the reader for a length of time to save the battery power.
Syntax:
#include <im20lib.h> IM_STATUS im_standby_wait (IM_UINT timeout);
IN Parameters:
The timeout parameter is the amount of time to wait in standby mode. You can exit the function before data is received or before the timeout occurs by performing an application break sequence (see your JANUS user’s manual). The return status indicates whether the function was successful, a timeout occurred, or the application break was received. The timeout parameter is a number or one of these constants: 1 to 65,534 ms IM_ZERO_TIMEOUT IM_INFINITE_TIMEOUT
Numeric range No wait Wait forever
OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
You must install the Reader Wedge to use this function. For information on loading RWTSR.EXE, see “Runtime Requirements” earlier in this chapter.
See Also:
None.
Example See example for im_irl_a.
2-144
Page 174
im_transmit_buffer
2 im_transmit_buffer Purpose:
This function transmits the contents of a data buffer through a designated communications port. This function continues operating until the buffer transmission is complete or until an error status is detected.
Syntax:
#include <im20lib.h> IM_STATUS im_transmit_buffer (IM_COM_PORT port_id, IM_USHORT user_length, IM_UCHAR far *data_buffer, IM_USHORT timeout);
IN Parameters:
The port_id parameter identifies the communications port as follows: IM_COM1 IM_COM2 IM_COM4
COM1 COM2, scanner port (2010 and 2050) COM4 (RF only)
The user_length parameter is the length of the data string that you want to transmit. The data_buffer parameter is a far pointer to the data array that you want to transmit. The timeout parameter is the transmission timeout period. You can exit the function before data is sent or before the timeout occurs by performing an application break sequence (see your JANUS user’s manual). The return status indicates whether the function was successful, a timeout occurred, or the application break was received. The timeout parameter is a number or one of these constants: 1 to 65,534 ms IM_ZERO_TIMEOUT IM_INFINITE_TIMEOUT
Numeric range No wait Wait forever
OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
2-145
Page 175
im_transmit_buffer
Notes:
You must install a protocol handler to use this function.
See Also:
im_receive_buffer, im_transmit_buffer_no_wait, im_transmit_buffer_noprot
Example /******************** im_transmit_buffer *******************************/ /* Also with: im_cancel_tx_buffer */ /* Note: Must have reader services and comm protocol handler installed to /* enable send/receive buffer functions. /* Run these TSR's at DOS prompt before running these tests: /* rservice /* phimec 1 ( 1 is COM1)
*/ */ */ */ */
#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #include "im20lib.h" #include "immsg.h" static IM_COM_PORT com_port = IM_COM1;
/* Uses COM1*/ static IM_UCHAR *data_str[] = { "Hi There, It must have three lines down the road from this demo", "The line 2 demonstration proves the transmit buffer is working", "The demonstration of the transmit buffer is Done", NULL }; void main (void) { int index; size_t actual_count; IM_STATUS status; IM_UCHAR data_buffer[160]; /* Call im_cancel_tx_buffer to initialize the communications port and its buffer */ status = im_cancel_tx_buffer(com_port); printf("Cancel Tx status: %xH\n", status); /* Sending data string loop until it reaches NULL */ for (index =0; data_str[index] != NULL; index++) { /* Copy string to big buffer */ strcpy(data_buffer, data_str[index]); actual_count = strlen(data_buffer); /* Get its length */ /* Call Intermec function, timeout within 50000 milliseconds */ status = im_transmit_buffer(com_port, actual_count, data_buffer, 50000); if (IM_ISSUCCESS(status)) printf("Line %d Sent\n", index + 1); else printf("Transmit error\nStatus = %xH\n", status); } printf("Transmit Done\n"); }
2-146
Page 176
im_transmit_buffer_no_wait
2 im_transmit_buffer_no_wait Purpose:
This function transmits the contents of a buffer and passes control back to its client.
Syntax:
#include <im20lib.h> IM_STATUS im_transmit_buffer_no_wait (IM_COM_PORT port_id, IM_COM_DATA_BUFFER far *data_struct);
IN Parameters:
The port_id parameter identifies the communications port as follows: IM_COM1 IM_COM2 IM_COM4
COM1 COM2, scanner port (2010 and 2050) COM4 (RF only)
The data_struct parameter is a far pointer to the data array that you want to transmit. OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
You must install a protocol handler to use this function. This function differs from im_transmit_buffer in that the client must set the buffer structure and monitor the buffer status until transmission is complete. Use this function for multiple buffer transmissions in conjunction with checking the status in data_struct. You must build and maintain a data_struct of the type IM_COM_DATA_BUFFER as described in IM20LIB.H.
See Also:
im_transmit_buffer_noprot, im_cancel_tx_buffer
2-147
Page 177
im_transmit_buffer_no_wait
Example /******************** im_transmit_buffer_no_wait ************************/ /* Also with: im_cancel_tx_buffer */ /* Note: Must have reader services and comm protocol handler installed to */ /* enable send/receive buffer functions. */ /* Run these TSR's at DOS prompt before running these tests: */ /* rservice */ /* phimec 1 ( 1 is COM1) */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "im20lib.h" #include "immsg.h" static IM_COM_PORT com_port = IM_COM1;
/* Uses COM1*/ static IM_UCHAR *data_str[] = { "Hi There, It must have four lines down the road from this demo\r" "The line 2 demonstration proves the Transmit Buffer No Wait working\r", "The line 3 demonstration proves the Transmit Buffer No Wait working\r", "The demonstration of the Transmit Buffer No Wait is Done\r", NULL }; void main (void) { IM_USHORT IM_COM_DATA_BUFFER IM_STATUS IM_UCHAR index; com_buff_struct; /*data buffer structure for receive/transmit */ status; data_buff[300];
/* Get the transmit environment ready */ status = im_cancel_tx_buffer(com_port); printf("Cancel Tx status: %xH\n", status); /* Transmitting data string loop until it reaches NULL */ for (index =0; data_str[index] != NULL; index++) { /* Copy string to transmit into big buffer */ strcpy(data_buff, data_str[index]); /* Set up comm buffer parameters */ com_buff_struct.command = IM_CU_TRANSMIT; com_buff_struct.user_length = strlen(data_buff); com_buff_struct.comm_length = 0; com_buff_struct.protocol_mode = IM_NO_PROTOCOL; com_buff_struct.eom_char = 0; com_buff_struct.data_ptr = (char far *)data_buff; com_buff_struct.protocol_xfer_status = IM_COMM_INUSE; /* Call Intermec routine */ status = im_transmit_buffer_no_wait(com_port, (IM_COM_DATA_BUFFER far *) &com_buff_struct); if (IM_ISSUCCESS(status)) { /* Wait for data transfer to complete */ while (com_buff_struct.protocol_xfer_status == IM_COMM_INUSE) ; /* Waiting loop, end while */
2-148
Page 178
im_transmit_buffer_no_wait
2 printf("Line %d Sent\n", index + 1); } else { printf("Tx Error = %XH\n", status); printf("Buffer not sent\n"); } }
/* for */ printf ("Transmit Done\n"); }
2-149
Page 179
im_transmit_buffer_noprot im_transmit_buffer_noprot Purpose:
This function transmits a buffer without protocol and sends only the specified number of characters.
Syntax:
#include <im20lib.h> IM_STATUS im_transmit_buffer_noprot (IM_COM_PORT port_id, IM_USHORT user_length, IM_UCHAR far *data_buffer IM_USHORT timeout);
IN Parameters:
The port_id parameter identifies the communications port as follows: IM_COM1 IM_COM2 IM_COM4
COM1 COM2, scanner port (2010 and 2050) COM4 (RF only)
The user_length parameter is the maximum number of bytes to transmit. The data_buffer parameter is a far pointer to the data array that you want to transmit. The timeout parameter is the transmission timeout period. You can exit the function before data is sent or before the timeout occurs by performing an application break sequence (see your JANUS user’s manual). The return status indicates whether the function was successful, a timeout occurred, or the application break was received. The timeout parameter is a number or one of these constants: 1 to 65,534 ms IM_ZERO_TIMEOUT IM_INFINITE_TIMEOUT
Numeric range No wait Wait forever
If IM_INFINITE_TIMEOUT is selected, the function will not return until the end of message character has been received. OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
2-150
Page 180
im_transmit_buffer_noprot
Notes:
2
You must install a protocol handler other than PHPCSTD.EXE to use this function. If an existing transmit client is linked to the host, you must issue a cancel command first.
See Also:
im_transmit_buffer_no_wait, im_cancel_tx_buffer, im_transmit_buffer
Example /******************** im_transmit_buffer_noprot ************************/ /* Also with: im_cancel_tx_buffer */ /* Note: Must have reader services and comm protocol handler installed to /* enable send/receive buffer functions. /* Run these TSR's at DOS prompt before running these tests: /* rservice /* phimec 1 ( 1 is COM1)
*/ */ */ */ */
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "im20lib.h" #include "immsg.h" static IM_COM_PORT com_port = IM_COM1;
/* Uses COM1*/ static IM_UCHAR *data_str[] = { "Hi There, It must have three lines down the road from this demo", "The line 2 demo proves the Transmit Buffer No Protocol is working", "The demonstration of the Transmit Buffer No Protocol is Done", NULL }; void main (void) { IM_STATUS status; IM_USHORT index; IM_UCHAR data_buffer[300]; /* PHIMEC protocol handler must be installed to run this routine */ /* It only works with PHIMEC protocol */ /* Get the transmit environment ready */ status = im_cancel_tx_buffer(com_port); printf("Cancel Tx status: %xH\n", status); /* Sending data string loop until it reaches NULL */ for (index =0; data_str[index] != NULL; index++) { /* Copy string to transmit into big buffer */ strcpy(data_buffer, data_str[index]); /* Call Intermec routine with infinite timeout */ status = im_transmit_buffer_noprot(com_port, strlen(data_buffer), data_buffer, IM_INFINITE_TIMEOUT);
2-151