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
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:
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’)
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.
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.
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.
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).
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.
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.
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
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