The text of a manual · part 13 of 42
JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 121 to 130
Pages 121 to 130 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 121
im_parse_host_response
Return Value:
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.” IM_DCM_ACK_RCD IM_DCM_MSG_RCD IM_DCM_NAK_RCD IM_DCM_TRUNCATED IM_DCM_EXCESSFIELD IM_DCM_TIMEOUT IM_DCM_HEAD_ERR
1A01 1A10 5A02 5A11 5A12 9A04 9A05
Transaction successful, ACK received Data received Transaction failed, NAK received Received data was truncated Too many fields Receive timeout Packet header error
Notes:
See Chapter 5, “Using the PSK With DCM.”
See Also:
im_setup_trx, im_standard_trx
Example See the sample program in Chapter 5, “Using the PSK With DCM.”
2-92
Page 122
im_power_status
2 im_power_status Purpose:
This function returns the line status, battery status, backup status, and percentage of remaining battery life.
Syntax:
#include <im20lib.h> IM_STATUS im_power_status (IM_LINE_STATUS *line_status, IM_BATTERY_STATUS battery_status, IM_BACKUP_STATUS *backup_status, IM_UCHAR fuel_gauge);
IN Parameters:
None.
OUT Parameters:
The line_status parameter returns one of these constants: IM_ACline_NOT_CONNECTED IM_ACline_CONNECTED IM_UNKNOWN_ACline
AC line is not connected AC line is connected AC line status is unknown
The battery_status parameter returns one of these constants: IM_HIGH_BAT IM_LOW_BAT IM_CRITICAL_BAT IM_CHARGING_BAT IM_UNKNOWN_BAT
Battery charge is high Battery charge is low Battery charge is critical Battery is charging now Battery condition is unknown
The backup_status parameter returns one of these constants: IM_BACKUP_OK IM_BACKUP_LOW
Backup battery is OK Backup battery is low
The fuel_gauge parameter returns one of these constants: 0 to 100 255 Return Value:
% of full charge in increments of 10% Unknown
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
2-93
Page 123
im_power_status
Example /******************** im_power_status ******************************/ #include <stdio.h> #include <stdlib.h> #include "im20lib.h" IM_LINE_STATUS ac_line; IM_BATTERY_STATUS battery; IM_BACKUP_STATUS backup; IM_UCHAR fuel; IM_STATUS status; void main (void) { /* Call Intermec function */ status = im_power_status( &ac_line, &battery, &backup, &fuel); printf ("Status: %4X\n", status); printf ("Line status:\n "); switch (ac_line) { case IM_ACline_NOT_CONNECTED: printf ("Not connected\n"); break; case IM_ACline_CONNECTED: printf ("Connected\n"); break; case IM_UNKNOWN_ACline: printf ("Unknown\n"); break; default: printf ("Invalid return value\n"); break; } /* End switch */ printf ("Battery status:\n "); switch (battery) { case IM_HIGH_BAT: printf ("Charge high\n"); break; case IM_LOW_BAT: printf ("Charge low\n"); break; case IM_CRITICAL_BAT: printf ("Charge critical\n"); break; case IM_CHARGING_BAT: printf ("Charging battery\n"); break; case IM_UNKNOWN_BAT: printf ("Unknown\n"); break;
2-94
Page 124
im_power_status
2 default: printf ("Invalid return value\n"); break; } /* end switch */ printf ("Backup status:\n "); switch (backup) { case IM_BACKUP_OK: printf ("Backup battery OK\n"); break; case IM_BACKUP_LOW: printf ("Backup battery low\n"); break; default: printf ("Invalid return value\n"); break; } /* end switch */ if (fuel <= 100) printf ("Fuel gauge:\n %u percent\n", fuel); else if (fuel == 255) printf ("Fuel gauge unknown\n"); else printf ("Invalid return value\n"); }
2-95
Page 125
im_protocol_extended_status im_protocol_extended_status Purpose:
This function gets the protocol extended status from the designated communications port. You allocate the protocol status buffer or RF status buffer, and then im_protocol_extended_status returns the status and setup in hexadecimal values.
Syntax:
#include <im20lib.h> IM_STATUS im_protocol_extended_status (IM_COM_PORT port_id, IM_COMM_STATUS_BUFFER_s far *status_buffer);
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 status_buffer parameter is a far pointer to the status buffer structure IM_COMM_STATUS_BUFFER_s. OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
See Also:
im_receive_buffer_no_wait, im_transmit_buffer_no_wait
Example /******************** im_protocol_extended_status **********************/ #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #include <im20lib.h> void main (void) { IM_STATUS status; IM_COMM_STATUS_BUFFER_s status_buffer; /* First format string for extended protocol status */ IM_UCHAR *format_str1 = "Strut Ver = %d\nHd Ver = %s\nBaud = %lu\nParity=%XH\nStop=%XH\nData=%XH\n" "Modem=%XH\nPort stat = %XH\nActive prot = %d\n"
2-96
Page 126
im_protocol_extended_status
2
"Lrc enabled = %XH\nInterchar dely= %d\nTurnarnd dely=%d\n" "Receive tmeout= %d\nTransmit tmeout= %d\n"; /* Second format string for extended protocol status */ IM_UCHAR *format_str2 = "Pol char = %XH\nPol length= %d\nSel char = %XH\nSel length= %d\n" "Res char = %XH\nRes length= %d\nReq char = %XH\nReq length= %d\n" "Aff char = %XH\nAff length= %d\nNeg char = %XH\nNeg length= %d\n" "Som char = %XH\nSom length= %d\n"; /* Third format string for extended protocol status */ IM_UCHAR *format_str3 = "Tx eom len = %XH\nTx eom char 1 = %XH\n" "Tx eom char 2 = %XH\nRx eom len = %XH\nRx eom char 1 = %XH\n" "Rx eom char 2 = %XH\nFlow ctrl = %XH\nMulti drp addr = %XH\n" "Multi drp addr = %XH\nMulti drp enbled = %XH\n" "EOF len = %XH\nEOF char = %XH\nRecv clt buff= %d\n" "Xmit clt buff= %d\nProt mode = %d\n"; /* Call Intermec routine */ status_buffer.status_structure_version = STATUS_STRUCT_VERSION; status = im_protocol_extended_status(IM_COM1, &status_buffer); clrscr(); gotoxy(1, 1);
/* to upper left screen */
/* Print first page of status info */ printf("Extd Status,Page 1of3\n"); printf(format_str1, status_buffer.status_structure_version, status_buffer.handler_ver, status_buffer.specific.serial.baud_rate, status_buffer.specific.serial.parity, status_buffer.specific.serial.stop_bits, status_buffer.specific.serial.data_bits, status_buffer.specific.serial.modem_status, status_buffer.specific.serial.port_status, status_buffer.specific.serial.active_prot, status_buffer.specific.serial.lrc_enabled, status_buffer.specific.serial.interchar_delay, status_buffer.specific.serial.turnaround_delay, status_buffer.specific.serial.receive_timeout, status_buffer.specific.serial.transmit_timeout); /* Pause between screens */ printf("Any key to cont'\n"); getch(); clrscr(); gotoxy(1, 1); printf ("Extd Status,Page 2of3\n"); /* Print second page of status info */ printf (format_str2, status_buffer.specific.serial.pol_char, status_buffer.specific.serial.pol_length, status_buffer.specific.serial.sel_char, status_buffer.specific.serial.sel_length, status_buffer.specific.serial.res_char,
2-97
Page 127
im_protocol_extended_status status_buffer.specific.serial.res_length, status_buffer.specific.serial.req_char, status_buffer.specific.serial.req_length, status_buffer.specific.serial.aff_char, status_buffer.specific.serial.aff_length, status_buffer.specific.serial.neg_char, status_buffer.specific.serial.neg_length, status_buffer.specific.serial.som_char, status_buffer.specific.serial.som_length); /* Pause between screens */ printf ("Any key to cont'\n"); getch(); clrscr(); gotoxy(1, 1); printf ("Extd Status,Page 3of3\n"); /* Print third page of status info */ printf (format_str3, status_buffer.specific.serial.txeom_len, status_buffer.specific.serial.txeom_char_1, status_buffer.specific.serial.txeom_char_2, status_buffer.specific.serial.rxeom_len, status_buffer.specific.serial.rxeom_char_1, status_buffer.specific.serial.rxeom_char_2, status_buffer.specific.serial.flow_ctrl, status_buffer.specific.serial.multi_drop_addr, status_buffer.specific.serial.multi_drop_enabled, status_buffer.specific.serial.eof_length, status_buffer.specific.serial.eof_char, status_buffer.specific.serial.have_recv_client_buffer, status_buffer.specific.serial.have_xmit_client_buffer, status_buffer.specific.serial.protocol_mode); /* Function call return status */ printf ("Extd Prot Stat=%XH\n", status); }
2-98
Page 128
im_ready_for_reboot
2 im_ready_for_reboot Purpose:
This function indicates to the host whether the JANUS reader is ready for a reboot in response to having received a “Prepare for Reboot” command.
Syntax:
#include "im20lib.h" IM_STATUS im_ready_for_reboot(IM_BOOL reboot_flag)
IN Parameters:
The reboot_flag parameter can be one of the following symbolic constants: IM_TRUE IM_FALSE
JANUS reader is ready for reboot. The string “..+%1” will be sent to the host. JANUS reader is not ready for reboot. The string “..+%0” will be sent to the host.
OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
To reboot, the JANUS reader must receive one of the reboot commands from the host: ..%$0 to reboot without an open session, or ..%$1 to reboot with an open session. The im_ready_for_reboot function with a reboot_flag of IM_TRUE must be called before the JANUS reader will respond to either reboot command. This prevents the JANUS reader from being rebooted before it is ready.
See Also:
im_get_reboot_flag
Example See example for im_get_reboot_flag
2-99
Page 129
im_receive_buffer im_receive_buffer Purpose:
This function receives the contents of a data buffer from a designated communications port.
Syntax:
#include <im20lib.h> IM_STATUS im_receive_buffer (IM_COM_PORT port_id, IM_USHORT user_length, IM_UCHAR far *data_buffer, IM_USHORT timeout, IM_USHORT far *comm_length);
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 receive and must be at least 256 bytes. The data_buffer parameter is a far pointer to the data array where you want to place the received data. This buffer must hold at least 256 bytes. The timeout parameter is the receive timeout period. 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
If you select IM_INFINITE_TIMEOUT, the function will not return until the end of message character has been received. OUT Parameters:
2-100
The comm_length is the actual number of bytes received upon completion of the call.
Page 130
im_receive_buffer
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
This function does not return until an end of message, a buffer is full, a timeout, or an error occurs.
2
You must install a protocol handler to use this function. See Also:
im_receive_buffer_no_wait, im_receive_buffer_noprot, im_cancel_rx_buffer, im_rx_check_status
Example /******************** im_receive_buffer *******************************/ /* Also with: im_cancel_rx_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) */ /* */ /* Assume that the receive data is stored in file 'RC.DAT' at current*/ /* working directory and uses the first byte of receiving string to */ /* terminate receive buffer loop. Default is 'Q' or 'q' character */ #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include "im20lib.h" static IM_COM_PORT static IM_UCHAR static IM_UCHAR com_port = IM_COM1; filename[] = "RC.DAT"; eor_char = 'Q';
/* Uses COM1*/ /* Store receive data filename*/ /* Default end of receive char */ void main (void) { IM_USHORT actual_length; IM_UCHAR data_buffer[300]; IM_UCHAR eor_byte; FILE *out_fptr; IM_STATUS status; /* Call im_cancel_Rx_buffer to initialize the communications port and its buffer */ status = im_cancel_rx_buffer(com_port); printf("Cancel Rx status: %xH\n", status); /* Assume that the received data is stored in file 'RC.DAT' */ out_fptr = fopen(filename, "w+t"); /* Open in Translate mode*/ printf("Type End of receive\nchar?"); eor_byte = toupper( getche()); if (isascii(eor_byte))
/* Get End of Receive char */
2-101