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 8 of 40

2D JANUS PSK for C/C++ Reference Manual, pages 71 to 80

Pages 71 to 80 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 71

im_get_length

2 im_get_length Purpose:

This function returns the length of the string received from the designated source by the most recent im_receive_input function.

Syntax:

#include "im20lib.h" IM_USHORT im_get_length (IM_ORIGIN source);

IN Parameters:

The source parameter is one of these constants: IM_LABEL_SELECT IM_KEYBOARD_SELECT IM_COM1_SELECT IM_COM2_SELECT IM_COM4_SELECT

Label selected Keypad selected COM1 selected COM2, scanner port selected (2010 and 2050) COM4 selected (RF only)

OUT Parameters:

None.

Return Value:

This function returns the length of the last input string read from the designated source.

Notes:

All input using im_receive_input has a null termination character added to the end of the string so that it can be used as a normal C string. However, some data might contain embedded null characters. If so, this function supplies the true data length. For this function, all COM input is considered to be from the same source. For example, if you call im_receive_input with IM_COM1_SELECT and again with IM_COM4_SELECT, then a call to im_get_length with a source of IM_COM1_SELECT returns the length of the message received from COM4 because that was the last message read from a communications port. 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_receive_input

Example See example for im_receive_input.

2-45

Page 72

im_get_postamble im_get_postamble Purpose:

This function retrieves the currently configured postamble string and its length.

Syntax:

#include "im20lib.h" IM_STATUS im_get_postamble (IM_UCHAR *post_string, IM_USHORT *length);

IN Parameters:

None.

OUT Parameters:

The post_string parameter is the postamble string. The length parameter is the length of the postamble string.

Return Value:

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

Notes:

You can set the postamble with IC.EXE, with the im_command function and $+AE command, or by scanning a postamble. Refer to your JANUS user’s manual for more information on configuring a postamble.

See Also:

im_get_postamble, im_get_config_info

Example /******************** im_get_postamble *******************************/ #include <stdio.h> #include <string.h> #include "im20lib.h" void main(void) { IM_STATUS status; IM_USHORT length; IM_UCHAR post_string[128]; // Use im_get_postamble to get the Postamble string printf("\nim_get_postamble example: \n"); status = im_get_postamble(post_string, &length); // Print the results printf("\nPostamble: %s", post_string); printf("\nlength : %d", length); printf("\nstatus : %d\n", status); }

2-46

Page 73

im_get_preamble

2 im_get_preamble Purpose:

This function retrieves the currently configured preamble string and its length.

Syntax:

#include "im20lib.h" IM_STATUS im_get_preamble (IM_UCHAR *pre_string, IM_USHORT *length);

IN Parameters:

None.

OUT Parameters:

The pre_string parameter is the preamble string. The length parameter is the length of the preamble string.

Return Value:

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

Notes:

You can set the preamble with IC.EXE, with the im_command function and $+AE command, or by scanning a preamble. Refer to your JANUS user’s manual for more information on configuring a preamble.

See Also:

im_get_postamble, im_get_config_info

Example /******************** im_get_preamble *******************************/ #include <stdio.h> #include <string.h> #include "im20lib.h" void main(void) { IM_STATUS status; IM_USHORT length; IM_UCHAR pre_string[128]; // Use im_get_preamble to get the Preamble string printf("\nim_get_preamble example: \n"); status = im_get_preamble(pre_string, &length); // Print the results printf("\nPreamble: %s", pre_string); printf("\nlength : %d", length); printf("\nstatus : %d", status); }

2-47

Page 74

im_get_reboot_flag im_get_reboot_flag Purpose:

This function determines if the reader received a “Prepare For Reboot” command (..+%1) from a host for binary file transfer (BFT). Your application should periodically check if it has received a “Prepare for Reboot” command.

Syntax:

#include "im20lib.h" IM_USHORT im_get_reboot_flag( )

IN Parameters:

None.

OUT Parameters:

None.

Return Value:

This function returns one of the following:

Notes:

1

“Prepare for Reboot” (..+%1) has been received from the host.

0

“Prepare for Reboot” (..+%1) has not been received from the host. or “Cancel Reboot Preparation” (..+%0) has been received from the host.

When a host initiates a BFT, the JANUS reader must reboot with a server session open to establish a transfer session. The application should close any open files and perform cleanup tasks before rebooting. Input functions such as im_receive_input terminate when the “Prepare for Reboot” command is received. The application should check the return status from input functions to determine if “Prepare for Reboot” terminated the input function.

See Also:

2-48 im_ready_for_reboot

Page 75

im_get_reboot_flag

2

Example //******************im_get_reboot_flag************************************* #include <conio.h> #include <stdio.h> #include "im20lib.h" void main (void) { char inString[300]; // Buffer used by application char comString[300]; // Buffer used by comm utilities int done = 0; int length; int valid_source; IM_USHORT status; IM_USHORT reboot_flag; IM_ORIGIN source; IM_DECTYPE symbology; /* FUNCTION BODY */ clrscr(); im_set_input_mode(IM_PROGRAMMER); im_set_display_mode(IM_SIZE_MODE_20X16, IM_STD_VIDEO_MODE_3, IM_LCD_SCROLL_AT_16, IM_STANDARD_CHAR_HEIGHT); im_link_comm(IM_COM1, comString, 300); while (!done) { valid_source = 1; // assume source will be valid printf("\nEnter>>"); printf("\nPress Q to quit>>"); status = im_receive_input(IM_ALL_SELECT, IM_INFINITE_TIMEOUT, &source, inString); printf("\nStatus>%4x",status); if (source == IM_KEYBOARD_SELECT) { printf("\nFrom Keyboard"); } else if (source == IM_LABEL_SELECT) { printf("\nFrom Label"); im_get_label_symbology(&symbology); if (symbology == IM_CODE_39) { printf("\nCode 39"); } else { printf("\nWrong code!"); } } else if (source == IM_COM1_SELECT) { printf("\nFrom Serial"); } else { printf("\nUnknown source"); // Source = Unknown if reboot // command or abort command // received valid_source = 0; } if (valid_source) { length = im_get_length(source); printf("\nRecvd>>%s",inString);

2-49

Page 76

im_get_reboot_flag printf("\nLength>%d",length); if (inString[0] == 'Q' || inString[0] == 'q') done = 1; } else { reboot_flag = im_get_reboot_flag(); if (reboot_flag) { printf("\nReboot flag is set"); status = im_ready_for_reboot(IM_TRUE); } else { printf("\nReboot flag not set"); status = im_ready_for_reboot(IM_FALSE); } } } im_unlink_comm(IM_COM1); im_set_display_mode(IM_SIZE_MODE_80X25, IM_STD_VIDEO_MODE_3, IM_LCD_SCROLL_AT_16, IM_STANDARD_CHAR_HEIGHT); im_set_input_mode(IM_WEDGE); }

2-50

Page 77

im_get_viewport_lock

2 im_get_viewport_lock Purpose:

This function retrieves the current setting of the viewport lock. When the display is in 80 x 25 mode, you can use the viewport in virtual display mode unless the currently running application program restricts it. The application program may require the viewport to be locked or unlocked. The viewport lock only affects the user’s ability to move the viewport with the viewport control keys.

Syntax:

#include "im20lib.h" IM_STATUS im_get_viewport_lock (IM_CONTROL *viewport_lock);

IN Parameters:

None.

OUT Parameters:

The viewport_lock parameter is one of these constants: IM_ENABLE IM_DISABLE

Viewport is locked Viewport is unlocked

Return Value:

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

Notes:

The display must be in 80 x 25 mode (see im_set_display_mode) to use this function. This function has no effect on the JANUS 2050. When the viewport is “locked,” the viewport movement keys do not move the viewport. The viewport can still move if follow-the-cursor mode is enabled.

See Also:

im_set_viewport_lock, im_set_display_mode, im_get_display_mode, im_get_follow_cursor, im_set_follow_cursor

2-51

Page 78

im_get_viewport_lock

Example /******************** im_get_viewport_lock *******************************/ /* Also with: im_set_viewport_lock */ #include <stdio.h> #include <conio.h> #include <ctype.h> #include <stdlib.h> #include "im20lib.h" #define

ESC_CHAR

0x1B void main (void) { IM_UCHAR ch, user_option; IM_CONTROL current_viewport_lock; clrscr();

/* Clear screen */

/* Get the current status of viewport lock for restore later */ im_get_viewport_lock(&current_viewport_lock); /* Get user's input option, 'y' for disable viewport lock */ printf("\nEnable viewport\nlock(y)?"); user_option = toupper( getch()); if (user_option == 'Y') { /* Enable viewport lock */ im_set_viewport_lock(IM_ENABLE); printf("\n\n'ESC' to quit!\nType _f and arrow keys\n"); printf("See viewport lock!"); } else { /* Disable viewport lock */ im_set_viewport_lock(IM_DISABLE); printf("\n'ESC' to quit\nType _f and arrow keys\n"); printf("See viewport unlock!"); } /* Enter characters loop to check viewport movement until 'ESC' key. */ while ( (ch = getch()) != ESC_CHAR ) putch(ch); /* Restore viewport lock */ im_set_viewport_lock(current_viewport_lock); }

2-52

Page 79

im_get_warm_boot

2 im_get_warm_boot Purpose:

This function retrieves the current setting of the warm boot status flag. You can enable or disable the Ctrl-Alt-Del warm boot key sequence. When disabled, pressing the Ctrl-Alt-Del sequence does not reboot the reader.

Syntax:

#include "im20lib.h" IM_STATUS im_get_warm_boot (IM_CONTROL *warm_boot);

IN Parameters:

None.

OUT Parameters:

The warm_boot parameter is one of these constants: IM_ENABLE IM_DISABLE

Ctrl-Alt-Del warm boot is enabled Ctrl-Alt-Del warm boot is disabled

Return Value:

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

See Also:

im_set_warm_boot

2-53

Page 80

im_get_warm_boot

Example /******************** im_get_warm_boot *******************************/ /* Also with: im_set_warm_boot */ #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <ctype.h> #include "im20lib.h" void main (void) { IM_UCHAR user_option; IM_CONTROL old_warmboot; IM_CONTROL new_warmboot; clrscr(); gotoxy(1,1);

/* Clear screen */ /* Position message */

/* Get the current status of warn boot */ im_get_warm_boot(&old_warmboot); /* Display warm boot's status */ if (old_warmboot == IM_ENABLE) printf("Warm boot enabled!"); else printf("Warn boot disabled!"); /* Get user's input option, 'y' for enabling warm boot */ printf("\n\nEnable warmboot(y)?"); user_option = getche(); user_option = toupper(user_option); if (user_option == 'Y') { /* Warm boot enable */ im_set_warm_boot(IM_ENABLE); } else { /* Warm boot disable */ im_set_warm_boot(IM_DISABLE); } /* Get new warm boot's status after setting */ im_get_warm_boot(&new_warmboot); /* Display user's input setting */ if (new_warmboot == IM_ENABLE) printf("\nwarm boot enabled!"); else printf("\nWarm boot disabled!"); printf("\nTest it>>\n"); getch(); }

2-54