The text of a manual · part 39 of 40
2D JANUS PSK for C/C++ Reference Manual, pages 381 to 390
Pages 381 to 390 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 381
numpad.cpp
B numpad.cpp /* numpad.cpp * * This program demonstrates key click control using interrupts. * modality of the keypad. * * Written: Sept. 1, 1993 * Last Modified: Sept. 1, 1993 * Author: Ray Rogers * Compiler: Borland C++ 3.1 */
It toggles the
#include "dos.h" #include "stdlib.h" #include "conio.h" #include "stdio.h" #include "im20lib.h" #define #define #define #define #define #define #define #define #define #define #define
KEYPAD_Int 0x7e KP_NUMPAD 0x06 KP_OFF 0x00 KP_ON_NUM_ON 0x01 KP_ON_NUM_OFF 0x02 KP_STATUS 0x03 KP_ENABLED 0xff VALID_SERVICE 0x00 TRANS_OK 0x00 ESC 0x1b FOREVER 1 typedef struct { IM_UCHAR status; IM_UCHAR pad_status; IM_UCHAR permit_status; IM_UINT padding; } RESP_BUFF; RESP_BUFF
// keypad interrupt // keypad numpad function // function is off // pad enabled, numlock is on // pad enabled, numlock is off // get status // function is enabled // valid function call // func transaction executed ok // ESC key // endless loop // KSCPU comm status // 0xff if function already enabled // 0xff if switching modality from keypad // permitted // work space rbuff;
// Prototypes IM_UINT KP_Func(IM_UCHAR, IM_UCHAR, RESP_BUFF *); void main() { IM_UCHAR ch; clrscr(); printf("%s", "\n\rCurrent NumPad Status:"); if(VALID_SERVICE == KP_Func(KP_NUMPAD, KP_STATUS, &rbuff)) // get curr. status of //click if(TRANS_OK == rbuff.status) if(rbuff.pad_status == KP_ENABLED) // if it is on... printf("%s", "\n\rNUMPAD ENABLED - \n\rPC KB 102 codes in use\n\r\n\r"); else printf("%s", "\n\rNUMPAD DISABLED - \n\rQWERTY codes in use\n\r\n\r"); printf("%s", "Choose New Setting:\n\r1. Disable Numpad\n”); printf("%s", "\r2. Enable, NumLk On\n\r3. Enable, NumLk Off\n\r");
B-31
Page 382
numpad.cpp
KP_Func(KP_NUMPAD, KP_OFF, &rbuff);
// make sure we can get menu choice ch = ' '; while(ch != ESC) { ch = getch(); switch(ch) { case '1': KP_Func(KP_NUMPAD, KP_OFF, &rbuff); ch = ESC; break; case '2': KP_Func(KP_NUMPAD, KP_ON_NUM_ON, &rbuff); ch = ESC; break; case '3': KP_Func(KP_NUMPAD, KP_ON_NUM_OFF, &rbuff); ch = ESC; break; }; } clrscr(); exit(0); } // Execute requested keypad function IM_UINT KP_Func(IM_UCHAR func, IM_UCHAR subfunc, RESP_BUFF *resp) { _ES = FP_SEG(resp); _BX = FP_OFF(resp); _AH = func; _AL = subfunc; _CL = 0x01; geninterrupt(KEYPAD_Int); return(_AH); }
B-32
// keypad function // subfunction // keypad mode switching permitted
Page 383
open.cpp
B open.cpp /* open.cpp * * This program demonstrates how to open COM2 on the 2D JANUS. * * Written: Feb. 10, 1999 * Last Modified: Feb. 10, 1999 * Author: Peter J. Girodat * Compiler: Borland C++ 3.1 */ #include <dos.h> #include <stdio.h> #include <stdlib.h> #define RS_VECTOR 0x7D #define RS_ASIC_RESET 0x0C #define RS_CLOSE_COM2 0x0D #define RS_ALL_SUCESS 0x0100 #define RS_INVALID_REQUEST 0x8100 void main() { _AH = RS_ASIC_RESET; _AL = 0;
/* Interrupt 7DH Reader Services */ /* Function 0CH ASIC Reset */ /* Function 0DH Close COM2 */ /* Reader Service sucessful */ /* Invalid function Hex code received */
// AH = Function 0CH geninterrupt(RS_VECTOR); if (_AX == RS_ALL_SUCESS) printf ("COM2 OPEN\n"); else if (_AX == RS_INVALID_REQUEST) printf ("JANUS 1D Reader\n"); }
B-33
Page 384
phterm.cpp phterm.cpp /* phterm.cpp * * This program demonstrates how to use interrupts and protocol. It requires a * Janus running PHIMEC.EXE and a connection to something else using an INTERMEC * protocol. * * Written: Aug. 12, 1993 as PHCOMM, derived PHTERM Feb. 28, 1994 * Last Modified: March 1, 1994 * Author: Ray Rogers * Compiler: Borland C++ 3.1, small model */ #include "stdio.h" #include "string.h" #include "dos.h" #include "conio.h" #include "stdlib.h" #include "im20lib.h" // Defines #define COM_Int 0x14 #define LCD_Int 0x79 #define SOUND_Int 0x7c #define VIDEO_Int 0x10 #define ESC 0x1b #define TXBUFFSIZE 512 #define RXBUFFSIZE 512 #define COM_PORT 3 #define LOUD 3 #define NORMAL 2 #define LOW 1 #define BOOL IM_UINT #define TRUE 1 #define FOREVER TRUE typedef struct { IM_UCHAR volume; IM_UINT pitch; IM_UINT duration; IM_UINT off_time; } IM_BEEP_PARAMS;
// Communications interrupt // LCD size mode manager interrupt // sound generation interrupt // video interrupt // char 27, Escape // transmit buffer size // receive buffer size // default to com port 0 for Janus // loud volume for beep // normal volume for beep // low volume for beep
// beeper sound structure
// struct for window control on JANUS typedef struct { IM_UCHAR ur; // upper row IM_UCHAR uc; // upper column IM_UCHAR lr; // lower row IM_UCHAR lc; // lower column IM_UCHAR cr; // current row, relative to this window IM_UCHAR cc; // current column, relative to this window } JANUS_WINDOW; // Global Variables IM_UINT vm_mode; IM_UINT vm_params; IM_COM_DATA_BUFFER s_struct; IM_COM_DATA_BUFFER r_struct;
B-34
// saves original video mode // saves original video parameters // send structure // receive structure
Page 385
phterm.cpp
B
IM_UCHAR s_buff[TXBUFFSIZE]; // send buffer IM_UCHAR r_buff[RXBUFFSIZE]; // receive buffer JANUS_WINDOW iw = {0, 0, 0, 19, 0, 0}; // input window JANUS_WINDOW ow = {3, 0, 14, 19, 0, 0}; // output window // Prototypes IM_UINT Ck_RX_Buffer_Status(IM_UINT portid); IM_UINT TX_Buffer(IM_UINT portid); IM_UINT RX_Buffer(IM_UINT portid); IM_UINT Set_Video_Mode(void); IM_UINT Make_Noise(IM_UCHAR, IM_UINT, IM_UINT, IM_UINT); IM_UINT Get_Input(void); void Reset_Video_Mode(void); void Cancel_TX(IM_UINT port); void Cancel_RX(IM_UINT port); void Pos_Cursor(JANUS_WINDOW *, IM_UINT, IM_UINT); void Shift_Left(IM_UINT); void Blank_Input(void); void Ck_y(JANUS_WINDOW *); void main() { if(Set_Video_Mode()) // set video mode, sound beep and exit on failure { Make_Noise(LOUD, 2000, 200, 20); // loud, high pitch Make_Noise(NORMAL, 500, 250, 20); // normal, low pitch exit(1); } Pos_Cursor(&ow, 0, -1); printf("%s", "____________________"); ow.cr = 0; Pos_Cursor(&iw, 0, 0); r_buff[0] = '\0'; RX_Buffer(COM_PORT);
// read the comm line
// main processing loop, exit loop on ESC key while(FOREVER) { if(Get_Input() == ESC) // get input from keyboard or comm line break; TX_Buffer(COM_PORT); }
// end main loop
Reset_Video_Mode(); Cancel_TX(COM_PORT); Cancel_RX(COM_PORT);
// return video mode to original settings // shut down interface to protocol handler
Make_Noise(LOUD, 1000, 200, 20); Make_Noise(NORMAL, 250, 250, 20);
// loud, high pitch // normal, low pitch exit(0); } // Prepare input line for new input by clearing out the old void Blank_Input() { Pos_Cursor(&iw, 0, 0); printf("%s", " "); Pos_Cursor(&iw, 0, 0);
B-35
Page 386
phterm.cpp
} // Cancel the RX buffer void Cancel_RX(IM_UINT port) { _DX = port; _AH = 0x84; geninterrupt(COM_Int); } // Cancel the TX buffer void Cancel_TX(IM_UINT port) { _DX = port; _AH = 0x85; geninterrupt(COM_Int); } //Check the receive buffer is a misnomer for this function since it actually instructs //the protocol handler to receive a packet. After that, you must check //protocol_xfer_status periodically to see if anything has been received yet. IM_UINT Ck_RX_Buffer_Status(IM_UINT port) { r_struct.command = IM_CU_RECV_AGAIN; // set the cmd to receive *(r_struct.data_ptr) = '\0'; r_struct.comm_length = 0; _DX = port; _AH = 0x17;
// select the com port // check com port receive buffer status function geninterrupt(COM_Int); return(r_struct.protocol_xfer_status); } // Check the row position that is about to be used for displaying a line // received from the comm port. If it is the bottom of the screen, scroll // the window to make room. void Ck_y(JANUS_WINDOW *jw) { if(jw->ur+jw->cr > jw->lr) { jw->cr--; _AH = 0x06; // video scroll function _AL = 1; // number of lines to scroll _CH = jw->ur; // upper left row _CL = jw->uc; // upper left column _DH = jw->lr; // lower right row _DL = jw->lc; // lower right col _BH = 0x07; // normal video mode geninterrupt(VIDEO_Int); } } // Position the cursor outside the defined text window void Pos_Cursor(JANUS_WINDOW *jw, IM_UINT loc, IM_UINT row) { jw->cr = row; jw->cc = loc;
B-36
Page 387
phterm.cpp
B
_DH = jw->ur+row; // row _DL = jw->uc+loc; // column _BH = 0; // page _AH = 0x02; // position cursor function geninterrupt(VIDEO_Int); // video } // Get the next input string from the keyboard while watching for input from the comm line IM_UINT Get_Input() { IM_UINT x, ch; ch = x = 0; iw.cc = 0; while(ch != ESC && ch != '\r') { if(kbhit()) { ch = getch();
// keybd input ends with CR or ESC
// use getch(), then printf() because JANUS if(ch == '\r') Blank_Input(); // clears input line for clean start else if(iw.uc+iw.cc >= iw.lc) Shift_Left(x); // input exceeds line length, scroll left else Pos_Cursor(&iw, iw.cc, 0); printf("%c", ch); if(ch == '\b') { x--; iw.cc--; } else { iw.cc++; s_buff[x++] = ch; } }
// doesn't like getche() or cputs() // backspace is the only supported editing key if(r_struct.protocol_xfer_status == 0x0601)
// 0x0601 is comm buffer done from // last recv request
{ *(r_struct.data_ptr + r_struct.comm_length) = '\0'; // add null to receive Ck_y(&ow); // buffer Pos_Cursor(&ow, 0, ow.cr); ow.cr++; printf("%s\n\r", r_buff); // print buffer contents Pos_Cursor(&iw, 0, 0); Ck_RX_Buffer_Status(COM_PORT); // issue request for next packet } } strcpy(&s_buff[x], "\n"); return(ch);
// add a line feed and a null character
} // read the receive buffer IM_UINT RX_Buffer(IM_UINT port) { r_struct.command = IM_CU_RECEIVE;
// set the cmd to receive
B-37
Page 388
phterm.cpp r_struct.user_length = RXBUFFSIZE; r_struct.data_ptr = (IM_UCHAR far *) r_buff; r_struct.protocol_mode = IM_USE_PROTOCOL; _ES = FP_SEG((IM_COM_DATA_BUFFER far *) &r_struct); _BX = FP_OFF((IM_COM_DATA_BUFFER far *) &r_struct); _DX = port; _AH = 0x60;
// select the com port // receive buffer geninterrupt(COM_Int); return(r_struct.protocol_xfer_status); } // transmit the transmit buffer IM_UINT TX_Buffer(IM_UINT port) { s_struct.command = IM_CU_TRANSMIT; // set the cmd to transmit s_struct.data_ptr = (IM_UCHAR far *) s_buff; s_struct.user_length = strlen((IM_UCHAR far *) s_buff); s_struct.protocol_mode = IM_USE_PROTOCOL; _ES = FP_SEG((IM_COM_DATA_BUFFER far *) &s_struct); _BX = FP_OFF((IM_COM_DATA_BUFFER far *) &s_struct); _DX = port; _AH = 0x50;
// select the com port // transmit buffer geninterrupt(COM_Int); return(s_struct.protocol_xfer_status); } // Make a noise to indicate a failure condition of some kind has occurred IM_UINT Make_Noise(IM_UCHAR volume, IM_UINT pitch, IM_UINT duration, IM_UINT off_time) { static IM_BEEP_PARAMS Beeper; // beeper sound structure Beeper.volume = volume; // loud Beeper.pitch = pitch; // HZ Beeper.duration = duration; // ms Beeper.off_time = off_time; // ms _ES = FP_SEG((IM_BEEP_PARAMS far *) &Beeper); _BX = FP_OFF((IM_BEEP_PARAMS far *) &Beeper);
// points to beeper structure // points to beeper structure
_CX = _DX = 0; _AX = 0x64;
// to be safe // sound function geninterrupt(SOUND_Int);
// generate the noise return(_AX); } // Set the video mode to 20x16 IM_UINT Set_Video_Mode() { _AH = 0x02; _AL = 0x03;
B-38
// function 2 of int 79h // get current video mode geninterrupt(LCD_Int);
// LCD display size mode manager interrupt vm_mode = _AH; vm_params = _BX;
// save the current video mode // save original video parameters
Page 389
phterm.cpp
B
_AH = 0x02; _AL = 0x01;
// function 2 of int 79h // set mode to 20x16 geninterrupt(LCD_Int);
// LCD display size mode manager interrupt return(_AL);
// return status, _AL = 0 if good, 0xFF if failed
} // Return the video mode to its original status void Reset_Video_Mode() { _BX = vm_params; // restore the original video parameters _AH = 0x02; // function 2 of int 79h _AL = 0x00; _BH = vm_mode; // restore the original video mode geninterrupt(LCD_Int);
// LCD display size mode manager interrupt
} // When input exceeds line length, scroll the line left void Shift_Left(IM_UINT x) { s_buff[x] = ' '; s_buff[x+1] = '\0'; Pos_Cursor(&iw, 0, 0); printf("%s", s_buff+x-iw.lc+1); Pos_Cursor(&iw, iw.lc-1, 0); }
B-39
Page 390
pl220ver.cpp pl220ver.cpp /* pl220ver.cpp * * This program demonstrates how to display the Symbol PL220 Decoder * firmware revision level using interrupts. * * Written: Jan. 11, 1999 * Last Modified: Feb. 25, 1999 * Author: Peter J. Girodat * Compiler: Borland C++ 3.1 */ #include <dos.h> #include <stdio.h> #include <stdlib.h> #define RS_VECTOR 0x7D #define RS_PL220_VER 0x0A #define RS_ALL_SUCESS 0x0100 #define RS_INVALID_REQUEST 0x8100
/* Interrupt 7DH Reader Services */ /* Function 0AH PL 220 Version */ /* Reader Service sucessful */ /* Invalid function Hex code received */ void main() { char pl220_version[16]; _ES = FP_SEG((void*)pl220_version); // ES:BX Far pointer to pl220_version _BX = FP_OFF((void*)pl220_version); _AH = RS_PL220_VER; // AH = Function 0AH _AL = 0; geninterrupt(RS_VECTOR); if (_AX == RS_ALL_SUCESS) printf("%s\n",pl220_version); else if (_AX == RS_INVALID_REQUEST) printf ("JANUS 1D Reader\n"); }
B-40