Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 13 of 40

2D JANUS PSK for C/C++ Reference Manual, pages 121 to 130

Pages 121 to 130 of 400

The original document is the PDF (793 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_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-95

Page 122

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-96

Page 123

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-97

Page 124

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-98

The comm_length is the actual number of bytes received upon completion of the call.

Page 125

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-99

Page 126

im_receive_buffer eor_char = eor_byte; printf ("Enter characters\n"); printf ("to be received\n"); printf ("from host\n"); printf ("CRLF to End of Line\n");

/* Each line end with a CR & LF */ do { actual_length = 0; /* Call Intermec receive buffer function with 50000 msec timeout */ status = im_receive_buffer(com_port, sizeof(data_buffer) - 1, data_buffer, 50000, &actual_length); if (actual_length > 0) { /* Append CR & LF before write it into files */ data_buffer[actual_length++] = '\x0D'; data_buffer[actual_length++] = '\x0A'; data_buffer[actual_length] = '\0'; /* Write results to file */ fwrite(data_buffer, actual_length, sizeof(char), out_fptr); printf("%s", data_buffer); /* Write data to on screen */ eor_byte = toupper(data_buffer[0]); } else { eor_byte = '\0'; printf("Rx Status: %xH\n", status); } } while (eor_byte != eor_char);

/* Close file and exit */ fclose(out_fptr); printf("Receive Done\n"); }

2-100

/* Loop until EOR char 'q' */

Page 127

im_receive_buffer_no_wait

2 im_receive_buffer_no_wait Purpose:

This function receives data from the designated communications port and places the data into a user-defined record. It differs from im_receive_buffer in that the programmer must set up the data record and monitor the transfer status until transmission is complete. This function runs in the background after it is initiated; no checks are made. Use this function when receiving multiple buffer transmissions in conjunction with im_rx_check_status.

Syntax:

#include <im20lib.h> IM_STATUS im_receive_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 for the received data. This buffer must hold at least 256 bytes. OUT Parameters:

None.

Return Value:

This function returns one of the standard status codes defined in Appendix A, “Status Codes.”

Notes:

You must build and maintain a data_struct of the type IM_COM_DATA_BUFFER as described in IM20LIB.H. You must periodically check the protocol_xfer_status element in the IM_COM_DATA_BUFFER record to see if all the data has been received. When protocol_xfer_status is no longer code 8602H (communications port in use), all data is received. You must install a protocol handler to use this function.

2-101

Page 128

im_receive_buffer_no_wait

This function differs from im_receive_buffer_noprot in that program execution continues after im_receive_buffer_no_wait is called. When im_receive_buffer_noprot returns from a function call, the data has been read, the timeout has expired, or an error was encountered. See Also:

im_receive_buffer_noprot, im_cancel_rx_buffer, im_rx_check_status

Example /******************** im_receive_buffer_no_wait ************************/ /* Also with: im_rx_check_status */ /* 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)

*/ */ */ */ */

#include <stdio.h> #include <conio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include "im20lib.h" #include "immsg.h" static IM_COM_PORT static IM_UCHAR com_port = IM_COM1; eor_char = 'Q';

void main (void) { IM_COM_DATA_BUFFER IM_STATUS IM_UCHAR IM_UCHAR int com_buff_struct; /*Data buffer structure for receive/transmit */ status; eor_byte; data_buff[300]; index = 0;

printf("Type End of receive\nchar?"); eor_byte = getche(); eor_byte = toupper( eor_byte);

/* Uses COM1*/ /* Default end of receive char */

/* Get End of Receive char */ if ( isascii(eor_byte)) eor_char = eor_byte; printf ("Enter characters\n"); printf ("to be received\n"); printf ("from host\n"); printf ("CRLF to End of Line\n");

/* Each line end with a CR & LF */

/* Get the receive environment ready */ status = im_cancel_rx_buffer(com_port); printf ("RX Init =%XH\n", status); /* Set up com_buff structure for init Receive Buffer No Wait */ com_buff_struct.command = IM_CU_RECEIVE; com_buff_struct.comm_length = 0;

2-102

Page 129

im_receive_buffer_no_wait

2 com_buff_struct.user_length = sizeof(data_buff); com_buff_struct.data_ptr = data_buff; com_buff_struct.protocol_mode = IM_NO_PROTOCOL; com_buff_struct.eom_char = 0x0d; /* CR for terminating char */ com_buff_struct.protocol_xfer_status = IM_COMM_INUSE; /* Call Intermec function */ status = im_receive_buffer_no_wait(com_port, (IM_COM_DATA_BUFFER far *) &com_buff_struct); /* Uses im_rx_check_status to get the rest coming data */ do /* loop until first character in buffer is a 'Q' */ { /* Check for receive errors: Print the error status */ if ( IM_ISSUCCESS(status) ) { ++index; /* Indicator of the receiving buffer */ /* Let the receive data coming complete */ while (com_buff_struct.protocol_xfer_status == IM_COMM_INUSE) ; /* End of While loop, Wait the coming data settled */ printf ("Line %d Done\n", index); /* Put a null byte in received string for display */ data_buff[com_buff_struct.comm_length] = '\0'; /* If 1st byte in string is equal to eor_char, then quit the receive*/ eor_byte = toupper(data_buff[0]); /* Display received string to screen */ printf("%s\n", data_buff); /* ************************************************************* * Update buffer for next block before calling check status to * get protocol handler to reset status. ************************************************************** */ com_buff_struct.command = IM_CU_RECV_AGAIN; com_buff_struct.comm_length = 0; com_buff_struct.protocol_xfer_status = IM_COMM_INUSE; /* Call intermec function to see next block data */ status = im_rx_check_status(com_port); } else { eor_byte = '\0'; printf("Rx Error = %XH\n", status); } printf("ch: %xH, by: %xH\n", eor_char, eor_byte); } while ( eor_byte != eor_char);

/* Loop until reaching eor_char */ printf ("Receive Done\n"); }

2-103

Page 130

im_receive_buffer_noprot im_receive_buffer_noprot Purpose:

This function receives a text string from the designated port without using the active protocol. Only the PHIMEC.EXE protocol handler supports this function, which is often used to receive a host initialization string before beginning transmission.

Syntax:

#include <im20lib.h> IM_STATUS im_receive_buffer_noprot (IM_COM_PORT port_id, IM_USHORT user_length, IM_UCHAR far *data_buffer, IM_USHORT timeout, IM_UCHAR eom_char, 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 characters you can 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 IM_INFINITE_TIMEOUT is selected, the function will not return until the end of message character has been received.

2-104