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

2D JANUS PSK for C/C++ Reference Manual, pages 361 to 370

Pages 361 to 370 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 361

contrast.cpp

B contrast.cpp /* contrast.cpp * * This program demonstrates contrast control using interrupts. It increases the * contrast by one step each time the space bar is pressed. It accepts a parameter * in the range of 0 - 31 from the command line and sets the contrast to that level. * * Written: Aug. 24, 1993 * Last Modified: Aug. 24, 1993 * Author: Ray Rogers * Compiler: Borland C++ 3.1 */ #include #include #include #include #include #include

"stdio.h" "string.h" "dos.h" "conio.h" "stdlib.h" "im20lib.h"

// Defines #define FOREVER 1 #define LCD_Int 0x79 #define LCD_CONTRAST 0 #define ESC 0x1b #define ZERO '0' #define PERIOD '.'

// LCD interrupt // contrast function

// Prototypes IM_UCHAR Step_Contrast(IM_UCHAR); IM_UCHAR Set_Contrast(IM_UCHAR); IM_UCHA Get_Contrast(void); void main(int argc, char *argv[]) { IM_UCHAR ch, level; if(argc == 1) { clrscr(); // no command line parameters printf("%s", "\n\rPress 0 to decrease\n\rperiod to increase\n\rESC to quit"); } else { Set_Contrast(atoi(argv[1])); exit(0); } // main processing loop, exit loop on ESC key while(FOREVER) { if(kbhit()) { ch = getch(); switch(ch) { case ESC: clrscr(); exit(0);

B-11

Page 362

contrast.cpp case case

}

ZERO: Step_Contrast(--(level = Get_Contrast())); break; PERIOD: Step_Contrast(++(level = Get_Contrast())); break;

}; } // end main loop

} // Get the current contrast level IM_UCHAR Get_Contrast() { _AH = LCD_CONTRAST; _AL = 3;

// current contrast geninterrupt(LCD_Int); return(_AL); } // Step the contrast one level by call with 0 parameter or set by // supplying a value IM_UCHAR Step_Contrast(IM_UCHAR step) { static IM_UCHAR once, level; if(!once) { once = 1; level = Get_Contrast(); } if(step != 0) level = step; if(level >= 31) level = 0;

// allow Get_Contrast() only once

// use step value if provided // keep level within bounds (not below zero // unsigned)

if(step == 0) level++; return(Set_Contrast(level)); } // Set the contrast to the requested level IM_UCHAR Set_Contrast(IM_UCHAR level) { _AH = LCD_CONTRAST; _AL = 1; // set contrast to value function _BL = level; geninterrupt(LCD_Int); return(_AL); }

B-12

Page 363

ctlkey.cpp

B ctlkey.cpp /* ctlkey.cpp * * This program demonstrates Ctrl key control by using interrupts to enable/disable * the Ctrl key. * * Written: Sept. 1, 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_CTL 0x08 KP_OFF 0x00 KP_ON 0x01 KP_STATUS 0x02 KP_ENABLED 0xff VALID_SERVICE 0x00 TRANS_OK 0x00

// key pad interrupt // keypad ctl key function // function is off // function is on // get status // function is enabled // valid function call // func transaction executed ok typedef struct { IM_UCHAR status; IM_UCHAR kp_status; IM_UINT padding; } RESP_BUFF;

// KSCPU comm status // 0xff if function already enabled // work space

RESP_BUFF rbuff;

// Prototypes IM_UINT KP_Func(IM_UCHAR, IM_UCHAR, RESP_BUFF *); void main() { clrscr(); if(VALID_SERVICE == KP_Func(KP_CTL, 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_CTL, KP_OFF, &rbuff); // turn it off printf("%s", "\n\rControl Key DISABLED\n\r\n\rPress a key..."); } else { KP_Func(KP_CTL, KP_ON, &rbuff); // else, turn it on printf("%s", "\n\rControl key ENABLED\n\r\n\rPress a key..."); } while(!kbhit()); getch(); clrscr(); exit(0);

// wait for a keypress

}

B-13

Page 364

ctlkey.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; geninterrupt(KEYPAD_Int); return(_AH); }

B-14

// keypad function // subfunction

Page 365

exstat.cpp

B exstat.cpp /* exstat.cpp * * This program demonstrates JANUS extended protocol status reporting using interrupts. * This program also demonstrates program control of the JANUS viewport using interrupts. * * NOTE: For units with Radio Frequency (RF), this program is known to function properly * only with Version 1.24 firmware. * Written: July 25, 1994 * * Last Modified: July 25, 1994 * Author: Ray Rogers * Compiler: Borland C++ 3.1 */ #include #include #include #include #include #include

"stdio.h" "string.h" "dos.h" "conio.h" "stdlib.h" "im20lib.h"

// Defines #define COM_Int 0x14 #define LCD_Int 0x79 #define ESC 0x1b #define SPACE ' ' #define ZERO '0' #define TRUE 1 #define FOREVER TRUE #define VP_ACROSS 5 #define VP_DOWN 4 #define VP_STEPSIZE 15 #define OK 0x600 #define ERR_NO_HANDLER 0x8611 #define ERR_BAD_VER 0x860e // Global Variables IM_UINT vm_mode; IM_UINT vm_params; IM_UINT vp = 0; IM_UINT vp_vert = 1; IM_COMM_STATUS_BUFFER_s sb0, sb3;

// Communications interrupt // LCD size mode manager interrupt // char 27, Escape // blank space // zero == set viewport to origin 0,0 // number of viewport steps across // number of viewport steps down // columns to move viewport right // ok status // no protocol handler loaded // old firmware - requires 1.24 or later // saves original video mode // saves original video parameters // viewport position // viewport vertical control // define buffers to hold status

// Prototypes IM_UINT Set_Video_Mode(void); IM_UINT Get_Ext_Status(IM_UINT, IM_COMM_STATUS_BUFFER_s *); IM_UINT VP_Move(IM_UINT, IM_UINT); void Display_Status(IM_UINT, IM_COMM_STATUS_BUFFER_s *, IM_UINT); void Move_Viewport(void); void err_msg(IM_UINT); void main() { IM_UCHAR ch; IM_UINT status0, status3; Set_Video_Mode(); sb0.status_structure_version = STATUS_STRUCT_VERSION;

B-15

Page 366

exstat.cpp sb3.status_structure_version = STATUS_STRUCT_VERSION; status0 = Get_Ext_Status(0, &sb0); // status for port 0 status3 = Get_Ext_Status(3, &sb3); // status for port 3 clrscr(); VP_Move(0, 0); printf("%s", "\n\rPress the space bar to\n\r"); printf("%s", "move the viewport \n\ror ESC to quit"); ch = 0x00; while(ch != SPACE && ch != ESC) if(kbhit()) ch = getch(); clrscr(); VP_Move(0, 0); Display_Status(0, &sb0, status0); printf("%s", "\r\n\n"); Display_Status(3, &sb3, status3); VP_Move(0, 0); // Loop for moving the viewport to display the data while(FOREVER) { ch = getch(); if(ch == SPACE) Move_Viewport(); if(ch == ZERO) VP_Move(0, 0);

// just handy to have if(ch == ESC) break; } clrscr(); VP_Move(0, 0); } // Display a status buffer on the 80x25 screen void Display_Status(IM_UINT port, IM_COMM_STATUS_BUFFER_s *sb, IM_UINT status) { static IM_UCHAR *prot[] = { "User Defined", "Pt to Pt", "Polling Mode D", "Multi Drop", "Reserved1", "XModem", "Reserved2", "Dos Protocol", "Reserved3", "None", "No RF Protocol", "RF Protocol"

B-16

Page 367

exstat.cpp

B

}; if(sb->handler_type != IM_RF_BACK_PH && status == OK) // if not the rf handler { printf("Port: %1d Protocol Handler Ver. %s\n\r", port, sb->handler_ver); printf("Baud= %6lu Parity= %1X Stop Bits= %1X Data Bits= %1X\n\r", sb->specific.serial.baud_rate, sb->specific.serial.parity, sb->specific.serial.stop_bits, sb->specific.serial.data_bits); printf("Modem Status= %2X Port Status= %2X Active Protocol= %s\n\r", sb->specific.serial.modem_status, sb->specific.serial.port_status, prot[sb->specific.serial.active_prot]); printf("LRC= %s Interchar Delay= %2X Turnaround Delay= %d\n\r", sb->specific.serial.lrc_enabled == 0 ? "No " : "Yes", sb->specific.serial.interchar_delay, sb->specific.serial.turnaround_delay); printf("POL char = %3X SEL char = %2X RES char = %2X\n\r", sb->specific.serial.pol_char, sb->specific.serial.sel_char, sb->specific.serial.res_char); printf("REQ char = %3X AFF char = %2X NEG char = %2X SOM char= %2X\n\r", sb->specific.serial.req_char, sb->specific.serial.aff_char, sb->specific.serial.neg_char, sb->specific.serial.som_char); printf("TXEOM len = %3X TXEOM char1 = %2X TXEOM char2= %2X\n\r", sb->specific.serial.txeom_len, sb->specific.serial.txeom_char_1, sb->specific.serial.txeom_char_2); printf("RXEOM len = %3X RXEOM char1 = %2X RXEOM char2= %2X\n\r", sb->specific.serial.rxeom_len, sb->specific.serial.rxeom_char_1, sb->specific.serial.rxeom_char_2); printf("Flow Cntrl= %3X MultiDrop Addr= %2X MultiDrop Enabled= %s\n\r", sb->specific.serial.flow_ctrl, sb->specific.serial.multi_drop_addr, sb->specific.serial.multi_drop_enabled == 0 ? "No " : "Yes"); printf("EOF length= %3d EOF char = %2X\n\r", sb->specific.serial.eof_length, sb->specific.serial.eof_char); printf("Recv Buff Avail= %s Xmit Buff Avail=%s Protocol Mode= %s", sb->specific.serial.have_recv_client_buffer == 0 ? "No " : "Yes", sb->specific.serial.have_xmit_client_buffer == 0 ? "No " : "Yes", sb->specific.serial.protocol_mode == 0 ? "Use Protocol" : "No Protocol "); } else if(sb->handler_type != IM_RF_BACK_PH && status != OK) err_msg(status); if(sb->handler_type == IM_RF_BACK_PH && status == OK) // it is the rf handler { printf("\n\rPort: %1d Protocol Handler Ver. %s\n\r", port, sb->handler_ver); printf("\n\rRF Back Ver= %1d.%1d", sb->specific.rf.RF_back_major_version, sb->specific.rf.RF_back_minor_version); printf("\n\rConnected= %s", sb->specific.rf.net_connect_status == 0 ? "No" : "Yes"); printf("\n\rProt Enabled= %s Address= %d", sb->specific.rf.RF_protocol_enabled == 0 ? "No" : "Yes", sb->specific.rf.RH_device_address); printf("\n\rHost Addr= %d Channel= %d Net ID= %d", sb->specific.rf.RT_host_address, sb->specific.rf.RV_channel_select, sb->specific.rf.RW_network_ID); } else if(sb->handler_type == IM_RF_BACK_PH && status != OK) err_msg(status); } // Get the protocol's extended status for the specified port IM_UINT Get_Ext_Status(IM_UINT port, IM_COMM_STATUS_BUFFER_s *sb)

B-17

Page 368

exstat.cpp

{ _ES = FP_SEG((IM_COMM_STATUS_BUFFER_s far *) sb); // pointer to buffer _BX = FP_OFF((IM_COMM_STATUS_BUFFER_s far *) sb); _CX = sizeof(IM_COMM_STATUS_BUFFER_s); // buffer length _DX = port; // port id _AH = 0x71; // extended status function geninterrupt(COM_Int); return(_AX); } // Move the viewport around when spacebar is pressed void Move_Viewport() { vp++; if(vp % VP_ACROSS) { VP_Move(vp_vert == 1 ? 0 : 12, vp * VP_STEPSIZE); } else { VP_Move(12 * vp_vert, 0); // up or down vp = 0; vp_vert = (vp_vert == 1 ? 0 : 1); } } // Set the video mode to 20x16 IM_UINT Set_Video_Mode() { _AH = 0x02; _AL = 0x03;

// right

// function 2 of int 79h // get current video mode geninterrupt(LCD_Int);

// LCD display size mode manager interrupt vm_mode = _AL; vm_params = _BX;

// save the current video mode // save original video parameters

_AH = 0x02; _AL = 0x00;

// function 2 of int 79h // set mode to 80x25 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 = vm_mode; // restore the original video mode geninterrupt(LCD_Int);

// LCD display size mode manager interrupt

} // Executes the viewport move interrupt IM_UINT VP_Move(IM_UINT row, IM_UINT col) { _AL = 0x01; _AH = 0x03;

B-18

// relative viewport move // viewport move function

Page 369

exstat.cpp

B

_BX = row; _CX = col; geninterrupt(LCD_Int); return(_AX); } // Display error messages void err_msg(IM_UINT status) { switch(status) { case ERR_NO_HANDLER: printf("\n\r%s\n\r", "ERROR- No protocol handler loaded!"); break; case ERR_BAD_VER: printf("\n\r%s\n\r", "ERROR- Incompatible revision level!"); break; } }

B-19

Page 370

fifo.cpp fifo.cpp /* fifo.cpp * * This program demonstrates the use of the UART restore interrupt and APM * interface protocol. This function is only necessary if your program is * communicating using the FIFO Control Register (FCR)in 16550 mode of the UART, * you are not using one of the INTERMEC protocol handlers, and power management * is active. Since the UART restore function depends on power management, this * program also demonstrates the use of the PM interface. * * This program doesn’t actually do any communications or set the 16550 * mode. Instead, it illustrates how to reset the FCR (a write only register) * after someone turns off the reader’s power. * * Pressing the 1/0 key on the Janus gives no warning to your program thru * power management. PM only notifies you upon power up and by then the * UART has been reset. * * Written: July 28, 1994 * Last Modified: Aug. 1, 1994 * Author: Ray Rogers * Compiler: Borland C++ Ver 3.1 Small Memory Model */ #include "dos.h" #include "stdio.h" #include "conio.h" #define #define #define #define #define #define #define #define #define

PM_Int TRUE FALSE NORMAL_RESUME CRITICAL_RESUME CARRY ESC UART_Int RESTORE

0x15 1 0 0x03 0x04 0x01 0x1b 0x78 0x06

// power mgmt interrupt

// carry flag mask // escape key // int used to control UART // restore function

// Function Prototypes void PM_Connect(void); void PM_Check(void); void PM_Disconnect(void); void Set_FIFO(void); void Store_UART(void); void Restore_UART(void); int PM_Event(void); unsigned char

FCR;

void main(void) { PM_Check(); PM_Connect(); Set_FIFO(); Store_UART();

B-20

// FIFO ctrl register value