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

PEN*KEY 6100 Computer Programmer's Reference Guide: Appendix B: Common PEN*KEY 6000 Series Information, pages 281 to 288

Pages 281 to 288 of 328, from PEN*KEY 6100 Computer Programmer's Reference Guide

The original document is the PDF (1.2 MB). 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 Norand 6100

Page 281

Appendix B

Common PEN*KEY 6000 Series Information "

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

"

Introduction This section contains information that is common to most of the PEN*KEYR 6000 Series Hand-Held Computers. If you are a new user, you may find this inĆ formation useful. The following list outlines the major topics in the section. Topic Summary

NORAPM.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-2

APMCODES.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-3

B. Common PEN*KEY 6000 Series Info.

Development Support Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page B-2 used for developing applications with Advanced Power Management (APM)

Sample Program Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-5

Charge Detection Demo Program: TESTCHRG.CPP . . . . . . . . . . . . . . . . . . . . .

B-5 a sample program listing demonstrating a method of accessing NORAPM.DLL

Critical Error Handler: CRITICAL.C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-6 a sample program listing demonstrating the handling of critical errors

IDLE.CPP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-10 sample program that demonstrates the use of the CPU Idle interrupt

Keyboard Remapping, with ANSI.SYS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-10

Memory Overview (PEN*KEY 6000 Series Computer) . . . . . . . . . . . . . . . . . . .

B-12 a review of the basic memory system, as it applies to the PEN*KEY 6000 Series sysĆ tems, including some noteworthy design aspects of the 6000 Series systems and how applications fit into that environment

The Windows Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

B-18 an overview of the Microsoft Windows environment, describing how Windows, BIOS, applications, and drivers all fit together with the hardware in a PEN*KEY 6000 SeĆ ries system

PEN*KEY R 6100 Computer Programmer’s Reference Guide

B-1

Page 282

Common PEN*KEY 6000 Series Information

APPENDIX B

Development Support Files NORAPM.H // NORAPM.H: Header file containing exported structures and functions for // interfacing with the NORAPM.DLL NORAND Windows APM Driver. // Created: 01.25.94 // Updated: 07.07.94 // (C) Copyright 1994 by Norand Corporation //=================================================================== // Section: NORAPM Exported Structures //=================================================================== /* tagPOWER_STATUS structure ***************************************** This structure is used by GetPowerStatus function to relay the APM BIOS system power status. Structure fields are direct representations of registers returned by the APM Get Power Status call (see below): *********************************************************************/ struct tagPOWER_STATUS { BYTE BatteryStatus; // Battery status bits changed since last call // 00H High // 01H Low // 02H Critical // 03H Charging // FFH = Unknown // All other values reserved

B. Common PEN*KEY 6000 Series Info.

BYTE LineStatus; // AC line status bits // 00H Off-line // 01H On-line // 02H On backup power // FFH = Unknown // All other values reserved BYTE BatteryCharge; // % of battery left // 0–100 = Percentage of full charge // FFH = Unknown // All other values reserved BYTE BatteryFlags; // Current battery status. // bit 0 = 1 High // bit 1 = 1 Low // bit 2 = 1 Critical // bit 3 = 1 Charging // bit 7 = 1 No system battery // All other bits reserved // FFH = Unknown // All other values reserved WORD BatteryLife; // Battery time left // Bit 15 = 0 Time units are seconds // 1 Time units are minutes // Bits 14–0 = Number of seconds or minutes // 0–7FFFH = Valid number of seconds // 0–7FFEH = Valid number of minutes // FFFFH = Battery life Unknown }; //=================================================================== // Section: NORAPM Exported Function Prototypes and Pointer Defines //=================================================================== // This section declares a prototype for each function exported by NORAPM.DLL // as well as a typedef for a pointer to each function to facilitate runtime // dynamic linking. //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // extern “C” int FAR PASCAL _export GetPowerStatus(tagPOWER_STATUS far B-2

PEN*KEY R 6100 Computer Programmer’s Reference Guide

Page 283

APPENDIX B

Common PEN*KEY 6000 Series Information

// *PwrStat) // // Returns current power status from APM. See NorAPM.H for detailed docs. // Return value of PWR_OK for success, or PWR_FAIL if error (no APM, etc). //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– extern “C” int FAR PASCAL _export GetPowerStatus(tagPOWER_STATUS far *PwrStat); typedef int (FAR PASCAL *fpGetPowerStatus) (tagPOWER_STATUS far *PwrStat); //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // extern “C” int FAR PASCAL _export GetPowerState(int Device) // // Returns APM BIOS power state for APM Device. If device does not exist, OFF // is returned. //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– extern “C” int FAR PASCAL _export GetPowerState(int Device); typedef int (FAR PASCAL *fpGetPowerState)(int Device);

//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // extern “C” void FAR PASCAL _export SystemActivity(int EventType) // // Call this function to indicate system or user activity and hold off standby // (backlight) and suspend timeouts. This function is generally called by a // device driver that controls background processing or communications // peripherals. // // EventType Parameter: // 0: Indicates “system” activity. This resets Suspend timeouts. // 1: Indicates “user” or input activity. This resets the Standby // (backlight), and Suspend timeouts. //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– extern “C” void FAR PASCAL _export SystemActivity(int EventType); typedef void (FAR PASCAL *fpSystemActivity)(int EventType);

APMCODES.H // APMCODES.H: Definitions of APM 1.1 event codes used by NORAPM.DLL for // interaction with BIOS, DOS, and Windows. // (C) Copyright 1994 by Norand Corporation // Indicate that this include file has been loaded #define APMCODES 1 //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // APM 1.1 BIOS event codes. These codes are broadcast to DOS TSRs by the // APM OS Driver. #define APM_STANDBYREQUEST 1 // System Standby Request Notification #define APM_SUSPENDREQUEST 2 // System Suspend Request Notification #define APM_SUSPENDRESUME 3 // Normal Resume System Notification #define APM_CRITICALRESUME 4 // Critical Resume System Notification #define APM_BATLOW 5 // Battery Low Notification #define APM_PWRCHANGE 6 // Power Status Change Notification #define APM_TIMEUPDATE 7 // Update Time Notification #define APM_CRITICALSUSPEND 8 // Critical System Suspend Notification #define APM_USERSTANDBY 9 // User System Standby Request Notif. PEN*KEY R 6100 Computer Programmer’s Reference Guide

B-3

B. Common PEN*KEY 6000 Series Info.

//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // extern “C” int FAR PASCAL _export SetPowerState(unsigned int Device, // unsigned int State) // // Sets APM BIOS device “Device” to power state “State”. Returns PWR_FAIL for // failure (No APM, unsupported device or power state) or PWR_OK for success. //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– extern “C” int FAR PASCAL _export SetPowerState(unsigned int Device, unsigned int PowerState); typedef int (FAR PASCAL *fpSetPowerState)(int Device, int PowerState);

Page 284

Common PEN*KEY 6000 Series Information

APPENDIX B

#define APM_USERSUSPEND 10 // User System Suspend Request Notif. #define APM_USERSTANDBYRESUME 11 // User System Standby Resume Notif. //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // NORAND APM 1.1 BIOS OEM event codes that are broadcast to DOS. #define APM_OEM_XKBD 0x0201 // External keyboard detect #define APM_OEM_CHARGE 0x0202 // External charge detect #define APM_OEM_POD1 0x0203 // Pod 1 ring detect #define APM_OEM_POD2 0x0204 // Pod 2 ring detect #define APM_OEM_EXTRING 0x0205 // External ring detect #define APM_OEM_PCMCIA 0x0206 // PCMCIA ring detect #define APM_OEM_ALARM 0x0207 // Real time clock alarm #define APM_OEM_PENDOWN 0x0208 // Pen down detect #define APM_OEM_SUSPEND 0x0209 // Suspend detect #define APM_OEM_RESUME 0x020a // Resume key detect #define APM_OEM_BUBLOW 0x020b // Backup battery low #define APM_OEM_MB0 0x020c // Main battery critical #define APM_OEM_MB10 0x020d // 10 minutes left on bat #define APM_OEM_MB20 0x020e // 20 minutes left on bat #define APM_OEM_MB30 0x020f // 30 minutes left on bat #define APM_OEM_PDOOR 0x0210 // PCMCIA door open detect #define APM_OEM_IKBD 0x0211 // Internal keyboard detect #define APM_OEM_PWRFAIL 0x0212 // Powerfail detect #define APM_OEM_PWRTICK 0x0213 // Charge tick event #define APM_OEM_EL 0x0214 // Backlight on/off press #define APM_OEM_BATT_CHANGE 0x0215 // Battery change detected #define APM_OEM_PWRFAILNEW 0x0216 // Powerfail detect #define APM_OEM_PWRMSGTXT 0x0280 // Power msg text broadcast.

B. Common PEN*KEY 6000 Series Info.

//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // Windows APM 1.1 event codes. These events are broadcast to the Windows // drivers and parent-windows by the Windows APM driver. Note that these codes // are one less than the corresponding BIOS codes. Also, only 3 codes 1...3, // are actually defined in the current Windows 3.1Windows.H header file #define PWR_STANDBYREQUEST 0 // System Standby Request Notification #define PWR_SUSPENDREQUEST 1 // System Suspend Request Notification #define PWR_SUSPENDRESUME 2 // Normal Resume System Notification #define PWR_CRITICALRESUME 3 // Critical Resume System Notification #define PWR_BATLOW 4 // Battery Low Notification #define PWR_PWRCHANGE 5 // Power Status Change Notification #define PWR_TIMEUPDATE 6 // Update Time Notification #define PWR_CRITICALSUSPEND 7 // Critical System Suspend Notification #define PWR_USERSTANDBY 8 // User System Standby Request Notification #define PWR_USERSUSPEND 9 // User System Suspend Request Notification #define PWR_USERSTANDBYRESUME 10// User System Standby Resume Notification //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // NORAND Windows APM 1.1 OEM event codes. Again, these are one less than // their DOS/BIOS counterparts. #define PWR_OEM_XKBD 0x0200 // External keyboard detected #define PWR_OEM_CHARGE 0x0201 // External charge detected #define PWR_OEM_POD1 0x0202 // Pod 1 ring detected #define PWR_OEM_POD2 0x0203 // Pod 2 ring detected #define PWR_OEM_EXTRING 0x0204 // External ring detected #define PWR_OEM_PCMCIA 0x0205 // PCMCIA ring detected #define PWR_OEM_ALARM 0x0206 // Real time clock alarm #define PWR_OEM_PENDOWN 0x0207 // Pen down detected #define PWR_OEM_SUSPEND 0x0208 // Suspend detected #define PWR_OEM_RESUME 0x0209 // Resume key detected #define PWR_OEM_BUBLOW 0x020a // Backup battery low #define PWR_OEM_MB0 0x020b // Main battery critical #define PWR_OEM_MB10 0x020c // 10 minutes left on battery #define PWR_OEM_MB20 0x020d // 20 minutes left on battery #define PWR_OEM_MB30 0x020e // 30 minutes left on battery #define PWR_OEM_PDOOR 0x020f // PCMCIA door open detected #define PWR_OEM_IKBD 0x0210 // Internal keyboard detected #define PWR_OEM_PWRFAIL 0x0211 // Powerfail detected #define PWR_OEM_PWRTICK 0x0212 // Charge tick event B-4

PEN*KEY R 6100 Computer Programmer’s Reference Guide

Page 285

APPENDIX B

Common PEN*KEY 6000 Series Information

#define PWR_OEM_EL #define PWR_OEM_BATT_CHANGE #define PWR_OEM_PWRFAILNEW #define PWR_OEM_PWRMSGTXT

0x0213 // Backlight on/off press 0x0214 // Battery change detected 0x0215 // Powerfail detected 0x027F // Power message text broadcast.

//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // APM BIOS standard device IDs #define APM_BIOS 0x0000 // APM BIOS itself #define APM_SYSTEM 0x0001 // All BIOS-managed devices #define APM_DISPLAY 0x0100 // Display controller (VGA, etc.) #define APM_PCMCIA 0x0200 // PCMCIA slot controller #define APM_PARALLEL_PORTS 0x0300 // Printer ports #define APM_SERIAL_PORTS 0x0400 // UARTs #define APM_LAN_ADAPTER 0x0500 // Ethernet controller #define APM_SLOTS 0x0600 // Cards in PCMCIA slots

B. Common PEN*KEY 6000 Series Info.

//––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // APM BIOS OEM Norand device IDs #define APM_OEM_DEVICES 0xE000 // Remainder are OEM unique #define APM_OEM_PODS 0xE000 // Two pod devices possible #define APM_OEM_DIG_PADS 0xE100 // Digitizer interface control #define APM_OEM_BACKLIGHT 0xE200 // Backlight control #define APM_OEM_HEATER 0xE300 // 4600 display heater control #define APM_OEM_SWV5 0xE400 // Wwitch 5 control for 4600 //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // APM power states #define APM_READY 0 // “ON” #define APM_STANDBY 1 // Still operational, but in low power state. #define APM_SUSPEND 2 // Not operational, but saves HW state #define APM_OFF 3 // Not operational and does not save HW state. //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // APM Event Return Codes for DOS. // The Windows versions of these codes (PWR_FAIL, PWR_OK) are in WINDOWS.H. #define APM_OK 0 // Continue operation #define APM_FAIL 0x80 // Cancel operation

Sample Program Listings

Charge Detection Demo Program: TESTCHRG.CPP TESTCHRG is a C++ Windows program that demonstrates a method for accessĆ ing NORAPM.DLL to get the current charge status (tells you whether you are in the dock or not). The program needs to include NORAPM.H. The sample proĆ gram TESTCHRG.CPP is presented in the following pages. // TESTCHRG.CPP: NorAPM charge detection test fixture v1.01. // (C) Copyright 1994 by Norand Corporation // ************************************************************** /* TESTCHRG.DEF NAME TESTCHRG DESCRIPTION ‘Tests NorAPM Charge Detection’ EXETYPE WINDOWS STUB ‘WINSTUB.EXE’ CODE PRELOAD MOVEABLE DISCARDABLE DATA PRELOAD MOVEABLE MULTIPLE HEAPSIZE 1024 STACKSIZE 8200 */ #include <windows.h> #include “norapm.h” char szTitle[] = “TESTCHRG.EXE – 94.07.07.01”; HINSTANCE hinstNorAPM; // For storing NorAPM library instance. PEN*KEY R 6100 Computer Programmer’s Reference Guide

B-5

Page 286

Common PEN*KEY 6000 Series Information

APPENDIX B tagPOWER_STATUS PwrStat; WORD Error;

// Holds current power status. // Holds error codes.

char MsgBuf[100];

// Message buffer

#pragma argsused int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Turn off the “File not found” error box. SetErrorMode(SEM_NOOPENFILEERRORBOX); // Get handle to NORAPM.DLL driver hinstNorAPM = LoadLibrary(”NORAPM.DLL”); // Did we find the library? if (hinstNorAPM > HINSTANCE_ERROR) { // Get Entry point for GetPowerStatus() fpGetPowerStatus lpfnGetPowerStatus = (fpGetPowerStatus) GetProcAddress(hinstNorAPM, ”GetPowerStatus”);

B. Common PEN*KEY 6000 Series Info.

if (lpfnGetPowerStatus) { // Get and display charge state do { Error = lpfnGetPowerStatus(&PwrStat); if (Error != PWR_OK) { wsprintf(MsgBuf, “GetPowerStatus() call failed with result of %d”, Error); Error = MessageBox(NULL, MsgBuf, szTitle, MB_RETRYCANCEL + MB_ICONEXCLAMATION); } // then else { // Display battery status wsprintf(MsgBuf, “A/C is %s line.\nBattery is %scharging\n”, (char far *) (PwrStat.LineStatus == 1 ? “on” : “off”), (char far *) (PwrStat.BatteryFlags & 8 ? “” : “NOT ”)); Error = MessageBox(NULL, MsgBuf, szTitle, MB_RETRYCANCEL + MB_ICONINFORMATION); } // else } while (Error == IDRETRY); } // then else MessageBox (NULL, “Could not get entry point for GetPowerState()!”, szTitle, MB_OK | MB_ICONEXCLAMATION); // Free NorAPM instance. It stays around since it was already open. FreeLibrary(hinstNorAPM); } // then else MessageBox(NULL, “Could not open NORAPM.DLL!”, szTitle, MB_OK | MB_ICONEXCLAMATION); // Exit application return (0); } // WinMain

Critical Error Handler: CRITICAL.C CRITICAL.C is a C++ program that demonstrates a method for handling critical errors. This sample program was designed for a previous PEN*KEY 6000 Series product and may need altering for the 6100 Computer. #include “stdio.h” #include “compat.h” #include “4800.h” extern uchar jamarray[4][1024]; B-6

PEN*KEY R 6100 Computer Programmer’s Reference Guide

Page 287

APPENDIX B

Common PEN*KEY 6000 Series Information extern extern extern extern int jamindex; FILE *stdprn; unsigned page_no; unsigned line_cnt;

B. Common PEN*KEY 6000 Series Info.

/******************************************************************/ /* Critical error handler routines for the printer follow. ********/ /******************************************************************/ struct reqpk { unsigned char reqlen, unit, cmd; unsigned status; long rsrv1, rsrv2; unsigned char lookahead; FP(unsigned char) buff; unsigned int bytes; }; struct devhdr{ FP(struct devhdr) next; unsigned attribute; void (*strategy)(); void (*interrupt)(); uchar name[8]; }; struct faddr{ void *offset; void *segment; }; union fncptr { FAR (void) (*fnc)(); struct faddr addr; FP(struct devhdr) fncx; }; void set24h(fnc) FP(void) fnc; { #asm xor ax,ax mov es,ax mov bx,24h*4 mov ax,[bp+4] mov dx,[bp+6] cli mov es:[bx],ax mov es:[bx+2],dx sti #endasm } drivercall(fncptr,pak) FP(void) pak; FAR (void) (*fncptr)(); { #asm les bx,8[bp] call dword ptr 4[bp] #endasm } baderr(error,devtype,hdr) unsigned error,devtype; FP(struct devhdr) hdr; { union fncptr strat; union fncptr inter; struct ioargs args; struct reqpk devpack; uchar buffer[40]; uchar cmd,exterr; PEN*KEY R 6100 Computer Programmer’s Reference Guide

B-7

Page 288

Common PEN*KEY 6000 Series Information

APPENDIX B uchar ch; uchar jam; uchar jam2,jam3,jam4; cmd = pXERROR; args.ioctl_cmd = &cmd; args.ioctl_buf = buffer; devpack.reqlen = sizeof devpack; /* Length of ioctl packet */ devpack.cmd = 3; /* ioctl input read */ devpack.buff = (FP(uchar)) &args; /* Point buffer to ioargsc */ devpack.bytes = 7; /* Read one byte */ inter.fncx = strat.fncx = hdr; inter.addr.offset = hdr–>interrupt; strat.addr.offset = hdr–>strategy; drivercall(strat.fnc,(FP(struct reqpk)) &devpack); drivercall(inter.fnc,(FP(struct reqpk)) &devpack); exterr = args.ioctl_buf[0]; if (exterr == HEADJAM) { jam = args.ioctl_buf[3]; jam2 = args.ioctl_buf[4]; jam3 = args.ioctl_buf[5]; jam4 = args.ioctl_buf[6]; } scr_printf (“\nprinter error\n %d\n”,exterr);

B. Common PEN*KEY 6000 Series Info.

switch (exterr) { case PNRDY: scr_printf(“Printer not ready. Check connection. Retry.\n”); break; case RXTMO: scr_printf(“Printer not transmitting. Check connection.Retry.\n”); break; case TXTMO: scr_printf(“Printer not receiving. Check connection. Retry. \n”); break; case BADADR: scr_printf(“MAC address error. Abort. \n”); break; case GAPERR: scr_printf(“MAC intercharacter Gap error. Retry.\n”); break; case LSRPE: scr_printf(“MAC length parity error. Retry.\n”); break; case IFTS: scr_printf(“Invalid communication Frame. Abort.\n”); break; case NS_NE_VR: scr_printf(“NS <> VR. Abort. \n”); break; case NR_NE_VS: scr_printf(“NR <> VS. Abort. \n”); break; case MAC_CRCERR: scr_printf(“CRC error. Retry. \n”); break; case RLENERR: scr_printf(“Receive length error. Abort.\n”); break; case FRMERR: scr_printf(“Frame reject. Abort. \n”); break; case NDMERR: scr_printf(“Printer Disconnect. Abort.\n”); break; case BINDERR: B-8

PEN*KEY R 6100 Computer Programmer’s Reference Guide