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

2D JANUS PSK for C/C++ Reference Manual, pages 371 to 380

Pages 371 to 380 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 371

fifo.cpp while(TRUE) { if(PM_Event()) Restore_UART();

B

// main processing loop

/* ** Do communications here */ if(kbhit()) if(getch() == ESC) break; }

// exit program on escape

// end main loop

PM_Disconnect(); } //APM installation check void PM_Check() { _AX = 0x5300; _BX = 0x0000; geninterrupt(PM_Int); } // Connect this program to Power Management void PM_Connect() { _AX = 0x5301; // register as a PM partner _BX = 0x0000; geninterrupt(PM_Int); } // Disconnect this program from Power Management void PM_Disconnect() { _AX = 0x5304; // resign as a PM partner _BX = 0x0000; geninterrupt(PM_Int); } // Poll PM event status int PM_Event() { int event; _AX = 0x530b;

// ask for event status geninterrupt(PM_Int); if(_FLAGS & CARRY) return(FALSE);

// if carry flag set function failed event = _BX;

// status returned in bx if(event == NORMAL_RESUME || event == CRITICAL_RESUME) return(TRUE); else return(FALSE);

B-21

Page 372

fifo.cpp

} // Prepare the FIFO register value void Set_FIFO() { FCR = 0x80; }

// set FIFO trigger to 8 bytes

// Store the readable UART registers so that they can be restored // if necessary void Store_UART() { _AX = 0x0600; // get UART cfg and save _BL = 0x01; geninterrupt(UART_Int); _AX = 0x0606; _BL = 0x01; _BH = FCR;

// save FCR value geninterrupt(UART_Int); // NOTE: In a real program it would be wise to use a return value here } // Restore the all UART settings including FCR after power returns void Restore_UART() { _AX = 0x0604; // restore UART settings _BL = 0x01; geninterrupt(UART_Int); }

B-22

Page 373

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_Int 0x7c 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-23

Page 374

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

Page 375

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

Page 376

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

Page 377

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

Page 378

keyclick.cpp

} // 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-28

Page 379

keystat.cpp

B 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;

// KSCPU response buffer

// Prototypes IM_UINT KP_Info(IM_UCHAR, RESP_BUFF *); void main() { clrscr();

B-29

Page 380

keystat.cpp 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; geninterrupt(KEY_Int); return(_AH); }

B-30

// scanner version or map ID function