Unitech MR350MKII User Manual

MR350MKII
Data Collection Terminal
Programming Reference Manual
September 2001 V1.2
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. If you doesn’t have the diskette, please contact your local unitech authorized dealer.
1-1
Table of Contents
Table of Contents ...................................................................................................................1-2
1. System Kernel............................................................................................................1-6
1.1. Application Programming Interface.................................................................................. 1-6
1.2. Keypad Subsystem............................................................................................................ 1-7
1.3. Display Subsystem............................................................................................................ 1-7
1.4. Communication Subsystem............................................................................................... 1-8
1.4.1. Point to point mode.................................................................................................... 1-8
1.4.2. Multi-point mode....................................................................................................... 1-8
1.5. Real time clock subsystem ................................................................................................ 1-8
1.6. Relay output and Digital input subsystem.......................................................................... 1-8
1.7. Bar code / Magnetic stripe / Proximity / ICC .................................................................... 1-9
1.8. Download Program in Point-to-point mode....................................................................... 1-9
1.9. Download Program in Multi-point mode......................................................................... 1-10
2. Data Structure.......................................................................................................... 2-14
2.1. Device Control Table...................................................................................................... 2-14
2.2. Type Definition .............................................................................................................. 2-14
2.3. Barcode Control Table.................................................................................................... 2-15
2.3.1. Type Definition........................................................................................................ 2-15
2.4. Communication Control Table of Host port..................................................................... 2-16
2.4.1. Type Definition........................................................................................................ 2-16
2.5. Terminal Control Table (available for host port only) ..................................................... 2-17
2.5.1. Type Definition........................................................................................................ 2-17
3. I/O Function Calls.................................................................................................... 3-20
3.1. LCD Display INT 10H.................................................................................................. 3-20
00 Clear screen............................................................................................................. 3-20
01 Set cursor type ......................................................................................................... 3-20
02 Set cursor position ................................................................................................... 3-20
03 Get cursor position................................................................................................... 3-21
04 Scroll screen............................................................................................................ 3-21
1A Enable/disable LCD Backlight INT 21H ................................................................. 3-21
3.2. Communication Environment Setup ............................................................................... 3-22
1C Select COM1 or COM2 as the host port ................................................................... 3-22
1C Set host port protocol ............................................................................................... 3-23
1C Set serial port flow control ....................................................................................... 3-23
19 Set COM1 port as RS485 or modem ........................................................................ 3-24
3.3. Host Port for Multi-point Protocol I/O (INT21H)........................................................... 3-24
1C Setup multi-point address......................................................................................... 3-24
1C Set polling timeout duration..................................................................................... 3-24
5F Read host port.......................................................................................................... 3-25
60 Output data.............................................................................................................. 3-25
61 Check if Busy-port................................................................................................... 3-25
3.4. Serial I/O for RS-232 and RS-485................................................................................... 3-26
RS-232 port serial I/O using INT 34H................................................................................ 3-26
01 Input data ................................................................................................................ 3-26
02 Output data.............................................................................................................. 3-27
1-2
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 ................................................................................. 3-29
06 Read CTS signal of RS-232 port .............................................................................. 3-29
RS-485 port serial I/O using INT 33H............................................................................... 3-29
01 Input data ................................................................................................................ 3-29
02 Output data.............................................................................................................. 3-30
03 Enable RS-485 port for serial I/O............................................................................. 3-30
04 Disable RS-485 port for serial I/O............................................................................ 3-30
00 Set Communication parameters................................................................................ 3-31
05 Open RS-485 multi-bus to send out data .................................................................. 3-32
06 Close RS-485 multi-bus (release RS-485 bus) .......................................................... 3-33
3.5. Relay Output / Digit Input / Buzzer / LED Indicator....................................................... 3-34
Set LED indicator ON/OFF INT 09H .................................................................................. 3-34
Read Photo Coupler Level state INT 08H.............................................................................. 3-34
Activate/Deactivate Relay ports INT 09H ............................................................................ 3-35
1A Buzzer On/Off INT 21H ......................................................................................... 3-35
1A Set buzzer volume INT 21H..................................................................................... 3-36
1B Get Security state INT 21H..................................................................................... 3-36
1B Alarm On/Off INT 21H ........................................................................................... 3-36
54 Buzzer volume control with user-defined frequency and time INT 21H................... 3-37
Buzzer volume control with predefined frequency and time INT 35H .................................. 3-37
3.6. Internal/ External reader Port: INT 21H ........................................................................ 3-38
51 Enable/Disable External reader port......................................................................... 3-38
18 Set external slot reader (only available for Barcode and Magnetic reader)................ 3-38
50 Read data from external reader(only available for Barcode and Magnetic reader)..... 3-39
52 Read Internal port.................................................................................................... 3-39
53 Enable/disable Internal reader.................................................................................. 3-40
1F Enable/Disable the Decoder of Wiegand Format (Proximity reader)......................... 3-40
1F Get Decoder status of Wiegand Format (Proximity reader)....................................... 3-41
1A Assign barcode or magnetic stripe input of Internal reader....................................... 3-41
1F Enable the decoding of a barcode symbology............................................................ 3-42
3.7. Miscellaneous: INT 21H................................................................................................ 3-42
1A Check lithium battery level ...................................................................................... 3-42
1B Get Address ID of the terminal ................................................................................ 3-43
25 Set interrupt vector .................................................................................................. 3-43
35 Get interrupt vector.................................................................................................. 3-43
36 Get free disk cluster................................................................................................. 3-44
1A Enable/disable system key-pressing commands: Warm start, Invoke user command menu,
Invoke supervisor mode......................................................................................................... 3-44
1E Change the Keyboard map....................................................................................... 3-44
3.8. DOS Manager................................................................................................................. 3-46
01 Read stdin (wait if no key) and write it to stdout ...................................................... 3-46
02 Write stdout............................................................................................................. 3-46
03 Read stdaux (COM2 RS-232 port) ........................................................................... 3-47
04 Write stdaux (COM2 RS-232 port) .......................................................................... 3-47
06 Read / Write stdin or return 0 if none is ready.......................................................... 3-47
07 Read stdin (wait if no key) ....................................................................................... 3-48
08 Read stdin (wait if no key) ....................................................................................... 3-48
09 Write character string to stdout................................................................................ 3-48
0A Keyboard buffer input.............................................................................................. 3-49
0B Keyhit check............................................................................................................ 3-49
2A Get System date....................................................................................................... 3-49
1-3
2B Set System date........................................................................................................ 3-50
2C Get System clock ..................................................................................................... 3-50
2D Set System clock...................................................................................................... 3-51
3.9. File Manager.................................................................................................................. 3-51
3C Create or truncate file .............................................................................................. 3-51
3D Open file.................................................................................................................. 3-52
3E Close file ................................................................................................................. 3-52
3F Read file.................................................................................................................. 3-53
40 Write file ................................................................................................................. 3-53
41 Delete file................................................................................................................ 3-54
42 Move file pointer ..................................................................................................... 3-54
43 Get file attribute....................................................................................................... 3-55
56 Rename a file........................................................................................................... 3-55
48 Allocate specified number of paragraphs memory .................................................... 3-56
49 Free allocated memory............................................................................................. 3-56
4A Modify allocated block............................................................................................. 3-56
4. Host ESC Commands..............................................................................................4-58
4.1. General Control Commands ........................................................................................... 4-58
17. Get terminal ID (ESC R)................................................................................... 4-61
This commcand can get terminal ID. The default terminal ID is "MR350"...................... 4-61
18. Get terminal ID and version no (ESC v)............................................................ 4-61
This commcand can get terminal ID and version no. The default terminal ID is "MR350 V4.xx".
....................................................................................................................................... 4-61
4.2. Configuration Commands............................................................................................... 4-61
4.3. File Transfer Commands ................................................................................................ 4-63
4.4. Multipoint Protocol......................................................................................................... 4-63
4.4.1. Protocol Operation................................................................................................... 4-65
4.4.2. Commands............................................................................................................... 4-66
ESC 0 - Application data................................................................................................ 4-66
ESC A - Soft Reset, Restart, or Abort.............................................................................. 4-67
ESC B - Enable/disable the decoding of barcode symbologies:....................................... 4-67
ESC C - Write communication configuration table to MR350MKII................................. 4-67
ESC D - Read directory of RAM disk to host................................................................... 4-68
ESC D/ROM - Read directory of Flash ROM to host ...................................................... 4-68
ESC E - Erase a file from the MR350MKII directory...................................................... 4-68
ESC F - Disable UPS battery to supply power ................................................................ 4-68
ESC G - Get MR350MKII's RAM size............................................................................. 4-68
ESC G/ROM - Get MR350MKII's Flash ROM size.......................................................... 4-69
ESC H - Hard Reset and initiate power on test ............................................................... 4-69
ESC I - Get filename of current executing program ........................................................ 4-69
ESC J - Check if file existed or not................................................................................. 4-69
ESC K - Set keyboard locking......................................................................................... 4-70
ESC L - Transfer file to MR350MKII.............................................................................. 4-70
ESC M - Write date and time to MR350MKII.................................................................. 4-70
ESC O - Set auto-execution program.............................................................................. 4-70
ESC P - Set supervisor password (maxi. 8 characters).................................................... 4-71
ESC R - Terminal ID ...................................................................................................... 4-71
ESC T - Write terminal configuration table to MR350MKII............................................ 4-71
ESC U - Transfer file from MR350MKII......................................................................... 4-71
ESC V - Write device configuration table to MR350MKII............................................... 4-71
ESC v - Get Terminal ID and version no......................................................................... 4-72
ESC X - Start program execution.................................................................................... 4-72
1-4
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 ) ............................................... 4-75
4.5.5. Verify Template ( ESC $H )................................................................................... 4-75
4.5.6. Verify ID ( ESC $I )............................................................................................... 4-76
4.5.7. Download Template ( ESC $L).............................................................................. 4-76
4.5.8. Set Globe Threshold ( ESC $S).............................................................................. 4-77
4.5.9. Get Globe Threshold ( ESC $S) ............................................................................. 4-77
4.5.10. Upload Template ( ESC $U)............................................................................ 4-78
4.5.11. Get Version ( ESC $V) ................................................................................... 4-78
4.6. ESC Commands Added for Flash Memory Features.........Error! Bookmark not defined.
5. How to to programming ..........................................................................................5-80
5.1. Programming MR350 MKII ........................................................................................... 5-80
5.1.1. Programming by JobGen PRO ................................................................................. 5-81
5.1.2. Programming by C/C++........................................................................................... 5-81
5.2. Programming communication program........................................................................... 5-82
5.3. Contains of the Demo Disk............................................................................................. 5-83
Appendix A. Standard C Libraries Routine for MR350MKII...............................................5-84
1-5
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. The programmer can design the application programs by calling those available functions just like that in the PC DOS environment.
The ROM based operating system of the terminal provides emulated MS/DOS function calls. The calling and parameter passing conventions are identical to that of MS/DOS. The detailed description of supported functions of the Terminal's subsystems, I/O interface, DOS manager and File manager is defined in later chapters.
The software to be run on MR350MKII may be programmed by using Microsoft C 5.1 and later version, and the IBM PC macro assembler version
1.0 and later version. Transaction data can be processed interactively with the computer or stored in a file.
NOTE in using Microsoft C:
When program execution area assigned less than 64K (see section 4.3) and a program with size more than 64K is invoked to run. A run time error message, "Not enough space for environment", will be shown. In this case add following statement in main:
/* mypgm.c */ _setenvp() { } main() {... ... ... }
and link with: >LINK /NOE mypgm
1-6
1.2. Keypad Subsystem
F1/
?
F3/
?
F4/
?
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.
Key Value Key Value Key Value Key Value
A 41H O 4FH [SP] 20H B 42H P 50H 0 30H C 43H Q 51H 1 31H D 44H R 52H 2 32H E 45H S 53H 3 33H F5/* 8AH F 46H T 54H 4 34H G 47H U 55H 5 35H H 48H V 56H 6 36H I 49H W 57H 7 37H J 4AH X 58H 8 38H K 4BH Y 59H 9 39H L 4CH Z 5AH [E] 0DH M 4DH + 2BH [C] 08H
Table of Key Values
F2/??
F6/? F7/?
86H 87H 88H 89H
8BH 8CH
N 4EH - 2DH
.
2EH
1.3. Display Subsystem
This subsystem provides the interface functions: Display character, Display string, Set cursor position, and Clear screen display. The display coordinates
are organized as follows: Min Min Max Max Row Col Row Col 0 0 1 15
The origin (0,0) is always at the upper left hand corner.
1-7
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. Nevertheless to transfer files, a Kermit server can be invoked by selecting option “3) COM” in user command menu or typing ”COM” in the Ready mode and a Kermit utility should also run on the Host side in order to make the data communication.
1.4.2. Multi-point mode
Either RS-232 or RS-485 port can be also used in multi-point mode by Multi-protocol (define by Unitech) when it is set as Host port. While RS-485 port is assigned to serve multi-point mode, up to 32 terminals can be accessed through one channel, On the other hand, while RS-232 is selected, the number of accessible terminals is limited by the number of available RS-232 ports on the host computer. There is also a multi-point communication protocol built in the MR350MKII for data communication of a multi-point networking.
1.5. Real time clock subsystem
This subsystem allows the program to set and read system date and time of
the MR350MKII.
1.6. Relay output and Digital input subsystem
The MR350MKII supports two contact relay ports and four photocoupler
input ports for digital signal input/output control, where pin #11/12 and pin
#13/14 can also be assigned to RS-232 port and barcode scanner by setting
of jumpers J1 to J6 (refer to MR350MKII Technical Reference Manual).
1-8
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. If the terminal block port #3 is set as scanner port, it can support barcode wand, slot reader , magnetic stripe reader and proximity reader.
The Internal reader, as badge reader port, is mainly designed for
connecting a barcode slot reader, magnetic stripe reader, proximity
reader(wiegand interface) or smart card (ICC) reader. The terminal supports
the reading of single track 1, 2 or 3 magnetic card stripe.
1.8. Download Program in Point-to-point mode
Connect the Terminal in point-to-point mode through serial port interface,
then follow the steps listed below to download a program to the Terminal:
Step 1. Connect a MR350MKII to a PC via RS232 interface with a proper
cable.
Step 2. Press [F5/*] to invoke user command menu.
Step 3. Select option “3) COM” to enter the Kermit serve mode.
Step 4 Insert the UTILITY diskette into the PC.
Step 5. Run KERMIT in the PC.
Step 6. Use the send command from PC to MR350MKII to download the
UTILITY program, 350TEST.EXE.
? MS-Kermit>SEND <file name>
Downloads an execution file from the PC disk to MR350MKII RAM area. (program)
? MS-Kermit>GET <file name>
Gets a collected data file from MR350MKII RAM area (data) to PC disk.
? MS-Kermit>REMOTE DIR
1-9
Displays all of the files which are stored in the MR350MKII ( Program as well as data file)
? MS-Kermit>REMOTE DEL <file name>
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.EXE to run, or, type the filename (i.e. 350TEST) directly under system Ready prompt. This program allows you to scan barcode data and send data from the MR350MKII to the PC.
1.9. Download Program in Multi-point mode
A sample program, 485COM.EXE, in the UTILITY disk is for multi-point
mode environment testing. Please note in multi-point mode each terminal
should be assigned a unique address ID and consistent communication
parameters with the PC.
NOTE: Following instructions use Host port to serve multi-point mode.
1) If Host port is RS232, directly connect to RS232 port between PC and MR350MKII
2) If Host port is RS485. Install an RS-485 interface card or an RS232/422 converter to the PC. And cabling the network trunk from RS485 interface to MR350MKII via RS485 port (note a twist-pair cable with 22 or 24 AWG should be used).
3) Set communication parameters including address ID on each MR350MKII properly. (The default values are, 9600 bps, non-parity, 8 data bits, 1 stop bit, address ID ‘A’)
4) Power up the PC and all terminals.
5) Run the test program, 485COM.EXE, on the PC.
CRT screen shall appear the following message:
Terminal type 1>350/360 2>700/870/860:
Typing “1” for selecting MR350,
COM(1-4)?:
Typing “1” for selecting COM1, “2” for COM2.
1-10
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). Polling data from each terminals.
A). Warm start means putting all connected terminals to ready mode, previously running program is stopped.
B). Set enable/disable the barcode symbologies C). Set communication control table. D). Remote read the files existed on MR350MKII ram disk. E). Remote delete a specified file which existed on ram disk. F). Change RAM size of executable area (Not available on
MR350MKII). f). Change font size. (Not available on MR350MKII) G). Get all connected terminals current total RAM size,
execution area size, and free size. H). Cold start means initializing the system parameters of
all connected terminals to factory default values. I). Get filename of current running program. J). Check if specified file existed or not. K). Set keypad Lock / Unlock / Partial lock. (Not available on
MR350MKII) k). Enter Kermit server mode (Not available on MR350MKII) L). Download a program or data file to MR350MKII. M). Set connected terminal’s date and time.
1-11
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). Loop back testing. @). Dumping terminal and Modem control ?). MR320's setting (Not available on MR350MKII) ~). Disable UPS F1). Set available terminal address to be communicated F2). Set PC's communication parameter F3). Set time period of Time-out/ NAK re-try / ACK F4). Debug mode (display whole received and sent data) F5). Go to DOS shell F6). Set communication packet size (For debug only) [ESC]. Exit 485COM.EXE and back to DOS prompt.
7) Select item F1) to key in the address of all connected terminals or some
terminals to be tested; for example, if there are three terminals connected with address A, B, C, respectively, type “ABC”.
8) Select item L) to download program 350TEST.EXE. This procedure
will be repeated till all designated terminals have been downloaded.
9) Select item X) and input program name, 350TEST, to start up the
program on all designated terminals in step 7.
1-12
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. Key in whether string
according to PC screen instruction, and the string pattern will then be displayed on the terminal's LCD as Application data:XXXXX where XXXXX is the string you keyed in from PC keyboard.
11) You may also select H) and A) to test the Cold-start and Warm-start
functions. Or press [ESC] key to end this program.
1-13
Chapter 2. Data Structure
RS232&RS454
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.
Terminal Application EXEC
Terminal Control Table Device control table
Kernel
File Allocation Table File Handle Table
2.1. Device Control Table
The device control table contains MR350MKII peripheral configuration information including the barcode scanner port, the badge reader port, LCD display, keyboard and buzzer output. The barcode scanner is controlled by a separate data structure and barcode control table, to be discussed later.
2.2. Type Definition
typedef struct { BYTE scanner;
BYTE badge; BYTE lcd_backlight; BYTE buzzer; BYTE keylock; BYTE buzzer_volume; } DEV_CONFIG;
scanner: 'N' = enable scanner port 'F' = disable scanner port (default)
badge 'B' = enable badge port for barcode slot reader (default)
Comm Control Table
2-14
'M' = enable badge port for magnetic card reader 'D' = disable badge port
lcd_backlight: 'N' = set LCD backlight ON 'F' = set LCD backlight OFF (default)
buzzer: 'N' = set buzzer ON (default) 'F' = set buzzer OFF
keylock: 'N' = set keyboard Unlock (default) 'K' = set keyboard Locked 'P' = set keyboard Partial Locked
buzzer_volume: 0 = Low volume (default) '5' = Middle volume '9' = High volume
2.3. Barcode Control Table
The MR350MKII supports decoding software to automatically discriminate bar code symbologies: Code 39, Code 39 Full ASCII, EAN-8, EAN-13, UPC-A, UPC-E, Code 128, Codabar and Interleaved 2 of 5.
2.3.1. Type Definition
typedef struct { BYTE code39; BYTE i2of5; BYTE codabar; BYTE ean_upc; BYTE code128; } BARCODE_CONFIG;
code39: 'N' = Enable barcode decoding of Code 39(default) 'F' = Disable barcode decoding of Code 39
i2of5: 'N' = Enable barcode decoding of Interleaved 2 of 5 (default) 'F' = Disable barcode decoding of Interleaved 2 of 5
codabar: 'N' = Enable barcode decoding of codabar(default) 'F' = Disable barcode decoding of Codabar
ean_upc: 'N' = Enable barcode decoding of UPC/EAN (default) 'F' = Disable barcode decoding of UPC/EAN
code128: 'N' = Enable barcode decoding of Code 128 (default)
2-15
'F' = Disable barcode decoding of Code 128
2.4. 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. The host system may then configure most MR350MKII parameters by issuing host command sequences. The host command sequences will be introduced in this manual.
2.4.1. Type Definition
typedef struct { BYTE baud_rate; BYTE stop_bit; BYTE data_bit; BYTE parity; BYTE protocol; BYTE address; WORD timeout;
} COM_CONFIG;
The MR350MKII terminal communicates with the host via the host port. The communication baud rate may be programmed from 110 to 38.4K baud (bits per second).
baud_rate: '0' = 110 bits per second '1' = 150 '2' = 300 '3' = 600 '4' = 1200 '5' = 2400 '6' = 4800 '7' = 9600 (default) '8' = 19200 '9' = 38400
stop_bit: '1' = one stop bit (default) '2' = two stop bits
data_bit: '7' = 7 data bits '8' = 8 data bits (default)
parity: 'N' = None parity (default)
2-16
'O' = Odd parity 'E' = Even parity
protocol: 'M' = Multipoint (default) 'F' = None protocol address: 'A' = 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). '02'-'FF' in hex format.
The value of this setting is specified for the communication timeout. If the MR350MKII does not receive a response from the host system within the number of timeout cycle periods, the MR350MKII regards the communication as unsuccessful and the transmission is then aborted. If the timeout value is set to zero, no timeout check is performed by the MR350MKII.
2.5. Terminal Control Table (available for host port only)
The terminal control table is meaningful only if the MR350MKII operation switch is set to "terminal mode". All other operational modes ignore the terminal control table.
2.5.1. Type Definition
The terminal control table is defined by the following typedef TERM_CONFIG. There is only one instance of the TERM_CONFIG data structure:
typedef struct { char terminal_id[8]; /* terminal id */ BYTE online; BYTE echo; BYTE autolf; /* auto LF */ BYTE mode; BYTE linepage; /* line or page block */ BYTE lineterm; /* line terminator */
2-17
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.
online: 'R' = set to Remote and transmit data to the host port (default) 'L' = set to Local and not transmit
echo: 'N' = Collected data displayed 'F' = Collected data not displayed
Above two variables, TERM_online and TERM_echo, are used to control transmission and display of the collected data, respectively. If TERM_online is set to Remote the MR350MKII will transmit data to the host, otherwise it will not transmit. If TERM_echo is set to Echo collected data will be displayed on the MR350MKII LCD, otherwise data will not be displayed.
autolf: 'N' = set not to append a LF after a CR 'F' = set to append a LF (default)
This variable instructs the MR350MKII to append a LF character whenever a CR is collected from an input scanning device.
mode: 'C' = set to Character mode 'B' = set to Block mode (default)
This parameter specifies either character mode or block mode free-format operation. The aforementioned form caching operation is only applicable when the MR350MKII is set in block mode.
linepage: 'L' = set line block mode (default) 'P' = set page block mode 'B' = set both line and page block modes
The linepage parameter is useful only if mode has been specified as 'B'.
2-18
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. LCD Display INT 10H
00 Clear screen
Entry Parameters: AH = 0 Returned Values: None
void TL_clrscr() { regs.h.ah= 0; int86(0x10,®s,®s); }
01 Set cursor type
Entry Parameters: AH = 1 AL = 1 ;set Block cursor 0 ;set Underscore cursor 3 ;set cursor off Returned Values: None
void TL_cursor_type(int status) { regs.h.ah = 1; regs.h.al = (unsigned char)status; int86(0x10,®s,®s); }
02 Set cursor position
Entry Parameters: AH = 2 DH = 0 ~ 1 ;row DL = 0 ~ 15 ;column
Returned Values: None
3-20
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: AH = 3 Returned Values: DH = 0 ~ 1 ;row DL = 0 ~ 15 ;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 ;disable = 1 ;enable void TL_scroll(int status) { regs.h.ah = 4; regs.h.al = (unsigned char)status; int86(0x10,®s,®s); }
1A Enable/disable LCD Backlight INT 21H
Entry Parameters: AH = 0x1A BH = 0 AL = 0 ;disable 1 ;enable Returned Values: None
void TL_backlight(int status) { regs.h.ah = 0x1A; regs.h.al = (unsigned char)status; regs.h.bh = 0;
3-21
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.
The factory defaults for the communication environment are:
Host port: as RS-422/485, multi-point protocol. Serial port: RS-232, none protocol.
Once you have assigned the protocol to the host port, the MR350MKII’s system kernel will automatically packing or unpacking the sending or receiving data according to the selected protocol. On the other hand, since the serial port has no protocol, you must use INT 34H (RS232) or INT 33H (RS-422/485) to read or write data character by character.
??NOTE:
If you want to control the host port I/O service, you must designate “NONE” protocol for the host port and then using INT 34H or INT 33H to control I/O for RS232 or RS422/485. The proper function call depends on which port is assigned as host port(see the next two sections).
1C Select COM1 or COM2 as the host port
Entry Parameters: AH = 1C BH = 0
AL = 1 ; Select COM1 as host 2 ; Select COM2 as host Returned Value: None
??NOTE:
While one of the COM port is designated as host, the other one is set as serial port automatically by system.
3-22
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 ; Multi-point (default) 3 ; None protocol 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 Set serial port flow control
The system provides three handshaking mode for serial port: XON/XOFF, CTR/RTS and none. The system default flow control for serial port is ?
ONE”. The CTS/RTS is only available while the RS-232 is designated to serial port.
Entry Parameters: AH = 1C BH = 2 AL = 0 ; None 1 ; XON/XOFF 2 ; CTS/RTS Returned Value: None
??NOTE:
If you want to control the hand shaking flow of serial port, you must set the
flow control as “NONE”.
void TC_flow_ctrl(int status) { regs.h.ah = 0x1C; regs.h.al = (unsigned char)status; regs.h.bh = 2; int86(0x21,®s,®s);
3-23
}
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: AH = 19 AL = 0 ; set as RS485 1 ; set as modem Returned Value: None
void TC_modem_port(int status) { regs.h.ah= 0x19; regs.h.al= status; int86(0x21,®s,®s); }
3.3. Host Port for Multi-point Protocol I/O (INT21H)
1C Setup multi-point address
Entry Parameters: AH = 0x1C BH = 06 AL = 'A'..'Y','0'..'6' Returned Values: None
void TC_set_address(char status) {
regs.h.ah= 0x1C; regs.h.al= status; regs.h.bh= 6; int86(0x21,®s,®s);
}
1C Set polling timeout duration
Entry Parameters: AH = 0x1C BH = 09 AL = 0-255 ;timeout period with base timeout cycle 80ms Returned Values: None ;timeout period is 160ms when set AL=2; AL=0 for no timeout
void TC_time_out(int status)
3-24
{
regs.h.ah= 0x1C; regs.h.al= status; regs.h.bh= 9; int86(0x21,®s,®s);
}
5F Read host port
Entry Parameters: AH = 0x5F Returned Values: 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.al); }
60 Output data
Entry parameters: AH = 0x60 DS:DX = buffer pointer Returned Values: AL = 0 ;output succeed 1 ;buffer busy now
int TC_str_O(unsigned char *str,int wait) { do { regs.h.ah=0x60; segregs.ds = FP_SEG(str); regs.x.dx = FP_OFF(str); int86x(0x21,®s,®s,&segregs); } while (wait && regs.h.al); return(regs.h.al); }
61 Check if Busy-port
Entry Parameters: AH = 0x61
3-25
Loading...
+ 60 hidden pages