MR350MKII Data Collection Terminal Programming Reference Manual Unitech Electronics Co., Ltd. September 2001 V1.
Introduction This manual is a hand book for whom intend to develop an application program on MR350MKII and Host computer or MS-DOS based PC. It will introduce the I/O function calls, DOS Manager function calls, File Manager function calls and Host ESC commands. For your easy understanding, source code of the two sample programs are listed in appendix D and E. All the programs mentioned in this manual are contained in a 3.5” MS-DOS format demo diskette.
Table of Contents Table of Contents...................................................................................................................1-2 1. System Kernel............................................................................................................1-6 1.1. 1.2. 1.3. 1.4. Application Programming Interface.................................................................................. 1-6 Keypad Subsystem .......................................................................
03 Enable RS-232 port.................................................................................................. 3-27 04 Disable RS-232 port................................................................................................. 3-27 00 Set Communication parameters................................................................................ 3-27 05 Set RTS signal of RS-232 port .................................................................................
2B 2C 2D 3.9. 3C 3D 3E 3F 40 41 42 43 56 48 49 4A 4. Set System date........................................................................................................ 3-50 Get System clock ..................................................................................................... 3-50 Set System clock ...................................................................................................... 3-51 File Manager .......................................................................
4.5. ESC Commands Added for MV1100 Fingerprint Module .......................................... 4-72 4.5.1. Get Template List (ESC $D) ................................................................................ 4-72 4.5.2. Erase Template ( ESC $E) .................................................................................... 4-74 4.5.3. Enroll and Store Template on MR350 MKII ( ESC $F )......................................... 4-74 4.5.4. Enroll and Store Template on MV1100 ( ESC $G ) .........
Chapter 1. System Kernel 1. System Kernel This chapter is used to introduce the system kernel of MR350MKII. Where the system kernel is divided into six subsystems to service application programming interface, keyboard input, LCD display, communication I/O, Real Time Clock, Relay output/Digital input and Barcode wand/Magnetic stripe/Proximity reader. 1.1. Application Programming Interface The MR350MKII kernel includes three basic modules: device driver, file manager and DOS manager.
1.2. Keypad Subsystem The keypad subsystem scans the key matrix, converts the scan code to its associated key value, and stores the value in the input buffer of keyboard for program utilization. Note that the [SHIFT] key is not stored into the buffer, it is used to distinguish the alphabetic and numeric mode of associated key position and provide an alternative key code. The following table shows the key values of each key.
1.4. Communication Subsystem The MR350MKII terminal communication subsystem consists of 1) point-to-point connection mode and 2) multi-point connection mode for network processing. 1.4.1. Point to point mode Either RS-232 or RS-485 port can be used in point-to-point mode when it is set as serial port. Each port can be configured, input data and output data by DOS call.
1.7. Bar code / Magnetic stripe / Proximity / ICC The MR350MKII has two ports for connecting different reader Internal reader and External reader. External reader port is dedicated for bar code reading by a bar code wand, CCD, or laser diode scanners, and the terminal supports reading of Code 39, Code 128, Codabar, Interleaved 2 of 5, UPC and EAN. NOTE: The CCD and laser diode scanner are only supported while connected through internal reader port.
( Displays all of the files which are stored in the MR350MKII Program as well as data file) ? MS-Kermit>REMOTE DEL Deletes a program or data file in the MR350MKII. Step 7. Press [SHIFT] in conjunction with [F5/*] on MR350MKII to exit from Kermit server mode to Ready mode. Step 8. Select option “1) RUN” in user command menu and press [F7/? ] key to step through the available downloaded executable object program, then press [E] to confirm for choosing 350TEST.
6) Then, the screen will display: V2.1 COM2 Address: ESC=1 NAK=3 PARA=9600,1,8,NONE 0.Send 1.Poll A.Stop B.BarT C.ComT D.DIR E.Del F.ExeSize f.Font G.Memory H.Reset I.ExFile J.Exist K.Keypad k.Kermit L.Dnload M.Time N.Buzzer O.Auto P.Passwd Q.UplMode R.TrmID T.TrmT U.Upload V.DEV_T X.Exec 3.brk 5.ChgAdr 9.Loop @.Modem ?.320 ~.UPS off F1.Addr F2.Comm_P F3.Retry F4.Disp. F5.Shell F6.Pkt size : Select: Item 0). Send a string of characters as message to MR350MKII. 1).
N). Set beeper's volume. O). Set a executable object program to be started up automatically after power-up. Q). Inquire Uploading status (Not available on MR350MKII) R). Change terminal's ID. T). Set terminal control table. U). Upload a program or data file from MR350MKII. V). Set device control table. X). Remote run means that starting up an pre-downloaded executable object program on the terminal. 3). Set power saving (Not available on MR350MKII) 5). Set connected terminal address. 9).
10) Select item 1) to start getting data, PC screen will appear "… ." indicating there is no data collected. If any of those terminals starting input data by scanning bar code label, PC screen will show as below: A (nn): XXXXXX The first character mean terminal address. Where XXXXXX is the data scanned from all connected barcode input devices or magnetic striper reader and NN is its data length. 10) Select item 0). to send message to terminals.
Chapter 2. Data Structure 2. Data Structure MR350MKII system control data structures are outlined in the following diagram. The system kernel uses the File Allocation Table (FAT), File Handle Table (FHT), Communication Control Table, Device Control Table and Key Alias Table. The following sections will describe each one of these control tables. The description includes a "typedef" part and the "default" values of the table.
'M' 'D' lcd_backlight: 'N' 'F' = set LCD backlight ON = set LCD backlight OFF (default) buzzer: 'N' 'F' = set buzzer ON (default) = set buzzer OFF keylock: 'N' 'K' 'P' = set keyboard Unlock (default) = set keyboard Locked = set keyboard Partial Locked buzzer_volume: 2.3.
'F' 2.4. = Disable barcode decoding of Code 128 Communication Control Table of Host port The communication control table is applicable to configure the host port of the MR350MKII. The communication control table specifies all communication parameters between the host system and the MR350MKII. When a hard reset command is issued via keypad input or host command sequence the default communication parameters are restored.
protocol: address: 'O' 'E' = Odd parity = Even parity 'M' 'F' 'A' = Multipoint (default) = None protocol = terminal address ID for Multipoint mode (default) Each MR350MKII has to be assigned a unique communication address when it is used in a Multipoint environment. The address is used by a host or concentrator to perform polling functions. Characters 'A'-'Y' and '0'-'6' are used for assigning an address ID of each terminal. timeout: '02' = polling timeout two cycle periods (default).
BYTE pageterm;/* page terminator */ } TERM_CONFIG; Each MR350MKII "terminal" is identified by an ASCII string. There can be up to seven characters of a terminal identification. The identification entry in the TERM_CONFIG table has one more character space to allow ASCII_Z (hex 0) termination, as in C language convention.
lineterm: designates the termination character of line block mode (default = null) pageterm: designates the termination character of page block mode (default = null) 2-19
Chapter 3. I/O Function Calls 3. I/O Function Calls The operating system of the MR350MKII supports BIOS/DOS Function to control LCD display, Keyboard input, Proximity/Barcode/Magnetic stripe input, Buzzer, Security alarm, Photo-coupler input, Relay output, and serial port input/output of RS232 and RS485. The whole C sample program are gathered into library file "350LIB.C" on Utility Diskette. 3.1.
void TL_gotoxy(int x,int y) { regs.h.ah = 2; regs.h.dh = (unsigned char)y; regs.h.dl = (unsigned char)x; int86(0x10,®s,®s); } 03 Get cursor position Entry Parameters: Returned Values: AH = 3 DH = 0 ~ 1 DL = 0 ~ 15 ;row ;column void TL_getxy(int *x,int *y) { regs.h.ah = 3; int86(0x10,®s,®s); *y = regs.h.dh; *x = regs.h.dl; } 04 Scroll screen Entry Parameters: AH = 4 AL = 0 =1 void TL_scroll(int status) { regs.h.ah = 4; regs.h.
int86(0x21,®s,®s); } 3.2. Communication Environment Setup Before placing MR350MKII into the communication environment, you have to decide: 1) Whether the RS-422/485 port or RS-232 port assigned as host port and another one as serial port. 2) Set communication protocol for host port. Please note, the protocol for serial port is always none. 3) If you have installed a internal modem interface. You have to set COM1 as modem instead of RS485.
void TC_select_host(int status) { regs.h.ah = 0x1C; regs.h.al = (unsigned char)status; regs.h.bh = 0; int86(0x21,®s,®s); } 1C Set host port protocol Entry Parameters: AH = 1C BH = 1 AL = 2 3 Returned Valued: None void TC_protocol(int status) { regs.h.ah = 0x1C; regs.h.al = (unsigned char)status; regs.h.bh = 1; int86(0x21,®s,®s); } 1C ; Multi-point (default) ; None protocol Set serial port flow control The system provides three handshaking mode for serial port: XON/XOFF, CTR/RTS and none.
} 19 Set COM1 port as RS485 or modem This function call is used to set COM1 port as RS485 serial port or modem when you have the internal modem interface installed. Before you can start to use modem for communication, you must set COM1 port as modem. Entry Parameters: Returned Value: AH = 19 AL = 0 1 None ; set as RS485 ; set as modem void TC_modem_port(int status) { regs.h.ah= 0x19; regs.h.al= status; int86(0x21,®s,®s); } 3.3.
{ regs.h.ah= 0x1C; regs.h.al= status; regs.h.bh= 9; int86(0x21,®s,®s); } 5F Read host port Entry Parameters: Returned Values: AH = 0x5F DS:DX = buffer pointer AL = 0 ;output succeed 1 ;no data int TC_str_I(unsigned char *str,int wait) { do { regs.h.ah=0x5F; segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); int86x(0x21,®s,®s,&segregs); } while (wait && regs.h.al); return(regs.h.
Returned Values: AL = 0 1 ;port is available ;port is busy int TC_ready(int wait) { int i; do { regs.h.ah=0x61; int86(0x21,®s,®s); } while (wait && regs.h.al); return(regs.h.al); } 3.4. Serial I/O for RS-232 and RS-485 The system allow to the RS-232 and RS-485 to serve serial input/output (character mode I/O) no matter the port is assigned as host or serial port. However, if the port is assigned as host, must select “NONE” as its active protocol.
02 Output data Entry Parameters: Returned Values: AH = 2 AL = Data character None void TC_232_char_O(unsigned char ch) { regs.h.ah = 2; regs.h.al = ch; int86(0x34,®s,®s); } 03 Enable RS-232 port Entry Parameters: Returned Values: AH = 3 None void TC_232_enable() { regs.h.ah = 3; int86(0x34,®s,®s); } 04 Disable RS-232 port Entry Parameters: Returned Values: AH = 4 None void TC_232_disable() { regs.h.
0001xxxx 150 baud rate 0010xxxx 300 baud rate 0011xxxx 600 baud rate 0100xxxx 1200 baud rate 0101xxxx 2400 baud rate 0110xxxx 4800 baud rate 0111xxxx 9600 baud rate 1000xxxx 19200 baud rate 1001xxxx 38400 baud rate Return Values: None void TC_232_parameter(long baud,int parity,int stop,int data) { unsigned char cc=0; unsigned int i_baud; i_baud = (int)(baud / 10L); switch (i_baud) { case 11 : cc=0x00; break; case 15 : cc=0x10; break; case 30 : cc=0x20; break; case 60 : cc=0x30; break; case 120 : cc=0x40;
} regs.h.ah = 0; regs.h.al = cc; int86(0x34,®s,®s); } 05 Set RTS signal of RS-232 port Entry Parameters: Returned Values: AH = 5 AL = 2 DH = 0 1 None ;set RTS to LOW ;set RTS to HIGH (default) void TC_232_RTS(int rts) { regs.h.ah = 5; regs.h.al = 2; regs.h.dh = (unsigned char)rts; int86(0x34,®s,®s); } 06 Read CTS signal of RS-232 port Entry Parameters: Returned Values: AH = 6 AL = 2 DH = 0 1 ;when CTS is LOW ;when CTS is HIGH int TC_232_CTS() { regs.h.ah = 6; regs.h.
AH = 0 AL = Data character 2) if no character received AH = 1 AL = undefined unsigned char TC_485_char_I() { regs.h.ah = 1; int86(0x33,®s,®s); if (regs.h.ah == 0) return(regs.h.al); return(255); } 02 Output data Entry Parameters: Returned Values: AH = 2 AL = Data character None void TC_485_char_O(unsigned char ch) { regs.h.ah = 2; regs.h.al = ch; int86(0x33,®s,®s); } 03 Enable RS-485 port for serial I/O Entry Parameters: Returned Values: AH = 3 None void TC_485_enable() { regs.h.
int86(0x33,®s,®s); } 00 Set Communication parameters Entry Parameters: AH = 0 AL = bit 0 bit 1 bit 2-3 bit 4-7 Return Values: BIT # 76543210 xxxxxxx0 7 data bits xxxxxxx1 8 data bits xxxxxx0x 1 stop bit xxxxxx1x 2 stop bits xxxx00xx NONE parity xxxx01xx ODD parity xxxx11xx EVEN parity 0000xxxx 110 baud rate 0001xxxx 150 baud rate 0010xxxx 300 baud rate 0011xxxx 600 baud rate 0100xxxx 1200 baud rate 0101xxxx 2400 baud rate 0110xxxx 4800 baud rate 0111xxxx 9600 baud rate 1000xxxx 19200 baud rate 10
default: cc=0x70; break; } switch (parity) { case 0 : break; case 1 : cc=cc|0x04; break; case 2 : cc=cc|0x0c; break; case 3 : cc=cc|0x08; break; } switch (stop) { case 1 : break; case 2 : cc=cc|0x02; break; } switch (data) { case 7 : break; case 8 : cc=cc|0x01; break; } TD_int_dos1(0x1C,cc,1,0); regs.h.ah = 0; regs.h.al = cc; int86(0x33,®s,®s); } 05 Open RS-485 multi-bus to send out data The RS-485 is a multi-bus architecture that means more than one RS-485 I/O port can access the trunk line.
06 Close RS-485 multi-bus (release RS-485 bus) Entry Parameters: Returned Values: AH = 6 None void TC_485_close() { regs.h.ah = 6; int86(0x33,®s,®s); } NOTE: 1) While the RS-485 post is used for serial input/output (character I/O) communication. The application must enable RS-485 first to set communication characteristic and make the system ready for serial I/O and then open its RS-485 to occupy the bus prior to reading or writing data.
3.5. Relay Output / Digit Input / Buzzer / LED Indicator Set LED indicator ON/OFF INT 09H Entry Parameters: AH = 2 Bit# 76543210 AL= 0000xxxx, where: x: 1, Set LED on 0, Set LED off Bit0: LED1 Bit1: LED2 Bit2: LED3 Bit3: LED4 Returned Value: None Ex. AL = 00000011 means to turn on LED1 and LED2. void TD_LED(int led1,int led2,int led3,int led4) { regs.h.ah = 2; regs.h.al = 0; if (led1 > 0) regs.h.al = regs.h.al | 1; if (led2 > 0) regs.h.al = regs.h.al | 2; if (led3 > 0) regs.h.al = regs.h.
regs.h.ah = (unsigned char)port; regs.h.al = (unsigned char)type; int86(0x08,®s,®s); return((int)regs.h.al); } Activate/Deactivate Relay ports INT 09H Entry Parameters: AH = 0 1 AL = 0 1 Returned Values: ;select Relay #1 ;select Relay #2 ;deactivate selected Relay contact OPEN ;activate selected Relay contact CLOSE None void TD_relay(int port,int s tatus) { regs.h.ah= (unsigned char)port ; regs.h.al= (unsigned char)status; int86( 0x09 ,®s,®s); return(regs.h.
1A Set buzzer volume INT 21H Entry Parameters: AH = 0x1A BH = 3 AL = 0 1 2 None Returned Values: ;set LOW volume ;set MEDIUM volume ;set HIGH volume void TD_beeper_vol(int status) { regs.h.ah= 0x1A ; regs.h.al= (unsigned char)status; regs.h.bh= 3; int86(0x21,®s,®s); return(regs.h. al); } 1B Get Security state INT 21H Entry Parameters: AH = 0x1B BH = 7 Returned Values: AL = 0 ;close 1 ;open int TD_security_status() { regs.h.ah = 0x1B; regs.h.bh = 7; int86(0x21,®s,®s); return((int)regs.
regs.h.bh = 8; int86(0x21,®s,® s); } 54 Buzzer volume control with user-defined frequency and time 21H Entry Parameters: Returned Values: AH = 0x54 CX = 1-3000 ;frequency in Hz DX = 1-1600 ;sound duration in mini-second None void TD_beep_user(int fz,int tm) { regs.h.ah 0x=54; regs.x.cx = fz; regs.x.
3.6. Internal/ External reader Port: INT 21H There are two readers can be connected to MR350 MKII --- Internal Reader and External Reader. Internal reader is a build-in reader, it is installed inside of MR350 MKII. External reader can be connected to either scanner port or terminal block. For internal reader, if it cannected with Magnetic stripe reader or Bar code slot reader, the system can automatically set up the Internal reader type by detecting the first time swiped card type.
50 Read data from external reader(only available for Barcode and Magnetic reader) Entry Parameters: Returned Values: AH = 0x50 DS:DX = buffer pointer AX = 0 ;data input 1 ;no data input Scanning direction CL = 0 ;from right to left 1 ;from left to right int TD_g et_external(unsigned char *str,int wai,itnt *direction ) { int i; do { segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); regs.h.ah= 0x50 ; int86x(0x21,®s,®s,&segregs); *direction = regs.h.cl; } while (wait && regs.h.al); return(regs.h.
0x13 : EAN-13 0x14 : EAN-8 CH = 1 :Magnetic data CL = 0 ;from right to left 2 ;from left to right BL = 0x01 : Track 1 0x02 : Track 2/3 'K' : ARK501 keypad input CH = 2 : Wiegand data CL = 0 : formatted data 1 : unformatted data BL = data length in bit int TD_get_ internal(unsigned char *str,int *direct_format,int *dev _type,int *data_type,int wait) { int i; do { i = TD_intdos_I(0x52,0,str); *direct_format = regs.h.cl; *dev_type = regs.h.ch; *data_type = regs.h.
Returned Values: BH = 5 BL = 0 26 36 0xff AL = 0 1 None ; for both 26- and 36-bit formats ; for 26-bit only ; for 36-bit only ; for un-formatted data ; Disable ; Enable void TD_set_wiegand_status(int status,int type) { regs.h.ah= 0x1f; regs.h.al= (unsigned char)status; regs.h.bh= 5; if (type == -1) regs.h.bl= 0xff; else regs.h.
Returned Values: AL = 0 1 None ;assign barcode input ;assign magnetic stripe input void TD_set_internal_type(int status) { regs.h.ah= 0x1A; regs.h.al= (unsigned char)status; regs.h.bh= 6; int86(0x21,®s,®s); return(regs.h.al); } 1F Enable the decoding of a barcode symbology Entry Parameters: Returned Values: AH = 0x1F BH = 1 AL = 0 ; Disable 1 ; Enable BL = 0 ; All 1 : Code 39 2 : I 2 of 5 3 : CODABAR 4 : EAN/UPC 5 : Code 128 None void TD_set_decode_status(int status,int type) { regs.h.
Returned Values: AL = 1 0 ; Lithium battery low ; Normal int TS_lithium_battery() { regs.h.ah= 0x1A; regs.h.bh= 9; int86(0x21,®s,®s); return(regs.h.al); } 1B Get Address ID of the terminal Entry Parameters: Returned Values: AH = 0x1B BH = 6 AL = Address ID char TC_get_address() { regs.h.ah = 0x1b; regs.h.bh = 6; int86(0x21,®s,®s); return((char)regs.h.
void TS_get_interrupt_vector(int vect,unsigned int *es,unsigned int *bx) { regs.h.ah= 0x35; regs.h.al= (unsigned char)vect; int86x(0x21,®s,®s,&segregs); *es = segregs.es; *bx = regs.x.bx; } 36 Get free disk cluster Entry Parameters: Returned Values: AH = 0x36 AH = 1 (number of sector per cluster) BX = number of available clusters CX = 1024 (number of bytes per sector) long TS_free_disk() { regs.h.ah= 0x36; int86x(0x21,®s,®s,&segregs); return((long)regs.x.bx*(long)regs.x.
DS:DX keyboard map with 128 bytes corresponded to numeric and alphabetic ASCII code table; a NULL for defining unused key. CX = 0x80 (table length for 128 bytes) None Returned Values: = void TD_key_map(unsigned char *str) { regs.h.ah=0x1E; regs.h.bh=1; regs.x.cx=0x80; segregs.ds = FP_SEG(str); regs.x.
ASCII code corresponded to scan code in Alphabetic mode Alphabetic mode keyboard layout ASCII code, ASCII code, ASCII code [Scan code, Scan code, Scan code] F1 ?? F2 ?? F5 * F6 ? QZ.
Returned Values: DL = 8-bit data None void TS_stdout(unsigned char ch) { regs.h.ah= 2; regs.h.dl= ch; int86(0x21,®s,®s); return; } 03 Read stdaux (COM2 RS-232 port) No check on control keys (ESC) Entry Parameters: AH = 03 Returned Values: AL = 8-bit data unsigned char TS_stdaux_in() { regs.h.ah= 3; int86(0x21,®s,®s); return(regs.h.al); } 04 Write stdaux (COM2 RS-232 port) Entry Parameters: Returned Values: AH = 04 DL = 8-bit data None void TS_stdaux_out(unsigned char ch) { regs.h.
if char not ready, Zero = set unsigned char TS_stdin_out(unsigned char ch) { regs.h.ah= 6; regs.h.dl= ch; int86(0x21,®s,®s); if (ch == 0xFF) { if ((regs.x.cflag & 0x40) == 0) return(regs.h.al); else return(0); } return(0); } 07 Read stdin (wait if no key) No check on control keys (ESC) Entry Parameters: AH = 07 Returned Values: AL = 8-bit data unsigned char TS_stdin_noecho() { regs.h.ah= 7; int86(0x21,®s,®s); return(regs.h.
void TS_stdout_string(unsigned char *str) { segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); regs.h.ah= 9; int86x(0x21,®s,®s,&segregs); return; } 0A Keyboard buffer input Entry Parameters: AH = 0A DS:DX = pointer to input buffer area Returned Values: Buffer filled with last character by a CR void TS_stdin_string(unsigned char *str) { segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); regs.h.
CX = year (1980..2099) DH = month (1..12) DL = day (1..31) void TS_get_date(int *year,int *month,int *day,int *week) { TD_int_dos1(0x2a,0,0,0); *year = regs.x.cx; *month = regs.h.dh; *day = regs.h.dl; *week = regs.h.al; } 2B Set System date Entry Parameters: Returned Values: AH = 2B CX = year (1980..2099) DH = month (1..12) DL = day (1..31) AL = 0 int TS_set_date(int year,int month,int day) { regs.h.ah = 0x2b; regs.x.cx = year; regs.h.dh = month; regs.h.dl = day; int86(0x21,®s,®s); return(regs.h.
2D Set System clock Entry Parameters: Returned Values: AH = 2D CH = hour (0..23) CL = min (0..59) DH = sec (0..59) AL = 0 int TS_set_time(int hour,int minute,int second,int hund_sec) { regs.h.ch = hour; regs.h.cl = minute; regs.h.dh = second; regs.h.dl = hund_sec; regs.h.ah = 0x2d; int86(0x21,®s,®s); return(regs.h.al); } 3.9. File Manager When the file is downloaded or uploaded, the working file can not be opened by the application command.
if ((regs.x.cflag & 0x01) == 1) return(-1); else return(regs.x.ax); } 3D Open file The file must exist in the file table. This function returns the file handle. Entry Parameters: Returned Values: AH = 3D AL = 0 ; Read only 1 ; Write only 2 ; Both Read and Write DS:DX = segment:offset of ASCIIZ file name if successful : Carry = clear, AX = handle if fail : Carry = set, AX = 2 When a file is opened, the file manager searches the file table for a file name match.
3F Read file Copy (CX) bytes from current address to DS:DX. Advance the current address (CX) number of bytes. Entry Parameters: Returned Values: AH = 3F BX = file handle CX = number of bytes to read DS:DX = segment:offset of buffer area if successful: Carry = clear, AX = number of bytes read, 0 if EOF if fail: Carry = set, AX = 6 int TS_read_file(int hdl,int cnt,char *str) { segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); regs.h.ah=0x3f; regs.x.cx=cnt; regs.x.
if ((regs.x.cflag & 0x01) == 0) return(regs.x.ax); else return(-1); } 41 Delete file Entry Parameters: Returned Values: AH = 41 DS:DX = segment:offset of ASCIIZ file name if successful : Carry = clear, if fail : Carry = set, AX = 2 int TS_delete_file(char *fn) { segregs.ds = FP_SEG(fn); regs.x.dx = FP_OFF(fn); regs.h.ah=0x41; int86x(0x21,®s,®s,&segregs); if ((regs.x.
long TS_seek_file(int hdl,int type,long loc) { union LONG_III aa; regs.h.ah=0x42; regs.h.al=(unsigned char)type; regs.x.bx=hdl; aa.l.ll = loc; regs.x.cx=aa.i.ii2; regs.x.dx=aa.i.ii1; int86(0x21,®s,®s); aa.i.ii2=regs.x.dx; aa.i.ii1=regs.x.ax; if ((regs.x.cflag & 0x01) == 0) return(aa.l.
segregs.ds = FP_SEG(inf); regs.x.dx = FP_OFF(inf); segregs.es = FP_SEG(outf); regs.x.di = FP_OFF(outf); regs.h.ah=0x56; int86x(0x21,®s,®s,&segregs); if ((regs.x.cflag & 0x01) == 0) return(regs.x.
This page is blank.
Chapter 4. Host ESC Commands 4. Host ESC Commands There are three classes of host communication activities: (1) Host Sends Control/Configuration Commands to the MR350MKII Almost all MR350MKII configurations and operations may be controlled by the host system via control commands. Configuration commands are used to set up system tables such as the communication control table.
restored from the Flash ROM.The hard reset command will not purge the program files that stored on Flash ROM The hard reset command does not have any parameter or value. The equivalent keypad invoking sequence is entering the supervisor mode and selecting an initialization command. 2. Abort ( ESC A ) Abort is the "soft reset" command. The MR350MKII terminates its execution and returns to ready mode. Programs and data that have been stored in the MR350MKII RAM space are preserved.
6. Autoboot ( ESC O program name ) This command defines an autoboot program name in the MR350MKII. The autoboot program will be executed automatically each time the power is turned OFF and ON. 7. Password ( ESC P password ) To create or edit a supervisor password. 8. Get RAM size (ESC G) Get the MR350MKII total RAM size, program execution memory, and free memory which available for RAM disc.
15. Buzzer Volume (ESC N) This command can remote changing MR350MKII's buzzer sound. 16. Supervisor password (ESC P) This command can remote changing MR350MKII's buzzer sound. 17. Get terminal ID (ESC R) This commcand can get terminal ID. The default terminal ID is "MR350" 18. Get terminal ID and version no (ESC v) This commcand can get terminal ID and version no. The default terminal ID is "MR350 V4.xx". 4.2.
The new communication control table takes effect immediately after the ESC C command has been successfully received. The MR350MKII will reinitialize the corresponding communication port with its new parameters. For example, if ESC C instructs the RS-232 port to change the baud rate from 9600 to 1200 the MR350MKII will switch to 1200 right after the ESC C command has been received. The next host communication will use 1200 baud. 3.
For example, command ESC M 199009262345 will initialize the MR350MKII clock to September 26, 1990. The time is 11:45 PM. The MR350MKII reconfigures the real time clock chip as soon as the ESC M command has been successfully received. 4.3. File Transfer Commands 1. Download ( ESC L filename ) The download command is used to transfer a binary executable program or data file from the host system to the MR350MKII.
ADDR Terminal address (A-Y,0-6) + 80H CMD Network command to terminal, 2 bytes, A-F,0-9 CS1 Checksum, first byte CS2 Checksum, second byte The checksum is calculated by adding each byte of the transmission, ADDR, and length of data block (excluding STX and ETX). CS1 is high nibble (4 bits) +40H and CS2 is low nibble +40H. Example: Command to load the file named A.EXE STX ESC L A . E X E CS1 CS2 ADDR Data block = ESC L A . E X E (excluding STX) Length of data block = 7 CS = ESC + L + A + .
\ convert to \\ 00 hex -- 1F hex convert to \ 80 hex -- \ 9F hex A0 hex -- FF hex convert to \ 20 hex -- \ 7F hex (excluding DC hex) 2) one-byte data transmitted as original data without converting unchanged other codes Host Transmissions Transmission Format Poll STX, ADDR Host Data STX, CMD, data, CS1, CS2, ADDR Acknowledgment ACK Negative ACK NAK Terminal Transmissions Transmission Format Terminal Data STX, data, CS1, CS2, ETX Acknowledgment ACK Negative ACK NAK 4.4.1.
=> ACK NAK - if data is received correctly, or - if an error has occurred * The host sends a command to and receives a response from the terminal in one poll cycle; it then acknowledges receipt of the terminal command response: => <= <= => STX, CMD, parms, ... CS1, CS2, ADDR ACK - if data is received correctly and no response is required, or NAK - if an error occurred or if there is response data to be sent.
ESC 5 - Set multipoint address => STX ESC '5' CS1 CS2 ADDR where = 'A'~'Y','0'~'6' <= STX ESC '5' CS1 CS2 ETX where = 0x00 if set OK 0x01 error => ACK or NAK ESC 9 - Send diagnostic test data => STX ESC '9' CS1 CS2 ADDR <= STX ESC '9' CS1 CS2 ETX => ACK or NAK ESC A - Soft Reset, Restart, or Abort This command stops any MR350MKII program execution as if control-exit has been pressed on the keypad.
ESC D - Read directory of RAM disk to host => <= => STX ESC D CS1 CS2 ADDR STX ESC D CS1 CS2 ETX (or NAK) ACK or NAK ESC D/ROM - Read directory of Flash ROM to host => <= => STX ESC D/ROM CS1 CS2 ADDR STX ESC D/ROM CS1 CS2 ETX (or NAK) ACK or NAK ESC E - Erase a file from the MR350MKII directory => <= => STX ESC E CS1 CS2 ADDR STX ESC E CS1 CS2 ETX where : 00 if successfully erased 01 file does not exist ACK or NAK ESC F - Disable UPS ba
ESC G/ROM - Get MR350MKII's Flash ROM size => STX ESC G/ROM CS1 CS2 ADDR <= STX ESC G/ROM CS1 CS2 ETX where = number of Kbytes of total memory = number of Kbytes of Free memory => ACK or NAK ESC H - Hard Reset and initiate power on test This command resets the MR350MKII terminal, and running applications are halted. Power-on test routines are run and, if completion is normal, the MR350MKII is ready for the next command.
ESC K - Set keyboard locking => STX ESC K CS1 CS2 ADDR where state = '0' set keyboard LOCK = '1' set keyboard UNLOCK = '2' set keyboard Partial LOCK <= STX ESC K CS1 CS2 ETX where Retcode = 00 if successful = 01 if not successful => ACK or NAK ESC L - Transfer file to MR350MKII => <= ... => <= STX ESC L CS1 CS2 ADDR ACK or NAK ....
ESC O/ROM - Set auto-execution program on ROM => STX ESC O /ROM CS1 CS2 ADDR <= STX ESC O /ROM CS1 CS2 ETX where Retcode = 00 if successful = 01 if not successful => ACK or NAK ESC P - Set supervisor password (maxi.
=> ACK or NAK ESC v - Get Terminal ID and version no => <= => STX ESC V CS1 CS2 ADDR STX ESC V CS1 CS2 ETX ACK or NAK ESC X - Start program execution => <= => STX ESC X CS1 CS2 ADDR STX ESC X CS1 CS2 ETX where : 00 if successfully started 01 file does not exist ACK or NAK Where the should contain the name of file only but without file extension name “.EXE”. For example: A executable program named ? RV30.
of $Txxxxxxxxxx.yyy, where xxxxxxxxx is the template ID and yyy is the template index. ==> STX ESC $D CS1 CS2 ADDR <== STX ESC $D RESULT CS1 CS2 ETX or <== NAK RESULT = ‘0’ ;success = ‘1’ ;fail = ‘2’ ;busy = ‘3’ ;timeout NAK means command format error or checksum error. For the host to get the MV1100 template list, it should issue ESC $D command first and then issue ESC U command to upload file $FP.LST if ESC $D command is successful.
ESC $E Erase Template The command erases the specified template on MV1100. ==> STX ESC $E xxxxxxxxxx.yyy CS1 CS2 ADDR <== STX ESC $E RESULT CS1 CS2 ETX or <== NAK xxxxxxxxxx ;template ID ( ‘1’ -- ‘4294967294’) yyy RESULT = ;template index ( ‘0‘-- ‘255’) ‘0’ ;success = ‘1’ ;fail = ‘2’ ;busy = ‘3’ ;timeout NAK means command format error or checksum error. ESC $F Enroll and Store Template on MR350 MKII The command enrolls and stores the template with the specified ID to the MR350 MKII reserved file $FP.
ESC $G Enroll and Store Template on MV1100 () The command enrolls and stores the template with the specified ID on MV1100.
SCORE is an integer that has a range of ‘000’– ‘100’ NAK means command format error or checksum error. For the host to verify against the template saved on its disk, it should issue ESC L command first to download the template to the MR350 MKII reserved file $FP.DNL and then issue ESC $H command to verify the fingerprint if ESC L command is successful. ESC $I Verify ID () The command requests to verify the fingerprint against the template(s) with the specified ID stored on MV1100.
= ‘1’ ;fail = ‘2’ ;busy = ‘3’ ;timeout NAK means command format error or checksum error. For the host to download the template saved on its disk, it should issue ESC L command first to download the template to the MR350 MKII reserved file $FP.DNL and then issue ESC $L command to download it to MV1100 if ESC L command is successful. ESC $S Set Globe Threshold () The command sets the globe verification value for MV1100 .
THRESH = ‘1’ ,very high security = ‘2’ ;high security = ‘3’ ;medium security = ‘4’ ;low security = ‘5’ ;very low security NAK means command format error or checksum error. ESC $U Upload Template () The command uploads the specified template from MV1100 flash memory to the MR350 reserved file $FP.UPL . ==> STX ESC $U xxxxxxxxxx.
If RESULT = ‘0’, MR350MKII will response with the version field: Kx.xxxx Ay.yyyy where x.xxxx represents the version of the kernal and y.yyyy represents the version number of the algorithm. NAK means command format error or checksum error.
Chapter 5. How to programning ? 5. How to to programming There are two major parts for programming – 1. Programming MR350 MKII and 2. Programming communication program between MR350 MKII and Host computer. The following topic describe application and utility library that will help users to develop quickly and efficiently for their applications. 5.1.
5.1.1. Programming by JobGen PRO The JOB GENerator PROfessional (JobGenPRO) is an MS-DOS based software for developing applications for MR350MKII. With JobGenPRO, application developers may create an application program easily by defining the transactions, attributes of data fields and operation flow without writing program code. An executable program generated by JobGenPRO can be downloaded and run on the MR350 MKII then.
with all MR350MKII? input/output devices. All detailed calling convention and source code are listed behind each BIOS/DOS call in Chapter 3. For easily using this library, Unitech also provide sample program (350TEST.C) to help user to use it. So, user can directly modify this sample program. All of those files are stored on sub-directory "LIB" of DEMO disk. 5.2. Programming communication program In Chapter 4, there are details description about Multi-Protocol between MR350MKII and Host computer.
5.3. Contains of the Demo Disk Below table show whole content of Demo disk C function library for MR350 MKII programming 1) 350LIB.C/OBJ/H C library source/object/header files MR350 MKII 2) 350TEST.C/EXE Test program and source code for using C library C library for programming DOS base Communication program 1) 485COM.EXE/C Communication Utility 2) 485LIB.C/OBJ C function library for 485COM.EXE 3) SLIB.
Appendix A. Standard C Libraries Routine for MR350MKII 1. Buffer Manipulation memccpy() memchr() memmove() memcpy() memcmp() memset() memicmp() movedata() 2. Character Classification and Conversion isalnum() isalpha() isascii() iscntrl() isdigit() isgraph() islower() isprint() ispunct() isspace() isupper() isxdigit() toascii() tolower() toupper() 3. Data Conversion atof() atoi() atol() ecvt() fcvt() gcvt() itoa() ltoa() strtod() strtol() strtoul() ultoa() 4. File Handling remove() unlink() 5.
9. Memory Allocation alloca() calloc() hfree() malloc() sbrk() stackavail() free() msize() halloc() realloc() 11.Searching and Sorting bsearch() l2ind() lsearch() qsort() 12.String Manipulation strcat() strchr() strcpy() strcspn() stricmp() strlen() strncmp() strncpy() strpbrk() strrchr() strspn() strstr() strcmp() strdup() strlwr() strnicmp() strrev() strtok() strcmpi() strerror() strncat() strnset() strset() strupr() 13.