The text of a manual · part 39 of 42
JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 381 to 390
Pages 381 to 390 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 381
jbeep.cpp
B jbeep.cpp /* jbeep.cpp * * This program demonstrates sound control using interrupts. * Usage is: JBEEP volume pitch duration off_time * JBEEP 3 (Loud) 1000 (Hz) 500 (ms) 20 (ms) * * Written: Aug. 20, 1993 * Last Modified: Sept. 9, 1993 * Author: Ray Rogers * Compiler: Borland C++ 3.1 */ #include "stdio.h" #include "string.h" #include "dos.h" #include "conio.h" #include "stdlib.h" #include "im20lib.h" // Defines #define SOUND_Int0x7c typedef struct { IM_UCHAR volume; IM_UINT pitch; IM_UINT duration; IM_UINT off_time; } IM_BEEP_PARAMS;
// sound generation interrupt // beeper sound structure
// Prototypes IM_UINT Make_Noise(IM_UCHAR, IM_UINT, IM_UINT, IM_UINT); void main(int argc, char *argv[]) { Make_Noise(argc > 1 ? atoi(argv[1]) : 5, argc > 2 ? atoi(argv[2]) : 1000, argc > 3 ? atoi(argv[3]) : 200, argc > 4 ? atoi(argv[4]) : 20); }
// default volume // default pitch // default duration // default off_time
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); // points to beeper structure _BX = FP_OFF((IM_BEEP_PARAMS far *) &Beeper); // points to beeper structure _CX = _DX = 0; _AX = 0x64;
// to be safe // sound function geninterrupt(SOUND_Int);
// generate the noise return(_AX); }
B-29
Page 382
jboot.cpp jboot.cpp /* jboot.cpp * * This program demonstrates warm boot control by using interrupts to enable/disable * the warm boot capability. * * Written: Aug. 25, 1993 * Last Modified: Aug. 25, 1993 * Author: Ray Rogers * Compiler: Borland C++ 3.1 #include "stdio.h" #include "string.h" #include "dos.h" #include "conio.h" #include "stdlib.h" #include "im20lib.h" // Defines #define KEY_Int 0x16 #define STATUS 2 #define ENABLE 1 #define DISABLE 0 #define PROHIBITED 0x0000
// keyboard interrupt // get boot status // enable boot // disable boot // warm boot prohibited status
// Prototypes IM_UINT Set_Boot(IM_UCHAR); void main() { IM_UINT resp; clrscr(); resp = Set_Boot(STATUS);
// get the current boot status if(resp == PROHIBITED) // if boot is currently prohibited { Set_Boot(ENABLE); printf("%s", "\n\rWarm boot enabled...\n\r"); } else { Set_Boot(DISABLE); printf("%s", "\n\rWarm boot disabled...\n\r"); } exit(0); } // Sets the boot control to enable or disable IM_UINT Set_Boot(IM_UCHAR status) { _AH = 0xB7; // Ctrl-Alt-Del function _AL = status; geninterrupt(KEY_Int); return(_AX); }
B-30
Page 383
keybuff.cpp
B keybuff.cpp /* keybuff.cpp * * This program demonstrates keyboard buffer control using interrupts. * disables, and tests the expanded keyboard buffer. * * From the command line, enter: * keybuff enable or * keybuff disable or * keybuff test * * Written: Sept. 1, 1993 * Last Modified: Sept. 1, 1993 * Author: Ray Rogers * Compiler: Borland C++ 3.1 */
It enables,
#include "dos.h" #include "stdlib.h" #include "string.h" #include "conio.h" #include "stdio.h" #include "im20lib.h" #define #define #define #define #define #define #define #define #define #define
KEY_Int 0x16 KB_BUFF 0xb4 KB_INSERT 0xb5 KB_FLUSH 0xb6 KB_OFF 0x02 KB_ON 0x01 KB_OK 0x00 KB_NO_BUFF 0x01 KB_BUFF_FULL 0x02 TRUE 0x00
// keyboard interrupt // buffer enable/disable function // insert string into buffer // flush the buffer // function is off // function is on // function completed ok // buffer is enabled // buffer is full
// Prototypes IM_UINT KB_Func(IM_UCHAR, IM_UCHAR); IM_UINT KB_Test(void); void main(int { IM_UINT resp;
argc, char
*argv[])
clrscr(); if(argc == 1) // no command line arguments { printf("%s", "\n\rUsage: keybuff [enable | disable | test]"); exit(0); } KB_Func(KB_FLUSH, 0);
// no effect if buffer not there if(TRUE == strcmp("enable", strlwr(argv[1]))) { KB_Func(KB_BUFF, KB_ON); printf("%s", "\n\rBuffer Enabled\n\r"); }
B-31
Page 384
keybuff.cpp if(TRUE == strcmp("disable", strlwr(argv[1]))) { KB_Func(KB_BUFF, KB_OFF); printf("%s", "\n\rBuffer Disabled\n\r"); } if(TRUE == strcmp("test", strlwr(argv[1]))) { if((resp = KB_Test()) != KB_OK) if(resp == KB_NO_BUFF) printf("%s", "\n\rNo buffer installed!\n\r"); else if(resp == KB_BUFF_FULL) printf("%s", "\n\rBuffer is full!\n\r"); } exit(0); } // Execute requested keyboard buffer function IM_UINT KB_Func(IM_UCHAR func, IM_UCHAR subfunc) { _AH = func; // keypad function _AL = subfunc; // subfunction geninterrupt(KEY_Int); return(_AL); } // Test the keyboard bffer IM_UINT KB_Test() { static char work[] = "This is a test of the keyboard buffer string insertion function"; _ES = FP_SEG(work); _BX = FP_OFF(work);
// address of inserted string
_CX = strlen(work);
// length of inserted string
_AH = KB_INSERT; _AL = 0x02;
// insert function // ASCII mode, no scancode translation geninterrupt(KEY_Int); return(_AL); }
B-32
Page 385
keyclick.cpp
B keyclick.cpp /* keyclick.cpp * * This program demonstrates key click control using interrupts. It toggles the * state of the key click. * .* Written: Aug. 31, 1993 * Last Modified: Sept. 1, 1993 * Author: Ray Rogers * Compiler: Borland C++ 3.1 */ #include "dos.h" #include "stdlib.h" #include "conio.h" #include "stdio.h" #include "im20lib.h" #define #define #define #define #define #define #define #define
KEYPAD_Int 0x7e KP_CLICK 0x05 KP_OFF 0x00 KP_ON 0x01 KP_STATUS 0x02 KP_ENABLED 0xff VALID_SERVICE 0x00 TRANS_OK 0x00 typedef struct { IM_UCHAR status; IM_UCHAR kp_status; IM_UINT padding; } RESP_BUFF; RESP_BUFF
// keypad interrupt // keypad click function // function is off // function is on // get status // function is enabled // valid function call // func transaction executed ok // KSCPU comm status // 0xff if function already enabled // work space rbuff;
// Prototypes IM_UINT KP_Func(IM_UCHAR, IM_UCHAR, RESP_BUFF *); void main() { clrscr(); if(VALID_SERVICE == KP_Func(KP_CLICK, KP_STATUS, &rbuff)) // get current status of // click if(TRANS_OK == rbuff.status) if(rbuff.kp_status == KP_ENABLED) // if it is on... { KP_Func(KP_CLICK, KP_OFF, &rbuff); // turn it off printf("%s", "\n\rKey click DISABLED\n\r\n\rPress a key..."); } else { KP_Func(KP_CLICK, KP_ON, &rbuff); // else, turn it on printf("%s", "\n\rKey click ENABLED\n\r\n\rPress a key..."); } while(!kbhit()); getch(); clrscr(); exit(0);
// wait for a keypress
B-33
Page 386
keyclick.cpp
}
B-34
Page 387
keyclick.cpp
B
// 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;
// keypad function // subfunction geninterrupt(KEYPAD_Int); return(_AH); }
B-35
Page 388
keystat.cpp keystat.cpp /* keystat.cpp * * This program demonstrates how to use the keyboard scanner and map table access using * interrupts. * * Written: Aug. 31, 1993 * Last Modified: Aug. 31, 1993 * Author: Ray Rogers * Compiler: Borland C++ 3.1 */ #include #include #include #include #include
"dos.h" "stdio.h" "stdlib.h" "conio.h" "im20lib.h"
#define #define #define #define #define #define #define #define
KEY_Int 0x7e ESC 0x1b FOREVER 1 SCAN_VER 0x03 MAP_ID 0x04 VALID_SERVICE 0x00 TRANS_OK 0x00 TABLE_VALID 0xff
// keyboard interrupt // escape key // endless loop control // keypad scanner version function // map table ID function // valid function call // function executed ok // valid keypad table typedef struct { IM_UCHAR status; IM_UCHAR minor; IM_UCHAR major; IM_UINT padding; } scanner_buff;
// KSCPU comm status // minor revision // major revision // work space // keypad scanner version typedef struct { IM_UCHAR status; IM_UCHAR kp_number; IM_UCHAR tabl_valid; IM_UINT chksum; IM_UINT padding; } map_table_buff;
// KSCPU comm status // keypad number // table validation, 0xff = pass // crc checksum // work space // map table ID buffer typedef union { scanner_buff scan; map_table_buff map; } RESP_BUFF; RESP_BUFF rbuff;
// Prototypes IM_UINT KP_Info(IM_UCHAR, RESP_BUFF *); void main() { clrscr();
B-36
// KSCPU response buffer
Page 389
keystat.cpp
B if(VALID_SERVICE == KP_Info(SCAN_VER, &rbuff)) { if(rbuff.scan.status == TRANS_OK) { printf("\n\rKeyPad Rev.= %d.%2d", rbuff.scan.major, rbuff.scan.minor); } } // end VALID_SERVICE if(VALID_SERVICE == KP_Info(MAP_ID, &rbuff)) { if(rbuff.map.status == TRANS_OK) { printf("\n\rMap ID= %X", rbuff.map.kp_number); printf("\n\rValid Table= %s", rbuff.map.tabl_valid == TABLE_VALID ? "Yes" : "No "); printf("\n\rCheck sum= %4X", rbuff.map.chksum); } } // end VALID_SERVICE printf("%s", "\n\r\n\rPress any key..."); while(!kbhit()); // wait for key press getch(); clrscr(); exit(0); } // Do keypad functions IM_UINT KP_Info(IM_UCHAR func, RESP_BUFF *rbuff) { _ES = FP_SEG((RESP_BUFF *) rbuff); // far pointer to response buffer _BX = FP_OFF((RESP_BUFF *) rbuff); // far pointer to response buffer _AH = func;
// scanner version or map ID function geninterrupt(KEY_Int); return(_AH); }
B-37
Page 390
numpad.cpp 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-38