The text of a manual · part 38 of 42
JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 371 to 380
Pages 371 to 380 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 371
exstat.cpp status0 = Get_Ext_Status(0, &sb0); status3 = Get_Ext_Status(3, &sb3);
B
// status for port 0 // 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-19
Page 372
exstat.cpp
B-20
Page 373
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) { _ES = FP_SEG((IM_COMM_STATUS_BUFFER_s far *) sb); // pointer to buffer
B-21
Page 374
exstat.cpp
_BX = FP_OFF((IM_COMM_STATUS_BUFFER_s far *) sb);
B-22
Page 375
exstat.cpp
B
_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; _BX = row; _CX = col;
// relative viewport move // viewport move function
B-23
Page 376
exstat.cpp 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-24
Page 377
fifo.cpp
B 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_Disconnect(void); void Set_FIFO(void); void Store_UART(void); void Restore_UART(void); int PM_Event(void); unsigned char
FCR;
// FIFO ctrl register value void main(void) { PM_Check(); PM_Connect(); Set_FIFO(); Store_UART();
B-25
Page 378
fifo.cpp while(TRUE) { if(PM_Event()) Restore_UART();
// 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-26
Page 379
fifo.cpp
B
}
B-27
Page 380
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-28