The text of a manual · part 15 of 42
JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 141 to 150
Pages 141 to 150 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 141
im_receive_input
OUT Parameters:
The source parameter specifies the actual input source and is one of these constants: IM_NO_SELECT No selection made IM_LABEL_SELECT Label selected IM_KEYBOARD_SELECT Keypad selected IM_COM1_SELECT COM1 selected IM_COM2_SELECT COM2, scanner port selected (2010 and 2050) IM_COM4_SELECT COM4 selected (RF only) The received parameter is the variable where the data is placed.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
If input from more than one source is received before this function is called, the first available input is returned in this order: label, keypad, COM1, COM2, and COM4. If you are using a communications port, you must install a protocol handler and call im_link_comm. 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:
im_get_length, im_get_label_symbology, im_link_comm
Example /******************** im_receive_input *******************************/ /* Also with: im_get_length */ /* im_link_comm */ /* im_unlink_comm */ /* im_get_input_mode */ /* im_set_input_mode */ #include <stdio.h> #include <conio.h> #include <stdlib.h> #include "im20lib.h" #include "immsg.h" #define COM_BUFSIZE 300 void main (void) { IM_UCHAR input[300];
2-112
/* Allocate 300 bytes comm buffer */
Page 142
im_receive_input
IM_USHORT IM_MODE IM_UCHAR IM_ORIGIN IM_ORIGIN IM_STATUS
2 length; original_mode; *com_buffer; in_source; source; status;
window(1, 1, 20, 16); clrscr();
/* Set the application text window */ /* Clear the screen */ printf("Demo im_receive_input\n'Q' to quit\n\'C' to clear screen\n"); /* Allocate a comm buffer */ com_buffer = (char *) malloc(COM_BUFSIZE); /* Get the previous input mode for restoring input mode later */ original_mode = im_get_input_mode(); /* Set Reader Wedge mode to program interface */ im_set_input_mode(IM_PROGRAMMER); /* Link com_buffer to com1 */ im_link_comm(IM_COM1, com_buffer, COM_BUFSIZE); /* Input loop */ do { /* Set up input source */ source = IM_LABEL_SELECT | IM_KEYBOARD_SELECT | IM_COM1_SELECT; /* Request input from label, keypad or com1 */ status = im_receive_input(source, IM_INFINITE_TIMEOUT, &source, input); length = im_get_length(source); if (IM_ISGOOD(status)) { /* Show the input source */ if (source == IM_LABEL_SELECT) printf("\nLabel input:\n"); else if (source == IM_KEYBOARD_SELECT) printf("\nKeybd input:\n"); else if ( source == IM_COM1_SELECT) printf("\nCom1 input:\n"); /* Display input data */ printf("%s\nInput length: %d\n", input, length); } else if (status == IM_APPLICATION_BREAK) { printf("application break detected"); } else /* input error */ printf("input error\n"); /* Upper case first char of input for simplifying to test input */ input[0] = toupper(input[0]); /*If the first char in string is 'C', then clear screen.*/ if (input[0] == 'C') clrscr(); } while (input[0] != 'Q');
/* First number in string is 'Q', then stop */
2-113
Page 143
im_receive_input
/* Unlink com_buffer from com1 */ im_unlink_comm(IM_COM1); /* Free allocated memory */ free(com_buffer); /* Restore original input mode */ im_set_input_mode(original_mode); }
2-114
Page 144
im_rs_installed
2 im_rs_installed Purpose:
This function determines whether or not the reader services (RSERVICE.EXE) program is installed.
Syntax:
#include <im20lib.h> IM_STATUS im_rs_installed (void);
IN Parameters:
None.
OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
See Also:
None.
Example /******************** im_rs_installed *******************************/ /* Also with: im_message */ #include <stdio.h> #include "im20lib.h" void main (void) { printf("Check for reader\nservice installation\n"); im_message( im_rs_installed() ); }
2-115
Page 145
im_rx_check_status im_rx_check_status Purpose:
This function directs the active protocol handler to check the communications port buffer status variable to determine if the application program has accepted the previous data. Use this function with the im_receive_buffer_no_wait function to receive input from multiple buffers.
Syntax:
#include <im20lib.h> IM_STATUS im_rx_check_status (IM_COM_PORT port_id);
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)
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.
See Also:
im_receive_buffer_no_wait
Example See example for im_receive_buffer_no_wait.
2-116
Page 146
im_serial_protocol_control
2 im_serial_protocol_control Purpose:
This function controls the protocol mode for a designated communications port and determines whether the receive mode is with or without protocol according to the input parameter. Any change clears the input buffer and resets the reader command parser. Use this function to set the protocol when connected to a communications port. The return value indicates a success if the port is currently linked to the Virtual Wedge. If the port is not currently linked to the Virtual Wedge, the function returns an error.
Syntax:
#include <im20lib.h> IM_STATUS im_serial_protocol_control (IM_COM_PORT port_id, IM_PROTOCOL_CMD protocol, IM_UCHAR eom_char);
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 protocol parameter affects how incoming messages are received and is one of these constants: IM_NO_CHANGE IM_PROTOCOL_OFF IM_PROTOCOL_ON IM_NEW_TERM_CHAR
Keep the current protocol Turn the protocol OFF Turn the protocol ON Use the new termination character
The protocol parameter affects all incoming messages as follows: • If IM_NO_CHANGE is specified, the protocol and end of message settings remain the same as the last time the function was called. • If IM_PROTOCOL_OFF is specified, the incoming data is terminated with the specified end of message character. If the end of message character is null, the function terminates upon receiving the first character.
2-117
Page 147
im_serial_protocol_control
• If IM_PROTOCOL_ON is specified, the incoming message is terminated with the end of message character of the active protocol. • If IM_NEW_TERM_CHAR is specified, IM_PROTOCOL_OFF is assumed and the new end of message character specified in the parameter list is used. The eom_char parameter is the end of message character needed to terminate input from the communications port. The character is normally a carriage return, but you can set it to any other character. An EOM character is required when using IM_PROTOCOL_OFF and IM_NEW_TERM_CHAR for protocol. OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
Requires im_link_comm. The receive buffers are cleared whenever the protocol is turned ON or OFF. To change the termination character (or to not change the setting at all), use IM_NEW_TERM_CHAR or IM_NO_CHANGE instead of toggling the protocol.
See Also:
im_link_comm
Example /******************** im_serial_protocol_control ************************/ /* Also with: im_set_input_mode */ /* im_link_comm */ /* im_unlink_comm */ #include <stdio.h> #include <conio.h> #include <dos.h> #include <stdlib.h> #include "immsg.h" #include "im20lib.h" #define
COM_BUFSIZE 300 void main (void) { IM_UCHAR *com_buffer; IM_UCHAR input[256]; IM_ORIGIN source;
2-118
/* Allocate 300 bytes for comm buffer */
Page 148
im_serial_protocol_control
IM_STATUS IM_CHAR int
2 status; *msg_ptr; sw_flag, order_flag;
window(1, 1, 20, 16); /* Set the reader services text window */ clrscr(); /* Clear the screen */ printf("Demo IM_SERIAL_PROTOCOL_CONTROL\n'Q' to quit\n"); /* Allocate a comm buffer */ com_buffer = (char *) malloc(COM_BUFSIZE); /* Set Reader Wedge into PROGRAMMER mode im_set_input_mode(IM_PROGRAMMER);
*/
/* Link com_buffer to com1 */ im_link_comm(IM_COM1, com_buffer, COM_BUFSIZE); order_flag = 0;
/* Set flag to start from CR & LF */
/* Demo Input loop */ do { sw_flag = order_flag % 3; switch (sw_flag) { case 0: /*Turn on protocol handle with EOM char CR & LF. */ status = im_serial_protocol_control(IM_COM1, IM_PROTOCOL_ON, 0x0D); msg_ptr = "CR & LF"; break; case 1: /* Turn off protocol handle with EOM char Ctrl-Z */ status = im_serial_protocol_control(IM_COM1, IM_PROTOCOL_OFF, 0x1A); msg_ptr = "Ctrl-Z"; break; case 2: /* Turn off protocol handle with EOM char Ctrl-Y */ status = im_serial_protocol_control(IM_COM1, IM_PROTOCOL_OFF, 0x19); msg_ptr = "Ctrl-Y"; break; } printf("\nEOM: %s, P-status: %x\n", msg_ptr, status); im_receive_input(IM_COM1, IM_INFINITE_TIMEOUT, &source, input); if ( source == IM_COM1_SELECT) { printf("%s\n", input); } else printf("error\n"); order_flag++; input[0] = toupper(input[0]); } while (input[0] != 'Q'); /* Unlink com_buffer from com1 */ im_unlink_comm(IM_COM1); /* Free allocated memory */ free(com_buffer); im_set_input_mode(IM_WEDGE); }
2-119
Page 149
im_set_abort_callback im_set_abort_callback Purpose:
This function sets up the callback address for notification of an exit program reader command. It determines which function is activated when /$ is received. For example, use this function when you are running a program and want to exit without using a warm boot.
Syntax:
#include <im20lib.h> IM_STATUS im_set_abort_callback (IM_ORIGIN source, void *notify_routine);
IN Parameters:
The source parameter is one of these constants: IM_LABEL_SELECT IM_COM1_SELECT IM_COM2_SELECT IM_COM4_SELECT IM_ALL_SELECT
No source selected COM1 selected COM2, scanner port selected (2010 and 2050) COM4 selected (RF only) All sources are selected
The notify_routine parameter is a pointer to the callback routine. OUT Parameters:
None.
Return Value:
This function returns one of the standard status codes defined in Appendix A, “Status Codes.”
Notes:
IRL uses the /$ as an exit command when received from a host or scanned from a label. This im_set_abort_callback function allows you to specify a routine that is called whenever the /$ is detected from the host or from the scanner. You can also use this capability from within a PSK application. The /$ is called the IRL exit command, but the application can use it for actions other than exiting the program. The callback is called by the Reader Wedge as soon as the /$ is detected. The /$ must be the only two characters in the string. Nothing occurs if the /$ is in the middle of other characters. It is recommended that your callback routine be short (such as setting a flag or performing some other action).
2-120
Page 150
im_set_abort_callback
2
Scan in the exit IRL program command to activate the abort callback. When the abort callback routine is called, the processor services an interrupt. The routine must reenable interrupts before doing any other interrupt-driven function such as writing to the screen. If you use im_set_abort_callback to set up a callback, you must use im_clear_abort_callback before exiting your program. Otherwise, the Reader Wedge continues to call the callback each time the /$ is detected. Since the callback is no longer at the address that the Reader Wedge calls, the result is unpredictable. The notification source parameter replaces the previously set source. Only one callback routine can be submitted. On callback, the abort function’s first parameter contains the origin of the abort program command. The second parameter is left for further expansion. This command does not work in Wedge mode. For this routine to work correctly, you must use the keyword _loadds to set the data segment in the callback routine. Since the abort routine is called as an interrupt, all other interrupts are disabled until the system returns from the abort function or until an interrupt is explicitly enabled. 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:
im_clear_abort_callback
2-121