8000 Series C Programming Guide Part 1
8000 Series C Programming Guide Part 1
Version 4.31
Copyright © 2007~2015 CIPHERLAB CO., LTD.
All rights reserved
Due to continued product development this information may change without notice. The
information and intellectual property contained herein is confidential between CIPHERLAB
and the client and remains the exclusive property of CIPHERLAB CO., LTD. If you find
any problems in the documentation, please report them to us in writing. CIPHERLAB
does not warrant that this document is error-free.
For product consultancy and technical support, please contact your local sales
representative. Also, you may visit our web site for more information.
All brand, product and service, and trademark names are the property of their registered
owners.
The editorial use of these names is for identification as well as to the benefit of the
owners, with no intention of infringement.
Part II
Modified: 1.4.1 – BT_ACL_DEVICE added
Modified: 4.1.3 – Note for 8231 added
Modified: 4.1.4 – Note for 8231 added
Modified: Appendix III – Wireless Netorking: descriptions and
table updated with 8231
4.30 Mar. 06, 2015 Part I
Modified: 2.2.1 – variable of ScannerDesTbl2[16] added
Modified: 2.2.3 – descriptions for ScannerDesTbl2 added
Modified: 2.4.1 – 3rd ELEMENT: INTER-CHARACTER DELAY (time
range & example revised)
Modified: Appendix I –
Replace ”Symbology Parameter Table I” with “Symbology Parameter
Table for CCD/LASER/Long Ranger Reader” section title,
and ”Symbology Parameter Table II” with “Symbology Parameter
Table for 2D/Extra Long Ranger Reader” section title
Modified: Appendix I – “Symbology Parameter Table for
CCD/LASER/Long Ranger Reader” ScannerDesTbl2[]: Bytes 2 ~
15 reserved for 8200
Modified: Appendix I – “Symbology Parameter Table for 2D/Extra
Long Ranger Reader” ScannerDesTbl[]: Bytes 45 ~ 47 reserved
for 8200/8300/8400/8700; Bytes 45 ~ 82 reserved for 8500
Modified: Appendix II – ScannerDesTbl2[] (bytes 0 & 1) added in
UPC/EAN Families
Part II
- None –
4.29 Dec. 16, 2014 Part I
- None –
Part II
Modified: 1.3.1 – COMM_RF of SetCommType revised
Modified: 5.1 – CipherLab ACL Packet Data added
Modified: 5.2.1 – ACL36xx[16], ReservedByte[204]
New: 5.3.6 ACL Functions
Modified: Appendix IV – ACL added in Bluetooth Examples section
Modified: Appendix IV – Bluetooth HID/USB HID: Subscript 2, Bit 7
& 6-1 added; keyboard wedge type “15” added
Part II
- None –
4.27 Mar. 28, 2014 Part I
Modified: Appendix I - Symbology Table I: Byte 11, bit 5 (GTIN
-> GTIN-14)
Removed: Appendix I - Symbology Table II: Byte 44, bit 2 (GS1
formatting for GS1 DataMatrix)
Modified: Appendix II – Scan Engine, CCD or Laser - GTIN: Byte
11, bit 5 (GTIN -> GTIN-14)
Removed: Appendix II – 2D SCAN ENGINE ONLY:
>2D SYMBOLOGIES | MAXICODE, DATA MATRIX & QR CODE: Byte
44, Bit 2
Part II
Modified: 4.1.1 NETCONFIG Structure – parameters added
Modified: Appendix II – Wireless Networking table – indexes
57, 58, 91, 92, 93 added
4.26 Feb. 12, 2014 Part I
Modified: 2.2.1 Barcod Decoding –
>ScannerDesTbl[45] for 8300
>FsEAN128[2], AIMark[2] arrays added
Modified: 2.10 KEYPAD | 2.10.1 GENERAL –
>8000 supports OSKToggle, SetTrigger commands
Modified: 2.10 KEYPAD | 2.10.6 Enter Key –
>SetMiddleEnter command added for 8400/8700
>SetPistolEnter command added for 8200/8700
Modified: 2.13 Fonts | 2.13.4 Special Fonts –
>8200/8400/8700 support Turkish (SetLanguage command)
Modified: Appendix I – SCANNERDESTBL ARRAY
SYMBOLOGY PARAMETER TABLE I
>Byte 4, Bit 2: Code39 security
>Byte 7, Bit 2: GS1 formatting for EAN-128
>Byte 7, Bit 1: GS1 formatting for GS1 DataBar Family
>Byte 11, Bit 6: Convert EAN8 to EAN13 Format
SYMBOLOGY PARAMETER TABLE II
>Byte 7, Bit 2: GS1 formatting for EAN-128
>Byte 25, Bit 4: Enable/Disable TCIF Linked Code 39 ->‘0’ (default)
>Byte 43, Bit 7~5 added
>Byte 44, Bit 7~3 added
Modified: Appendix II Symbology Parameters –
Scan Engine, CCD or Laser
>Code39: Byte 4, Bit 2
>CODE 128/EAN-128/ISBT 128: Byte 7, Bit 2
>GS1 DataBar FAMILY: Byte 7, Bit 1
>UPC/EAN FAMILIES: Byte 11, Bit 6
>UPC/EAN FAMILIES: UPC-E Triple Check descriptions
SCAN ENGINE, 2D OR (EXTRA) LONG RANGE LASER
>CODE 128 | UCC/EAN-128: Byte 7, Bit 2
>GS1 DataBar FAMILY: Byte 44, Bit 7~5
2D SCAN ENGINE ONLY
>COMPOSITE CODES | CC-A/B/C: Byte 44, Bit 4~3
>2D SYMBOLOGIES | MAXICODE, DATA MATRIX & QR CODE: Byte
44, Bit 2
Modified: Appendix III Scanner Parameters –
>USER PREFERENCES: Byte 43, Bit 7
>READ REDUNDANCY: Byte 43, Bit 6~5
Part II
- None –
4.25 Mar 27, 2013 Part I
Modified: Introduction – the mention of “Chapter 5 Simulator”
removed
Modified: 2.2.2 Code Type – CodeType Table II: add 8400/8700 2D
scan engine to Composite_CC_A/B/C symbologies (Decimal
47/55/118)
Modified: 2.4.1 WedgeSetting[0] setting value table updated
(11~14)
Modified: 2.10.1 OSKToggle (8400/8700 models supported)
Modified: 2.15.9 GetFileInfo (8400/8700 models supported)
Modified: Appendix I – Symbology Parameter Table II: add
8400/8700 2D scan engine to Bit 0 of Byte 9 (Convert UPC-A to
EAN-13)
Modified: Appendix II – Scan Engine, 2D or (Extra) Long Ranger
Laser – UPC/EAN Families: add 8400/8700 2D scan engine to Bit 0
of Byte 9 (Convert UPC-A to EAN-13)
Part II
Modified: Introduction – the mention of “Chapter 5 Simulator”
removed
Modified: 2.2.2 Socket function – parameters of SOCK_RAW type &
ICMP protocol removed
4.24 Dec. 21, 2012 Part I
Modified: 2.2.2 CodeType Tbale II – Composite_CC_A/B/C added
Added: 2.10 Keypad – OSKToggle command added
Modified: 2.13.1 Font Size – 20X20 added
Modified: 2.13.4 Special Fonts – CheckFont, GetFont, SetFont
modified
Added: 2.15.9 Get File Information – GetFileInfo command added
Modified: Appendix I – Symbology Parameter Table II – bit 0 of
Byte 9 added with “8200 2D” scan engine
Modified: Appendix II – SCAN ENGINE, 2D OR (EXTRA) LONG
RANGE LASER – UPC/EAN Families – “8200 2D” scan engine added
Part II
- None –
INTRODUCTION........................................................................................................................ 1
This programming guide is meant for users to write application programs for CipherLab 8
Series Mobile Computers by using the “C” Compiler. It is organized in chapters giving
outlines as follows:
1
CipherLab C Programming Part I
2
Chapter 1
DEVELOPMENT ENVIRONMENT
The C Language Development Kit for CipherLab 8 Series Mobile Computers contains six
directories, namely, BIN, ETC, INCLUDE, LIB, README and USER. To set up the C
language development environment on your PC, you may create the \C_Compiler
directory from the root directory first. Then, simply copy the above six directories from
the CD-ROM to the \C_Compiler directory.
Windows 2000
Windows XP
Windows Vista
Windows 7
IN THIS CHAPTER
1.1 Directory Structure & Variables ....................................... 4
1.2 Development Flow......................................................... 7
1.3 C Compiler ................................................................. 14
3
CipherLab C Programming Part I
BIN
This directory contains executable files. Usage will be described further in later sections.
The BIN folder is for Windows 2000 and Windows XP.
The BIN for Vista-Win7 folder is for Windows Vista and Windows 7.
A number of execution files for compilation, linking, and so on.
ASM900.EXE CC900.EXE EZDRIVER.DLL MAC900.EXE
THC1.EXE THC2.EXE TUAPP.EXE TUCONV.EXE
TUFAL.EXE TULIB.EXE TULINK.EXE TUMPL.EXE
Note: Depending on your operation system, please make sure to use the correct link file.
ETC
This directory contains help and version information of the C Compiler.
4
Chapter 1 Development Environment
INCLUDE
This directory contains header files.
1 header file for mobile-specific library: e.g. 8500lib.h
1 header file for Real-Time Kernel Library: UCOS.H
“C” header files for standard library routines:
CTYPE.H ERRNO.H FLOAT.H LIMITS.H MATH.H
STDARG.H STDDEF.H STDIO.H STDLIB.H STRING.H
TCPIP.H
LIB
This directory contains library object code files.
“C” standard library: C900ml.lib
Mobile-specific library: 8000lib.lib, 8200lib.lib, 8300lib.lib, 8400lib.lib, 8500lib.lib and 8700lib.lib
Readme
This directory contains C Compiler version update and supplemental information.
Sample Program
This directory contains source code of the user program or other sample programs.
Download Utilities
This directory contains utilities for downloading a program (.SHX, .SYN) or font file (.SHX) to the
mobile computer.
Note: USB Virtual COM also shares the interface option of RS-232/IrDA.
Font
This directory contains available font files.
Kernel
This directory contains kernel programs.
Link File
This directory contains link files for (1) Windows 2000, XP and (2) Windows Vista, Windows 7.
Manual
This directory contains programming documents.
5
CipherLab C Programming Part I
6
Chapter 1 Development Environment
The development process is much like writing any other C programs on PC. The flow is
illustrated as below.
7
CipherLab C Programming Part I
The first step is to create or modify the desired C programs using any text editors. We
recommend that you use “.C” as the file extension and create program files under the
USER directory so that you can use the USER directory as the working directory. We
also recommend that you divide the whole program into modules while retaining function
integrity, and put modules into separate files to reduce compilation time.
8
Chapter 1 Development Environment
1.2.2 COMPILE
To compile the C programs, use cc900 command in the directory of the target file. For
the usage of cc900 command and the options, please refer to “cc900.hlp” in the ETC
subdirectory.
The batch file “Y.BAT” which can be found under the USER directory has been created to
simplify the compiling process.
Y FILENAME.C
This batch file invokes the C compilation program which in turn calls many other
executable programs under the BIN directory. As these programs are invoked by the
compiler sequentially, their usages can be ignored. Also, many parameters are set in
calling the compiler driver to accommodate target machine environments. It is
recommended to use the Y.BAT file directly. If you attempt to write your own batch file,
remember to put the same parameters as shown below.
This routine waits until sys_msec is changed. And sys_msec is a system variable that is
updated each 5 milliseconds by background interrupt. If optimization is enabled, this
whole routine is truncated as it is meaningless (which is a dead-loop). To avoid this, the
type identifier “volatile” can be used to suppress optimization.
9
CipherLab C Programming Part I
1.2.3 LINK
If the C source programs are successfully compiled into relocatable object files, the linker
must be used to create the absolute objects, and then the file can be downloaded to the
target machine’s flash memory for execution. However, a linker map file must be
created.
TULINK FILENAME.LNK
This map file “FILENAME.LNK” is used to instruct the linker to allocate absolute addresses
of code, data, constant, and so on according to the target machine environments. This is
a lengthy process as it depends on the hardware architecture. Fortunately, a sample
linker map file is provided and few steps are required to customize it for your own need,
while leaving hardware-related stuff unchanged.
From the following sample linker file, you can see that only the file names need to be
changed (underlined & boldfaced sections). If the linking is successful, an absolute object
file named “FILE1.ABS” is created. Besides, a file named “FILE1.MAP” lists all code and
variable addresses, and, error messages if there is any.
10
Chapter 1 Development Environment
memory
{
IRAM: org = 0x001100, len = 0x000e00 /* 0x1000 – 0x10ff IntVec */
/* 0x1f00 – 0x1fff Stack */
RAM : org = 0x205000, len = 0x3b000
ROM : org = 0xf00000, len = 0x0e0000
}
sections
{
code org = 0xf00000 : {
*(f_head)
*(f_code)
} > ROM
11
CipherLab C Programming Part I
/* End */
12
Chapter 1 Development Environment
The absolute object file created by TULINK is in TOSHIBA’s own format. Before being
downloaded to the target machine, it must be converted to the Motorola S format by
using the “TUCONV” utility.
The batch file “Z.BAT” which can be found under the USER directory has been created to
simplify the linking and format conversion process. Simply run the batch file:
The target executable file (with SHX extension) will then be generated if no error is
found.
Now that the Motorola S format object file FILENAME.shx is created successfully, it can
be downloaded to the flash memory for testing. Run the ProgLoad.exe utility and
configure the following parameters properly.
File Name: Specify the absolute object file.
COM Port: Select the appropriate COM port for transmission.
Baud Rate: Supported baud rates are 115200, 57600, 38400, 19200, and 9600.
Parity: None
Data Bits: 8
Flow Control: None
Note: The selected baud rate, parity, data bits, etc. must match the COM port settings of
the target machine.
13
CipherLab C Programming Part I
1.3 C COMPILER
This C compiler is for TOSHIBA TLCS-900 family 16-bit MCUs, and it is mostly ANSI
compatible. Some specific characteristics are presented in this section.
Regarding the representation range of the values of integer types, macros are defined in
the header file <limits.h> as follows.
14
Chapter 1 Development Environment
About Floating-Point
Every decimal integer can be exactly represented by a binary integer; however, this is not true for
fractional numbers. It is therefore very important to realize that any binary floating-point system
can represent only a finite number of floating-point values in exact form. All other values must be
approximated by the closest representable value. For example, even common decimal fractions,
such as decimal 0.0001, cannot be represented exactly in binary. (0.0001 is a repeating binary
fraction with a period of 104 bits!)
// Floating-point error
float A = 99999.1;
float B = 99999.0;
printf(“%.04f”, A); // It prints “99999.1016” instead of “99999.1000”.
printf(“%.04f”,(A-B) * 100); // It prints “10.1563” instead of “10”.
printf("(A-B)==0.1?%s.",((A-B)==0.1)?"Equal":"Not Equal");
// It prints “(A-B)==0.1?Not Equal”.
We suggest not handling floating-point values directly but converting them to integers first. After
calculations, convert integers to real numbers if necessary. For example, in order to process the
expression of 1.82-1.8, you are advised to modify the expression to something like 182-180, and
then divide the result by 100 to get the actual result of 0.02.
When the floating-point values are displayed, printed, or used in calculations, they lose precision.
Instead of using floating-point, use integer or long to perform arithmetical or logical calculations. If
there is a need to display a fractional number on the screen, convert the integer or long to a string
and add the decimal point in the proper place. For example,
long A=999991;
long B=999990;
long C=(A-B)*100;
15
CipherLab C Programming Part I
IEEE Format
Float is an approximate numeric data type, as defined by the standards. Floating-point
representations have a base and a precision p. If base is 10 and p is 3, then the number 0.1 is
represented as 1.00 × 10-1. If base is 2 and p is 24, then the decimal number 0.1 cannot be
represented exactly, but is approximately 1.10011001100110011001101 × 2-4.
Precision refers to the number of digits that you can represent. The precision of the binary formats
is one greater than the width of its significand, because there is an implied (hidden) 1 bit. A “double
precision” (64-bit) binary floating-point number has a coefficient of 53 bits (one of which is
implied), an exponent of 11 bits, and one sign bit. Positive floating-point numbers in this format
have an approximate range of 10−308 to 10308 (because 308 is approximately 1023 × log10(2), since
the range of the exponent is [−1022,1023]). The complete range of the format is from about
−10308 through +10308.
Name Common Name Base Digits E min E max Decimal digits Decimal E max
binary32 Single precision 2 23+1 -126 +127 7.22 38.23
binary64 Double precision 2 52+1 -1022 +1023 15.95 307.95
16
Chapter 1 Development Environment
1.3.4 ALIGNMENT
Register and interrupt handling are possible through C. However, they are prohibited as
all the accessing to system resources is supposed to be made via CipherLab library
routines.
17
CipherLab C Programming Part I
These are the reserved words specific to this C compiler and all of them start with two
underscores (“_ _”).
The following types can be used as the bit field base types. The allocation is made as
shown in the illustrations.
The bit-field can be very useful in some cases. However, if memory is not a concern, it is
recommended not to use the bit-fields because the code size is downscaled at the cost of
degraded performance.
18
Chapter 1 Development Environment
19
CipherLab C Programming Part I
20
Chapter 2
MOBILE-SPECIFIC FUNCTION LIBRARY
There are a number of mobile-specific library routines to facilitate the development of the
user program. These functions cover a wide variety of tasks, including communications,
show string or bitmap on the LCD, buzzer control, scanning, file manipulation, etc. They
are categorized and described in this section by their functions or the resources they
work on.
The function prototypes of the library routines, as well as the declaration of the system
variables, can be found in the library header file, e.g. “8300lib.h”. It is assumed that the
programmer has prior knowledge of the C language.
IN THIS CHAPTER
2.1 System ...................................................................... 22
2.2 Barcode Reader .......................................................... 54
2.3 RFID Reader ............................................................... 63
2.4 Keyboard Wedge ......................................................... 69
2.5 Buzzer ....................................................................... 77
2.6 LED Indicator ............................................................. 81
2.7 Vibrator & Heater ........................................................ 82
2.8 Real-Time Clock .......................................................... 84
2.9 Battery & Charging...................................................... 87
2.10 Keypad .................................................................... 90
2.11 LCD ....................................................................... 104
2.12 Touch Screen .......................................................... 127
2.13 Fonts ..................................................................... 131
2.14 Memory ................................................................. 138
2.15 File Manipulation ..................................................... 142
2.16 SD Card ................................................................. 191
2.17 Graphical User Interface .......................................... 219
21
CipherLab C Programming Part I
2.1 SYSTEM
2.1.1 GENERAL
_KeepAlive__
Purpose To let the user program keep on running and prevent it from being
automatically shut down by the system.
Syntax void _KeepAlive__ (void);
Example ...
AUTO_OFF = 60; // set 1 minute
_KeepAlive__(); // load the AUTO_OFF value
...
Return Value None
Remarks Whenever this routine is called, it will reset the counter governed by the global
variable AUTO_OFF, so that the user program will keep on running without
suffering from being automatically shut down by the system.
See Also AUTO_OFF
22
Chapter 2 Mobile-Specific Function Library
Return Value For 8000 Series, the return value can be one of the following:
Return Value
0 No wakeup event.
1 POWER_KEY_PRESSED The POWER key is pressed.
2 CHARGE_OK Charging process has been completed.
3 TIME_IS_UP The alarm time is up.
For 8400 Series, the return value can be one of the following:
Return Value
0 No wakeup event.
2 RS232_CABLE_DETECTED RS-232 cable is detected.
4 CHARGING Charging process is ongoing.
8 CHARGE_OK Charging process has been completed.
16 POWER_KEY_PRESSED The POWER key is pressed.
32 TIME_IS_UP The alarm time is up.
64 USB_DETECTED USB cable is detected.
128 RS232_DATA_RXED Data is received via RS-232.
For 8200/8700 Series, the return value can be one of the following:
Return Value
0 No wakeup event.
2 RS232_CABLE_DETECTED RS-232 cable is detected.
4 CHARGING Charging process is ongoing.
8 CHARGE_OK Charging process has been completed.
16 POWER_KEY_PRESSED The POWER key is pressed.
32 TIME_IS_UP The alarm time is up.
64 USB_DETECTED USB cable is detected.
23
CipherLab C Programming Part I
24
Chapter 2 Mobile-Specific Function Library
SetPwrKey
Purpose To determine whether the POWER key serves to turn off the mobile computer
or not.
Syntax void SetPwrKey (int mode);
Parameters int mode
0 POWER_KEY_DISABLE The POWER key is disabled.
1 POWER_KEY_ENABLE The POWER key is enabled.
Example SetPwrKey(1);
shut_down
SysSuspend
system_restart
25
CipherLab C Programming Part I
After being reset, a portion of library functions called POR routine initializes the system
hardware, memory buffers, and parameters such as follows.
There must be one and only one “main” function in the C program which is the entry
point of the application program. Control is then transferred to the “main” function
whenever the system initialization is done.
COM Ports
After reset, all COM ports will be disabled.
Reader Ports
After reset, all reader ports will be disabled.
Keypad Scanning
After reset, keypad scanning will be enabled.
LCD
After reset, LCD will be initialized and the displayed contents will be cleared out; the cursor is off
and set to the upper-left corner (0, 0).
Contrast: Level 4
Backlight
After reset, the backlight settings for the keypad and LCD will be set to:
Duration: 20 seconds
Luminosity: Level 2 (= BKLIT_LO)
Shade effect: Enabled (= BKLIT_SHADE_LO for 8200/8400 Series)
LED
After reset, all the indicators will be set off and reset to default. (= LED_SYSTEM_CTRL for
8200/8400/8700 Series)
Calendar
After reset, Real Time Clock (RTC) will be set to the current time.
Others…
Allocate stack area and other parameters.
26
Chapter 2 Mobile-Specific Function Library
Note: sys_msec and sys_sec are system timers that are cleared to 0 upon powering up.
Do not write to these system timers as they are updated by the timer interrupt.
This variable governs the counter for the system to automatically shut down the user program
whenever there is no operation during the preset period.
When it is set to 0, the AUTO_OFF function will be disabled.
...
AUTO_OFF = 60; // set 1 minute
_KeepAlive__(); // load the AUTO_OFF value
...
This variable holds the frequency-duration pair of the system beep, which is the sound you hear
when entering System Menu.
The following example can be used to sound the system beep.
on_beeper(SYSTEM_BEEP);
This variable holds the backlight timer for the LCD when its backlight is set on.
By default, it is set to 20 seconds.
27
CipherLab C Programming Part I
This variable governs the timer for the IrDA connection; the system will give up trying to establish
connection with an IrDA device when the timer expires.
Possible value of this variable can be one of the following time intervals.
Value Value
1 3 seconds (Default) 5 20 seconds
2 8 seconds 6 25 seconds
3 12 seconds 7 30 seconds
4 16 seconds 8 40 seconds
These two variables govern the location of the battery icon. Once their values are changed, the
battery icon will be moved.
8000 Series: Set to (96, 51) by default.
8300 Series: Set to (120, 51) by default.
8200/8400 Series: Set to (144, 152) by default.
8500/8700 Series: Set to (144, 152) by default.
It is possible to wake up the mobile computer by one of the following pre-defined events:
28
Chapter 2 Mobile-Specific Function Library
This character array can be used to store the version information of the user program.
Such version information can be checked from the submenu: System Menu | Information.
Note that your C program needs to declare this variable to overwrite the system default setting.
For example,
const char ProgVersion[16] = “Power AP 1.00”;
29
CipherLab C Programming Part I
These routines can be used to collect information on the components, either hardware or
software, of the mobile computer.
DeviceType
30
Chapter 2 Mobile-Specific Function Library
31
CipherLab C Programming Part I
32
Chapter 2 Mobile-Specific Function Library
FontVersion
GetRFmode
Return Value The return value can be 0 ~ 8, depending on the capabilities of your mobile
computer.
Remarks Return Value
0x00 NO_RF_MODEL (8000, 8200, 8300)
0x01 MODE_433M Obsolete
0x02 MODE_24G Obsolete
0x03 Reserved
0x04 MODE_802DOT11 (8071, 8370, 8470, 8570, 8770)
0x05 MODE_BLUETOOTH (8062, 8260, 8362, 8400, 8500,
8700)
0x06 MODE_ACOUSTIC (8020, 8021)
0x07 MODE_802DOT11_GSM (8790)
0x08 MODE_802DOT11_BT (8230, 8330)
HardwareVersion
33
CipherLab C Programming Part I
KernelVersion
KeypadLayout
LibraryVersion
ManufactureDate
34
Chapter 2 Mobile-Specific Function Library
NetVersion
OriginalSerialNumber
35
CipherLab C Programming Part I
SerialNumber
36
Chapter 2 Mobile-Specific Function Library
2.1.5 SECURITY
To provide System Menu with password protection so that unauthorized users cannot
gain access to it, you may either directly enable the password protection mechanism
from System Menu or through programming. In addition, a number of security-related
functions are available for using the same password to protect your own application.
CheckPasswordActive
Purpose To check whether the system password has been applied or not.
Syntax int CheckPasswordActive (void);
Example if (CheckPasswordActive())
printf(“Please input password:”);
Return Value If applied, it returns 1.
Otherwise, it returns 0 to indicate no password is required.
Remarks By default, System Menu is not password-protected.
CheckSysPassword
Purpose To check whether the input string matches the system password or not.
Syntax int CheckSysPassword (const char *psw);
Example if (!CheckSysPassword(szInput))
printf(“Password incorrect!!!”);
Return Value If the input string matches the system password, it returns 1.
Otherwise, it returns 0.
Remarks If the system password has been applied and you want to use the same
password to protect your application, then this routine can be used to check if
the input string matches the system password.
InputPassword
Purpose To provide simple edit control for the user to input the password.
Syntax int InputPassword (char *psw);
Example char szPsw[10];
printf(“Input password:”);
if (InputPassword(szPsw))
if (!CheckSysPassword(szPsw))
printf(“Illegal password!”);
Return Value If the user input is confirmed by hitting [Enter], it returns 1.
If the user input is cancelled by hitting [ESC], it returns 0.
Remarks Instead of showing normal characters on the display, it shows an asterisk (*)
whenever the user inputs a character.
37
CipherLab C Programming Part I
SaveSysPassword
38
Chapter 2 Mobile-Specific Function Library
Program Manager, being part of the kernel, is capable of managing multiple programs
(.shx).
39
CipherLab C Programming Part I
Activate
This is furnished by calling ActivateProgram().
Upload
Program Manager menu also allows user to upload programs to another mobile computer or
host computer. Two options are provided after selecting “Upload” from the menu.
1. Upload > One Program
2. Upload > All Programs
However, if the file name (ProgVersion[ ]) of a program is prefixed with a “#” symbol, it
means the program is protected, and therefore, uploading is not allowed.
40
Chapter 2 Mobile-Specific Function Library
ActivateProgram
Purpose To make a resident program become the active program (you may clear or
keep the original file system).
Syntax void ActivateProgram (int Prog, int mode);
Parameters int Prog
1~6 (Max. 6 programs) Each stands for a resident program on
8000/8200/8300/8500/8700.
1~7 (Max. 7 programs) Each stands for a resident program on
8400.
int mode
0 KEEP_FILE_SYSTEM To keep the original file system.
1 CLEAR_FILE_SYSTEM To clear the original file system.
Example ActivateProgram(3, KEEP_FILE_SYSTEM);
// make program #3 become active and keep the file system
Return Value None
Remarks This routine copies the desired program (Prog) in flash memory from its
residence location to the active area, and thus makes it become the active
program.
The original program resided in the active area will then be replaced by the
new program.
The POWER key is disabled to protect the system while replacing the
program.
If successful, the new program will be activated immediately. However, if
the execution continues running to the next instruction, it means the
operation of this routine fails.
See Also DeleteBank, LoadProgram, ProgramInfo, ProgramManager
Purpose To delete a user program (.shx) from Program Manager (flash memory).
Syntax int DeleteBank (int slot);
Parameters int slot
1~6 (Max. 6 slots) Each stands for a resident location on
8000/8200/8300/8700.
1~7 (Max. 7 programs) Each stands for a resident program on
8400.
Example if (DeleteBank(1))
printf(“Delete OK”);
else
printf(“Delete NG”);
Return Value If successful, it returns 1.
Otherwise, it returns 0.
See Also ActivateProgram, LoadProgram, UpdateBank
41
CipherLab C Programming Part I
DownLoadProgram
42
Chapter 2 Mobile-Specific Function Library
LoadProgram
ProgramInfo
43
CipherLab C Programming Part I
ProgramManager
Purpose To enter the kernel and bring up the menu of Program Manager.
Syntax void ProgramManager (void);
Example ProgramManager(); // jump to the menu of Program Manager
UpdateBank
Purpose To copy a user program (.shx or .bin) from the file system (SRAM or SD card)
to Program Manager (flash memory).
Syntax int UpdateBank (const char *filename);
Parameters const char *filename
Pointer to a buffer where filename of the program is stored.
Example val = UpdateBank(“PlayTest”); // update bank via a file in SRAM
val = UpdateBank(“A:\\PlayTest”); // update bank via a file on SD card
Return Value If successful, it returns the residence location of program (slot 1 ~ 6 of
8000/8200/8300/8500/8700; slot 1 ~ 7 of 8400).
On error, it returns a negative value to indicate a specific error condition.
Return Value
-1 Failed to open file
-2 Invalid file format
-3 No free residence location in Program Manager
-4 No enough free flash
-5 Failed to read program code from source file
-6 Failed to erase/write flash
Remarks If the file is stored in SRAM, the file name can be 8 bytes at most, which
does not include the null character.
If the file name specified is identical to that of an existing program in flash
memory, the new program will replace the old one. Otherwise, it will be
stored in an automatically assigned residence location.
SD card is allowed only with 8200/8400/8700 Series. If the file name has a
prefix of “drive A”, such as “A:\\”, this routine will search for the file on SD
card. Refer to 2.16.2 Directory for how to specify a file path. In this case, if
the program version of the file (“ProgVersion”) is identical to that of an
existing program in flash memory, the new program will replace the old
one. Note that the file name of the specified file on SD card will be ignored!
See Also DeleteBank, DownLoadProgram, UpdateUser
44
Chapter 2 Mobile-Specific Function Library
Purpose To update the bootloader program (.shx or .bin) by copying the update from
the file system (SRAM or SD card) to the bootloader (flash memory).
Syntax int UpdateBootloader (const char *filename, int mode, int remove);
Parameters const char *filename
Pointer to a buffer where filename of the program is stored.
int mode
0 KEEP_FILE_SYSTEM To keep the SRAM file system.
1 CLEAR_FILE_SYSTEM To clear the SRAM file system.
int remove
0 To keep the program in the file system.
1 To remove the program from the file
system.
45
CipherLab C Programming Part I
UpdateKernel
Purpose To update the kernel program (.shx or .bin) by copying the update from the file
system (SRAM or SD card) to the kernel (flash memory).
Syntax int UpdateKernel (const char *filename, int mode, int remove);
Parameters const char *filename
Pointer to a buffer where filename of the program is stored.
int mode
0 KEEP_FILE_SYSTEM To keep the SRAM file system.
1 CLEAR_FILE_SYSTEM To clear the SRAM file system.
int remove
0 To keep the program in the file system.
1 To remove the program from the file
system.
Example val = UpdateKernel(“8400K100”, KEEP_FILE_SYSTEM, 0);
// update kernel via a file in SRAM
val = UpdateKernel(“A:\\8400K100”, KEEP_FILE_SYSTEM, 0);
// update kernel via a file on SD card
Return Value If successful, the device will restart itself.
On error, it returns 0~5 to indicate the error condition encountered.
Return Value
0 No file
1 Invalid file format
2 No enough free flash
3 Write flash error
4 Read file error
5 The update version is no greater than the current version.
Remarks Except for 8200/8700, downgrade is not allowed!
Except for 8200/8700, it requiress 128 KB free flash before successful
execution. You may need to delete some programs from the flash memory.
For 8200/8700, if the file is stored on SD card, it requires 1.5 MB free
SRAM file system size before successful execution. You may need to delete
some files.
If the file is stored in SRAM, the file name can be 8 bytes at most, which
does not include the null character.
SD card is allowed only with 8200/8400/8700 Series. If the file name has a
prefix of “A:\\”, this routine will search for the file on SD card.
See Also DownLoadProgram, UpdateBootloader, UpdateUser
46
Chapter 2 Mobile-Specific Function Library
UpdateUser
Purpose To make a user program (.shx or .bin), from the file system (SRAM or SD
card), become the active program.
Syntax int UpdateUser (const char *filename, int mode,…) ;
Parameters const char *filename
Pointer to a buffer where filename of the program is stored.
int mode
0 KEEP_FILE_SYSTEM To keep the original file system.
1 CLEAR_FILE_SYSTEM To clear the original file system.
int remove
0 To keep the program in the file system.
1 To remove the program from the file
system.
Example val = UpdateUser(“PlayTest”, KEEP_FILE_SYSTEM, 0);
// activate the program in SRAM, and keep the file system as well as
this program
Return Value
0 No file
1 Invalid file format
2 No enough free flash
3 File name length is out of limit
Remarks You may call UpdateUser (const char *filename, int mode) or UpdateUser
(const char *filename, int mode, int remove).
This routine copies the desired program from the file system directly to the
active area of Program Manager in flash memory, and thus makes it become
the active program. The original file system may be kept or cleared (mode). If
the file system is kept, the program may be removed from it (remove).
If the file is stored in SRAM, the file name can be 8 bytes at most, which
does not include the null character.
If the file is stored on SD card, the file name can be 64 bytes at most,
which includes the null character.
The original program resided in the active area will then be replaced by the
new program.
SD card is allowed only with 8200/8400/8700 Series. If the file name has a
prefix of “A:\\”, this routine will search for the file on SD card.
47
CipherLab C Programming Part I
While replacing the program, the POWER key is disabled to protect the
system.
If successful, the new program will be activated immediately. However, if
the execution continues running to the next instruction, it means the
operation of this routine fails.
See Also DownLoadProgram, UpdateBank
48
Chapter 2 Mobile-Specific Function Library
DownLoadPage
Purpose To stop the application and force the program to jump to System Menu for
downloading new programs.
Syntax void DownLoadPage (void);
void DownLoadPage (int detect, int comtype, int baudrate);
Example open_com(1, 0x80); // 38400, N, 8
DownLoadPage(); // enter “Download” mode
Return Value None
Remarks This routine sets the mobile computer to the “Download” mode. The “Download
Via” page will be displayed, and the user can select the COM port and baud
rate for program downloading.
It is possible to pass arguments to suppress the download submenu.
Parameter #1 (detect): The constant NO_MENU is a must.
Parameter #2 (comtype): Communication type; refer to SetCommType.
Parameter #3 (baudrate): Transmission baud rate; refer to open_com.
For example,
DownLoadPage(NO_MENU, COMM_DIRECT, BAUD_115200);
In this case, the mobile computer will be set to the “Ready to download” state
without prompting the download submenu.
49
CipherLab C Programming Part I
SMENU and MENU structures are defined in the header files. User can simply fill the
MENU structure and call prc_menu to build a hierarchy menu-driven user interface.
MENU STRUCTURE
struct SMENU {
int total_entry;
int selected_entry;
int ReturnFlag;
char* title;
struct SMENU_ENTRY* entry_list[14];
};
typedef struct SMENU MENU;
Parameter Description
int total_entry The total number of the menu entries.
1~14
int selected_entry The item number of the selected entry.
1~ total_entry
int ReturnFlag The return flag can be 0 or 1.
(1) When the return flag is 0, it will return to the current
menu after executing the function calls it contains or
pressing [ESC] to exit its sub-menus.
(2) When the return flag is 1, it will skip the current menu
after executing the function calls it contains or pressing
[ESC] to exit its sub-menus.
char* title The title of this menu.
struct SMENU_ENTRY* entry_list[14] See MENU_ENTRY Structure
MENU_ENTRY STRUCTURE
struct SMENU_ENTRY {
int text_x;
int text_y;
char* text;
void (*func) (void);
struct SMENU *sub_menu;
};
typedef struct SMENU_ENTRY MENU_ENTRY;
50
Chapter 2 Mobile-Specific Function Library
Parameter Description
int text_x X coordinate of this menu entry.
int text_y Y coordinate of this menu entry.
char* text The title of this menu entry.
Void (*func) (void) The function to be executed when this menu entry is
selected.
struct SMENU *sub_menu The sub-menu to be executed when this menu entry is
selected.
prc_menu
void FuncCollect(void)
{
// to do: add your own program code here
}
void FuncUpload(void)
{
// to do: add your own program code here
51
CipherLab C Programming Part I
}
void FuncDownload(void))
{
// to do: add your own program code here
}
void main(void)
{
// state_menu
clr_scr();
gotoxy(0, 0);
// Menu list
while (1)
{
prc_menu(&MyMenu); //* process MyMenu menu */
…
}
}
Return Value If the return flag in the MENU structure is 1, it returns 1.
Otherwise, it returns 0 to indicate the ESC key was pressed to abort operation.
Remarks This routine creates a user-defined menu. In addition to using [Up]/[Down]
and [Enter] keys to select an item, shortcut keys are provided. The first
character of each item title is treated as a shortcut key. In the above example,
1, 2, and 3 are shortcut keys for these three items (submenus) respectively.
That is, you can press [1] on the keypad to directly enter the submenu
“Collect”.
If the length of a string for a menu item exceeds the maximum characters
allowed in one line per screen, it will be divided into segments automatically.
Then, with the specified interval, these segments are displayed one by one.
For 8500/8700 Series, its touch screen functionality has each item in a
menu taken as a touchable item. That is, each item can be selected by
directly touching it. If the menu contains more than one page, there will be
a “page-up” icon in the bottom row of every page except the first one. To
go to a previous page or menu, you can touch the current menu title.
See Also GetMenuPauseTime, SetMenuPauseTime
52
Chapter 2 Mobile-Specific Function Library
GetMenuPauseTime
Purpose To get the interval value for displays of fragments of a string when using
prc_menu.
Syntax unsigned long GetMenuPauseTime (void);
Example interval = GetMenuPauseTime();
SetMenuPauseTime
Purpose To set interval between displays of fragments of a string when using prc_menu.
Syntax void SetMenuPauseTime (unsigned long time);
Parameters unsigned long time
Specify interval in units of 5 milli-seconds.
Example SetMenuPauseTime(200); // set display interval to 1 second
53
CipherLab C Programming Part I
The barcode reader module provides options for a number of scan engines as listed
below.
Scan Engine: “” means supported 8000 8200 8300 8400 8500 8700
1D CCD (linear imager)
Standard Laser
Extra Long Range Laser (ELR) --- --- --- --- ---
2D 2D imager --- ---
Below are global variables related to the barcode decoding routines. These variables are
declared by the system, and therefore unnecessary to be declared in user programs.
The operation of the Decode() routine is governed by this unsigned character array.
Refer to Appendix I and II for details of the ScannerDesTbl[] and ScannerDesTbl2[]
variables.
For 8200/8400/8500/8700 Series, only the first 45 bytes are used currently, and the rest is
reserved!
Note: For 2D or (Extra) Long Range Laser scan engine (except 8700 long range), it is
necessary to enable new settings by calling ConfigureReader().
After successful decoding, the code type (for a symbology being decoded) is stored in this variable.
54
Chapter 2 Mobile-Specific Function Library
After successful decoding, the length of the decoded data is stored in this variable.
To enable barcode decoding capability in the system, the first thing is that the scanner
port must be initialized by calling the InitScanner1() function. After the scanner port is
initialized, the Decode() function can be called in the program loops to perform barcode
decoding.
For CCD, Laser scan engine or 8700 long range, the barcode decoding routines
consist of 3 functions: InitScanner1(), Decode(), and HaltScanner1().
For 2D or (Extra) Long Range Laser scan engine (except 8700 long range), it is
necessary to enable new settings by calling ConfigureReader() before
InitScanner1().
extern unsigned char FsEAN128[2]; 8000, 8200, 8300, 8400, 8700
This global array inserted between adjacent Application ID (AID) fields as the field separator is
used for GS1 formatting.
This global array is used for indicating Application ID Mark (AID Mark). AIMark[0] will be placed at
the left of AID, and AIMark[1] at the right of AID.
Purpose To enable new settings on the scan engine according to the ScannerDesTbl
array.
Syntax int ConfigureReader (void);
Example memcpy(ScannerDesTbl, DefaultSetting, sizeof(DefaultSetting));
if (ConfigureReader())
printf(“Set OK”);
else
printf(“Set NG”);
Return Value If successful, it returns 1.
Otherwise, it returns 0.
Remarks For new settings of ScannerDesTbl to take effect on (Extra) Long Range Laser
or 2D scan engine, it is necessary to call this function.
Note that this function shall be called before InitScanner1() or after
HaltScanner1.
See Also ScannerDesTbl
55
CipherLab C Programming Part I
Decode
HaltScanner1
Return Value Once the scanner port is stopped from operating by this routine, it cannot be
restarted unless it is initialized again by calling InitScanner1().
It is recommended that the scanner port should be stopped if barcode
decoding is not required for a long period of time.
Remarks None
See Also Decode, InitScanner1
56
Chapter 2 Mobile-Specific Function Library
InitScanner1
57
CipherLab C Programming Part I
Note: For CCD or Laser scan engine, the variable OrgCodeType is provided for
identifying the original code type when a conversion has occurred.
CodeType Table I:
58
Chapter 2 Mobile-Specific Function Library
A variable, OrgCodeType, is provided for identifying the original code type when a
conversion has occurred.
OrgCodeType Table:
59
CipherLab C Programming Part I
60
Chapter 2 Mobile-Specific Function Library
Note: IATA stands for International Air Transport Association, and this barcode type is
used on flight tickets.
61
CipherLab C Programming Part I
For specific symbology parameters, refer to Appendix II. For scanner parameters, refer
to Appendix III.
62
Chapter 2 Mobile-Specific Function Library
For 8300/8500/8700 Series, it allows an optional RFID reader that can coexist with the
barcode reader, if there is any.
The RFID reader supports read/write operations, which depend on the tags you are using.
Supported labels include ISO 15693, Icode®, ISO 14443A, and ISO 14443B. The
performance of many tags has been confirmed, and the results are listed below.
Warning: Before programming, you should study the specifications of RFID tags.
Mifare Standard 1K
Mifare Standard 4K
Mifare Ultralight
TAG_SR176
SRIX 4K
SR176
TAG_ISO15693
ICODE SLI
TAG_Icode
ICODE
Note: These are the results found with RFID module version 1.0 ( for features
supported), and you may use RFIDVersion() to find out version information.
63
CipherLab C Programming Part I
The algorithm for programming the RFID reader simply follows the routines related to
COM ports. The virtual COM port for RFID is defined as COM4. Thus,
open_com (4, int) : initialize and enable the RFID COM port
(parameter int can be any integer value)
close_com (4) : terminate and disable the RFID COM port
read_com (4, char*) : read data of card from RFID COM port
write_com (4, char*) : write data of card through RFID COM port
The return values for some related functions are described below.
64
Chapter 2 Mobile-Specific Function Library
Before reading and writing a specific tag, the parameters of RFID must be specified by
calling RFIDReadFormat() and RFIDWriteFormat().
Parameter Description
unsigned char TagType[0]
TagType[4]
Bit 7 ~ 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Reserved ISO SR176 ISO Icode Tagit ISO
14443B 14443A 15693
TagType[1~3]: Reserved
unsigned int The starting byte of data for the read/write operation.
StartByte
Unsigned int Read: The maximum data length (1~255).
MaxLen
0 refers to reading UID data only.
Write: Reserved (Any integer value is acceptable.)
unsigned char Reserved
Reserve[20]
65
CipherLab C Programming Part I
66
Chapter 2 Mobile-Specific Function Library
Purpose To check the status of security key for some specific tags.
Syntax int GetRFIDSecurityKey (unsigned char TagType, unsigned char
*KeyString, unsigned char *KeyType);
Parameters unsigned char TagType
‘V’ TAG_ISO15693 Refer to the table in section 2.3 for more
information on tag types.
‘T’ TAG_Tagit
‘I’ TAG_Icode
‘M’ TAG_MifareISO14443A
‘S’ TAG_SR176
‘Z’ TAG_ISO14443B
unsigned char *KeyString
Pointer to a buffer where key value (string) is stored.
unsigned char *KeyType
Pointer to a buffer where key type is stored.
Example if (!GetRFIDSecurityKey(TAG_MifareISO14443A, key_buffer, &keytype))
{
printf(“No Sefurity Key.”);
}
Return Value If any key exists, it returns 1.
Otherwise, it returns 0.
Remarks This routine is used to find out if there is a security key for some specific tag,
such as Mifare Standard 1K/4K or SLE66R35 tag.
67
CipherLab C Programming Part I
Example SetRFIDSecurityKey(
TAG_MifareISO14443A, ‘FFFFFFFFFFFF’, MIFARE_KEYA);
// set Key A with a specified value for ISO14443A tags
Return Value None
Remarks This routine is used to set security key for some specific tags, such as Mifare
Standard 1K/4K and SLE66R35 tags.
68
Chapter 2 Mobile-Specific Function Library
For 8300 Series, it can be programmed to send data to the host through the physical
wedge interface by using the SendData() routine. SendData() is governed by a
3-element unsigned character string – WedgeSetting, which is a system-defined global
character array and must be filled with appropriate values before calling SendData().
For those that do not allow the keyboard wedge cable, alternatives are Bluetooth HID,
USB HID and the Wedge Emulator utility. Refer to the table below, 2.4.3 Wedge Emulator,
and Part II: Appendix IV Examples (Bluetooth HID and USB HID sections).
69
CipherLab C Programming Part I
The operation of the SendData routine is governed by this unsigned character array.
Purpose To check whether the keyboard wedge is ready to send data or not.
Syntax int WedgeReady (void);
Example if (WedgeReady())
SendData(CodeBuf);
Return Value If connection is OK, it returns 1.
Otherwise, it returns 0.
Remarks Before sending data via keyboard wedge, it is recommended to check if the
cable is well connected; otherwise, the transmission may be blocked.
70
Chapter 2 Mobile-Specific Function Library
71
CipherLab C Programming Part I
For example, if the terminal type is PCAT (US), then the first element of the
WedgeSetting can be defined as follows –
WedgeSetting[0] = 1
2ND ELEMENT
Alphabets’ Case
72
Chapter 2 Mobile-Specific Function Library
The setting of this bit affects the way the SendData() routine transmits alphabets. SendData()
can transmit alphabets according to their original case (case-sensitive) or just ignore it. If ignoring
case is selected, SendData() will always transmit alphabets without adding shift key.
To set “Ignore Alphabets Case”, add 32 to the value of the second element of the
WedgeSetting array.
Digits’ Position
This setting can force the SendData() routine to treat the position of the digit keys on the
keyboard differently. If this setting is set to upper, SendData() will add shift key when
transmitting digits. This setting will be effective only when the keyboard type selected is PCAT (all
available language), PS2-30, PS55, or Memorex Telex. However, if the user chooses to send digits
using numeric keypad, this setting is meaningless.
To set “Lower Position”, add 16 to the value of the second element of the WedgeSetting
array.
To set “Upper Position”, add 24 to the value of the second element of the WedgeSetting
array.
Digit Transmission
This setting instructs the SendData() routine which group of keys is used to transmit digits,
whether to use the digit keys on top of the alphabetic keys or use the digit keys on the numeric
keypad.
To set “Use Numeric Keypad to Transmit Digits”, add 2 to the value of the second element of
the WedgeSetting array.
Note: DO NOT set “Digits’ Position” and “Shift/Capital Lock Keyboard” unless you are
certain to do so.
For example, to set the inter-character delay to 10 milliseconds, the third element of the
WedgeSetting array can be defined as,
73
CipherLab C Programming Part I
The mapping of the keyboard wedge characters is as listed below. Each character in the
output string is translated by this table when the SendData() routine transmits data.
00 10 20 30 40 50 60 70 80
0 F2 SP 0 @ P ` p
1 INS F3 ! 1 A Q a q
2 DLT F4 “ 2 B R b r
3 Home F5 # 3 C S c s
4 End F6 $ 4 D T d t
5 Up F7 % 5 E U e u
6 Down F8 & 6 F V f v
7 Left F9 ‘ 7 G W g w
8 BS F10 ( 8 H X h x
9 HT F11 ) 9 I Y i y
A LF F12 * : J Z j z
B Right ESC + ; K [ k {
C PgUp Exec , < L \ l |
D CR CR* - = M ] m }
E PgDn . > N ^ n ~
F F1 / ? O _ o Dly ENTER*
The SendData() routine can not only transmit simple characters as shown above, but
also provide a way to transmit combination key status, or even direct scan codes. This is
done by inserting some special command codes in the output string. A command code is
a character whose value is between 0xC0 and 0xFF.
0xC0 : Indicates that the next character is to be treated as scan code. Transmit it as it is,
no translation required.
74
Chapter 2 Mobile-Specific Function Library
0xC0 | 0x20 : Clear all combination status key after sending the next character.
For example, to send [A] [Ctrl-Insert] [5] [scan code 0x29] [Tab] [2] [Shift-Ctrl-A] [B]
[Alt-1] [Alt-2-Break] [Alt-1] [Alt-3], the following characters are inserted into the string
supplied to the SendData() routine.
0x41, 0xC2, 0x01, 0x35, 0xC0, 0x29, 0x09, 0x32, 0xC3, 0x41, 0x42, 0xC4, 0x31
0xE4, 0x32, 0xC4, 0x31, 0xC4, 0x33
Note: (1) The scan code 0x29 is actually a space for PCAT, Alt-12 is a form feed
character, and Alt-13 is an Enter. (2)
The break after Alt-12 is necessary, if omitted the characters will be treated as Alt-1213
instead of Alt-12 and Alt-13.
75
CipherLab C Programming Part I
Note: Alternatively, you may use Bluetooth HID for a wedge application on the
Bluetooth-enabled mobile computers, or USB HID for 8200/8400/8700 Series.
76
Chapter 2 Mobile-Specific Function Library
2.5 BUZZER
This section describes the routines manipulating the buzzer. The activation of the buzzer
is conducted by specifying a beep sequence, which comprises a number of beep
frequency and beep duration pairs. Once on_beeper() or play() is called, the activation
of the buzzer is automatically handled by the background operating system. There is no
need for the application program to wait for the buzzer to stop. Yet, beeper_status()
and off_beeper() are used to determine whether a beep sequence is undergoing or is to
be terminated immediately.
A beep sequence is an integer array that is used to instruct how the buzzer is activated.
It comprises a number of pairs of beep frequency and duration. Each pair is one beep.
A beep frequency is an integer that is used to specify the frequency (tone) of the buzzer
when it is activated. However, the value of the beep frequency is not the actual
frequency that the buzzer generates. It is calculated by the following formula:
For example, if a frequency of 4 KHz is desired, the value of beep frequency should be 19.
Suitable frequency range is from 1 KHz to 6 KHz, whereas the peak is at 4 KHz. If no
sound is desired (pause), the beep frequency should be set to 0.
Note: A beep sequence with frequency set to 0 causes the buzzer to pause, not to stop.
Beep duration is an integer that is used to specify how long a buzzer will be working at a
specified beep frequency; it is specified in units of 0.01 second. To have the buzzer work
for one second, the beep duration should be set to 100.
Note: When the value of beep duration is set to 0, it will end a beep sequence; the
buzzer will stop working.
77
CipherLab C Programming Part I
beeper_status
78
Chapter 2 Mobile-Specific Function Library
on_beeper
Purpose To specify a beep sequence of how a buzzer works, or to play a wave table (for
8200 only).
Syntax void on_beeper (const int *sequence); // 8000, 8300, 8400, 8500, 8700
unsigned char on_beeper (const void *buffer); // 8200 only
Parameters const int *sequence
Pointer to a buffer where a beep sequence is stored.
const void *buffer
Pointer to a buffer where
(1) a beep sequence is stored, or
(2) a wave table is stored, or
(3) the file name of a wave file on SD card is stored. Filename needs to have
a prefix, such as “A:\\”, “a:\\”, “A:/”, or “a:/”.
Example (1) const int two_beeps [] = {19, 10, 0, 10, 19, 10, 0, 0};
on_beeper(two_beeps);
Example (2) on_beeper(“A:\\Sound.wav”); // play a wave file from SD card on 8200
Return Value For 8200 Series, the return value can be one of the following:
Return Value
0 Success
1 Invalid file format
2 Fail to open file on SD Card
Remarks This routine specifies a beep sequence to instruct how a buzzer works. If there
is a beep sequence already in progress, the later will override the original one.
For 8200, the supported audio file format is *.wav files, which meet the
following requirements:
NumChannels: mono or stereo
SampleRate: 8000, 11025, 22050, 32000, 44100
BitsPerSample: 8 bits or 16 bits
off_beeper
79
CipherLab C Programming Part I
play
Bit 7 6 5 4 3 2 1 0
Reserved Frequency for A (La) Scale # key Musical Scale
000: Reserved 0: disable 000: Reserved
001(1): 55 Hz 1: enable 001(1): Do
010(2): 110 Hz 010(2): Re
011(3): 220 Hz 011(3): Mi
100(4): 440 Hz 100(4): Fa
101(5): 880 Hz 101(5): So
110(6): 1760 Hz 110(6): La
111(7): 3520 Hz 111(7): Ti
80
Chapter 2 Mobile-Specific Function Library
In general, the dual-color LED indicator or indicators on the mobile computer are used to
indicate the system status, such as good read or bad read, error occurrence, etc.
set_led
81
CipherLab C Programming Part I
This section describes the routines for configuring the vibrator and heater.
2.7.1 VIBRATOR
82
Chapter 2 Mobile-Specific Function Library
2.7.2 HEATER
GetHeaterMode 8500
SetHeaterMode 8500
83
CipherLab C Programming Part I
2.8.1 CALENDAR
The system date and time are maintained by the calendar chip, and they can be retrieved
from or set to the calendar chip by the get_time() and set_time() functions. A backup
rechargeable Lithium battery keeps the calendar chip running even when the power is
turned off.
The calendar chip automatically handles the leap year. The year field set to the
calendar chip must be in four-digit format.
Note: The system time variable sys_msec and sys_sec is maintained by CPU timers
and has nothing to do with this calendar chip. Accuracy of these two time variables
depends on the CPU clock and is not suitable for precise time manipulation. They are
reset to 0 upon powering up.
DayOfWeek
get_time
Purpose To get the current date and time from the calendar chip.
Syntax void get_time (char *cur_time);
Parameters char *cur_time
Pointer to a buffer where the system date and time is stored.
The character array cur_time allocated must have a minimum of 15 bytes
to accommodate the date, time, and the string terminator.
The format of the system date and time is “YYYYMMDDhhmmss”.
Example get_time(system_time);
84
Chapter 2 Mobile-Specific Function Library
set_time
85
CipherLab C Programming Part I
2.8.2 ALARM
86
Chapter 2 Mobile-Specific Function Library
This section describes the power management functions that can be used to monitor the
voltage level of the main and backup batteries. The mobile computer is equipped with a
main battery for normal operation as well as a backup battery for keeping SRAM data
and time accuracy.
get_vmain
Purpose To get the voltage level of the main battery, in units of mV.
Syntax int get_vmain (void);
Example if (get_vmain() < 2200) // alkaline battery
puts(“Battery is low.”);
get_vbackup
Purpose To get the voltage level of the backup battery, in units of mV.
Syntax int get_vbackup (void);
Example bat1 = get_vbackup();
87
CipherLab C Programming Part I
charger_status
Return Value
0 CHARGE_STANDBY Not connected to any external power.
1 CHARGING_5V The battery is being charged via 5V power cord.
2 CHARGE_DONE The battery is fully charged.
3 CHARGE_FAIL Battery charging fails.
17 CHARGING_USB The battery is being charged via USB.
For 8500 Series, the return value can be one of the following:
Return Value
0 CHARGING The battery is being charged.
1 CHARGE_DONE The battery is fully charged.
2 CHARGE_FAIL Battery charging fails.
3 CHARGE_STANDBY Not connected to any external power.
See Also GetUSBChargeCurrent, SetUSBChargeCurrent
88
Chapter 2 Mobile-Specific Function Library
Purpose To get the charging current via USB port on the mobile computer.
Syntax int GetUSBChargeCurrent (void) ;
Example val = GetUSBChargeCurrent(); // get charging setting
Purpose To set the charging current via USB port on the mobile computer.
Syntax void SetUSBChargeCurrent (int current_type) ;
Parameters int current_type
0 CURRENT_500mA Set charging at 500 mA.
1 CURRENT_100mA Set charging at 100 mA (8200/8400 only)
2 CURRENT_0mA Disable charging (8200/8700 only)
Example SetUSBChargeCurrent(CURRENT_500mA); // set 500 mA for USB charging
89
CipherLab C Programming Part I
2.10 KEYPAD
The background routine constantly scans the keypad to check if any key is being pressed.
There is a keyboard buffer of size 32 bytes. However, if the buffer is full, the keystrokes
followed will be ignored. Normally, a C program needs constantly to check if any
keystroke is available in the buffer.
2.10.1 GENERAL
CheckKey
Purpose To detect whether the specified keys have been pressed simultaneously or not.
Syntax int CheckKey (const int scan_code,...);
Parameters Specify the scan codes of the keys as many as you like, but be sure to specify
the type as the last parameter. There are two types:
int LastIsType
-1 CHK_EXC Exclusive checking – only the keys being pressed match the
keys specified, will the function return 1.
-2 CHK_INC Inclusive checking – as long as the keys being pressed
include the keys specified, this function will return 1.
90
Chapter 2 Mobile-Specific Function Library
clr_kb
getchar
Purpose To read one character from the keyboard buffer and then remove it.
Syntax int getchar (void);
Example c = getchar();
if (c > 0)
printf(“Key %d pressed.”, c);
else
printf(“No key pressed.”);
Return Value If successful, it returns the character read from the keyboard buffer.
Otherwise, it returns 0 to indicate the keyboard buffer is already empty.
Remarks This routine can be used with menu operation to detect a shortcut key being
pressed, or with touch screen operation to detect a touched item.
See Also clr_kb, kbhit, putch
91
CipherLab C Programming Part I
GetKBDModifierStatus
92
Chapter 2 Mobile-Specific Function Library
GetKeyClick
Return Value If key click is enabled, it returns 1~5 to indicate different tones.
Otherwise, it returns 0.
Remarks The key click is set to be enabled by default, but it can be changed from
System Menu or through programming.
See Also SetKeyClick
kbhit
Return Value If any key is pressed, it returns 1 to indicate a character is put in the keyboard
buffer.
Otherwise, it returns 0 to indicate the buffer is empty.
See Also clr_kb, getchar
Return Value If successful, it returns the character read from the keyboard buffer.
Otherwise, it returns a null character (0x00) to indicate the buffer is empty.
Remarks This routine provides the capability to simulate the keypad operation.
For example, it can be implemented with touch screen operation. The key value
of a touched item, which is designed as a key on the screen, can be put to the
keyboard buffer by putch. It can then be detected by using getchar().
See Also clr_kb, getchar
93
CipherLab C Programming Part I
SetKeyClick
TriggerStatus
Purpose To check whether the SCAN key has been pressed or not.
Syntax int TriggerStatus (void);
Example if (TriggerStatus())
printf(“Scan key is pressed.”);
Return Value If the SCAN key is pressed, it returns 1.
Otherwise, it returns 0.
SetTrigger 8000,8200,8400,8700
OSKToggle 8000,8200,8400,8700
94
Chapter 2 Mobile-Specific Function Library
dis_alpha
en_alpha
95
CipherLab C Programming Part I
get_alpha_enable_state
Return Value
-1 No ALPHA key available on 8500, 44-key (Type I).
0 The ALPHA key is disabled, resulting from dis_alpha() and
LockAlphaState().
1 The ALPHA key is enabled and the keypad behavior is set to
ALPHA_FIXED, resulting from en_alpha().
2 The ALPHA key is enabled and the keypad behavior is set to
ALPHA_ROLLING, resulting from en_alpha().
Remarks By default, the ALPHA key is enabled.
get_alpha_lock_state
Purpose To get information of the ALPHA state for input mode, locked or unlocked.
Syntax int get_alpha_lock_state (void);
Example state = get_alpha_lock_state();
Return Value
-1 No ALPHA key available on 8500, 44-key (Type I).
0 Numeric mode
1 Upper case alpha mode
2 Lower case alpha mode
3 Function mode (8000, 8200 only)
Remarks This routine gets the current state of input mode, resulting from either
LockAlphaState() or set_alpha_lock().
96
Chapter 2 Mobile-Specific Function Library
LockAlphaState
Purpose To set the ALPHA state for input mode and lock (= disable) the ALPHA key.
Syntax void LockAlphaState (int state);
Parameters int state
0 NUMERIC_KAYPAD Locked to numeric mode
1 UPPER_CASE Locked to upper case alpha mode
2 LOWER_CASE Locked to lower case alpha mode
3 FUNCTION_KEY Locked to function mode
(8000, 8200 only)
set_alpha_lock
97
CipherLab C Programming Part I
The SHIFT key is a modifier key that converts the alphabets from upper case to lower
case. Here are the functions to set or get its status.
Note: The SHIFT key is available on the 8500 44-key (Type I) mobile computer only.
get_shift_lock_state 8500
Return Value The return value can be 0 ~ 3. However, it returns -1 for 8500 Series 24-key
and 44-TE key (Type II) because of no SHIFT key.
set_shift_lock 8500
98
Chapter 2 Mobile-Specific Function Library
The ALT key serves as a modifier key. Here are the functions to set or get its status.
Note: The ALT key is available on the 8500 44-key (Type I) or 8500/8700 44-TE (Type II)
key mobile computer.
Return Value The return value can be 0 ~ 3. However, it returns -1 for 8500/8700 Series
24-key because of no ALT key.
99
CipherLab C Programming Part I
2.10.5 FN KEY
The function (FN) key serves as a modifier key used to produce a key combination.
1) To enable this modifier key, press the function (FN) key on the keypad, and the
status icon “ ” will be displayed on the screen.
2) Press another key to get the value of the key combination (say, F1), and the status
icon will go off immediately when the function (FN) key is set to Auto Resume mode
by SetFuncToggle(). That is, this modifier key can work one time only.
3) To get the value of another key combination, repeat the above steps.
However, on condition that the function (FN) key is set to Toggle mode by
SetFuncToggle(), this modifier key can work as many times as desired until it is
pressed again to exit the function mode.
100
Chapter 2 Mobile-Specific Function Library
int state
0 Auto Resume mode + Multi-Key mode (default)
1 Toggle mode + Multi-Key mode
For (1) 8400 Series, 24-key and 39-key (2) 8500/8700 Series, 44-key Type II:
int state
0 Auto Resume mode + Multi-Key mode (default)
1 Toggle mode + Multi-Key mode
2 Auto Resume mode + Multi-Key mode + FN as normal key
3 Toggle mode + Multi-Key mode + FN as normal key
4 Multi-Key mode
6 Multi-Key mode + FN as normal key
101
CipherLab C Programming Part I
By default, F1~F8 are available on on 8400 Series, 29-key. However, you may use key
combinations for F9~F20 after SetFuncExtKey(1) is called.
GetFuncExtKey 8400
Purpose To check whether the extended function keys F9~F20 are enabled.
Syntax int GetFuncExtKey (void);
Example state = GetFuncExtKey;
SetFuncExtKey 8400
102
Chapter 2 Mobile-Specific Function Library
The yellow key on the 8200 mobile computer is set to work as the ENTER key by default,
which is identified as the “middle” ENTER key.
After InitScanner1() is called, the yellow key works as the SCAN key.
After HaltScanner1() is called, the yellow key works as the ENTER key again.
CheckKeyEnter 8200, 8700
Return Value
0 No ENTER key is being pressed.
1 Right ENTER key is being pressed.
2 Left ENTER key is being pressed.
3 Middle ENTER key is being pressed. (8200/8400/8700 only)
4 Pistol ENTER key is being pressed. (8200/8700 only)
Remarks This function shall be called after getchar().
Purpose To enable or disable using the yellow SCAN key as ENTER key.
Syntax void SetMiddleEnter (int state) ;
Parameters int state
0 Disable middle ENTER key (Default for 8400/8700)
1 Enable middle ENTER key (Default for 8200)
Example SetMiddleEnter(1);
103
CipherLab C Programming Part I
Example SetPistolEnter(1);
2.11 LCD
The liquid crystal display (LCD) on the mobile computer is FSTN graphic display. The
display capability may vary due to the size of LCD panel. A coordinate system is used for
the cursor movement routines to determine the cursor location — (x, y) indicates the
column and row position of cursor. The coordinates given to the top left point is (0, 0),
while those of the bottom right point depends on the size of LCD and font. For displaying
a graphic, the coordinate system is on dot (pixel) basis.
2.11.1 PROPERTIES
DecContrast
104
Chapter 2 Mobile-Specific Function Library
IncContrast
GetContrast
Return Value It returns the current contrast level, ranging from 0 to 7. (0 to 5 for 8200)
Remarks This routine indicates the current contrast level of the LCD, which is set to 4 by
default.
SetContrast
GetVideoMode
105
CipherLab C Programming Part I
SetVideoMode
106
Chapter 2 Mobile-Specific Function Library
GetBklitLevel 8200,8400,8700
SetBklitLevel 8200,8400,8700
107
CipherLab C Programming Part I
SetAutoBklit 8200,8400,8700
Purpose To set automatic backlight. Backlight turns on when any key is pressed.
Syntax void SetAutoBklit(int mode);
Example SetAutoBklit(1);
Parameters int mode
0 Disable (default)
1 Enable
lcd_backlit
108
Chapter 2 Mobile-Specific Function Library
Parameters For 8000/8300 Series, the parameter state can be one of the following:
int state
0 BKLIT_OFF Backlight off
1 BKLIT_LO Backlight on
For 8200 Series, the parameter state can be one of the following:
int state
0 BKLIT_OFF Backlight off
1 BKLIT_ON Backlight on
For 8400 Series, the parameter state can be one of the following:
int state
0x0000 BKLIT_OFF Backlight off
0x0001 BKLIT_VERY_LO Backlight with very low luminosity
0x0002 BKLIT_LO Backlight with low luminosity
0x0003 BKLIT_MED Backlight with medium luminosity
0x0004 BKLIT_HI Backlight with high luminosity
0x0010 BKLIT_SHADE_OFF SHADE effect on and Backlight off
0x0011 BKLIT_SHADE_VL SHADE effect on and Backlight with very
low luminosity
0x0012 BKLIT_SHADE_LO SHADE effect on and Backlight with low
luminosity
0x0013 BKLIT_SHADE_MED SHADE effect on and Backlight with
medium luminosity
0x0014 BKLIT_SHADE_HI SHADE effect on and Backlight with high
luminosity
For 8500/8700 Series, the parameter state can be one of the following:
int state
0 BKLIT_OFF Backlight off
1 BKLIT_VERY_LO Backlight with very low luminosity
2 BKLIT_LO Backlight with low luminosity
3 BKLIT_MED Backlight with medium luminosity
4 BKLIT_HI Backlight with high luminosity
Example lcd_backlit(1); // turn on LCD backlight, low density
109
CipherLab C Programming Part I
Purpose To provide the use of combination keys to control the LCD backlight.
Syntax void SetBklitControl (int mode);
Parameters For 8200/8400 Series, the parameter can be one of the following:
int mode
(the backlight key is for 29-key and for 39-key)
0 Key combination [Backlight] + [↑]/[↓] disabled
1 Key combination [Backlight] + [↑]/[↓] enabled
2 Key combination [Backlight] + [↑]/[↓] disabled
+ Backlight key as normal key
3 Key combination [Backlight] + [↑]/[↓] enabled
+ Backlight key as normal key
For 8500/8700 Series, the parameter can be one of the following:
int mode
0 Key combination FN + [←]/[→] disabled
1 Key combination FN + [←]/[→] enabled
Example SetBklitControl(0);
// disable the key combination for Backlight Control
Return Value None
Remarks This routine determines whether the LCD backlight can be adjusted by pressing
the combination keys.
When enabled on 8200/8400 Series, press [Backlight] + [↑] simultaneously
for higher luminosity and [Backlight] + [↓] simultaneously for lower
luminosity.
When disabled on 8200/8400 Series, the key values KEY_BUP or
KEY_BDOWN will be stored in keyboard buffer.
For 8200/8400, Backlight key as normal key — The key is treated as a
normal key.
When enabled on 8500/8700 Series, press FN + [→] simultaneously for
higher luminosity and FN + [←] simultaneously for lower luminosity.
When disabled on 8500/8700 Series, the key values KEY_FLEFT or
KEY_FRIGHT will be stored in keyboard buffer.
See Also lcd_backlit
110
Chapter 2 Mobile-Specific Function Library
SetContrastControl
Purpose To provide the use of combination keys to control the LCD contrast.
Syntax void SetContrastControl (int mode);
Parameters For 8000/8300/8500/8700 Series, the parameter can be one of the following:
int mode
0 Key combination FN + [↑]/[↓] disabled
(For 8500/8700 44-TE key, FN + [3]/[6] disabled)
1 Key combination FN + [↑]/[↓] enabled
(For 8500/8700 44-TE key, FN + [3]/[6] enabled)
Example SetContrastControl(0);
// disable the key combination for Contrast Control
Return Value None
Remarks This routine determines whether the LCD contrast can be adjusted by pressing
the combination keys.
When enabled on 8000/8300/8500/8700 Series, press FN + [↑]
simultaneously for higher contrast and FN + [↓] simultaneously for lower
contrast.
When disabled on 8000/8300/8500/8700 Series, the key values KEY_FUP
or KEY_FDOWN will be stored in keyboard buffer.
When enabled on 8200/8400 Series, press [Backlight] + [→]
simultaneously for higher contrast and [Backlight] + [←] simultaneously
for lower contrast.
When disabled on 8200/8400 Series, the key values KEY_BLEFT or
KEY_BRIGHT will be stored in keyboard buffer.
See Also DecContrast, GetContrast, IncContrast, SetContrast
111
CipherLab C Programming Part I
2.11.2 CURSOR
GetCursor
Purpose To check whether the cursor indication on the LCD is visible (On) or not (Off).
Syntax int GetCursor (void);
Example if (GetCursor() == 0)
puts(“Cursor Off”);
Return Value If visible, it returns 1.
Otherwise, it returns 0.
SetCursor
Purpose To determine whether the cursor indication on the LCD is visible (On) or not
(Off).
Syntax void SetCursor (int cursor);
Parameters int cursor
0 CURSOR_OFF Hide cursor (Off)
1 CURSOR_ON Display cursor (On)
gotoxy
Example gotoxy(10, 0)
// move the cursor to the 11th column of the first line
Return Value None
Remarks This routine moves the cursor to a new position whose (X, Y) coordinates are
specified in the argument x_position and y_position.
Depending on the following elements, the maximum values for coordinates are
limited:
The printing of characters in the icon area, which is determined by
ICON_ZONE().
The size of LCD.
The font file in use.
For 8500/8700 Series, the y coordinate cannot be over 18 with font size 6x8
and ICON_ZONE(0) is given.
See Also wherexy
112
Chapter 2 Mobile-Specific Function Library
wherex
wherexy
wherey
113
CipherLab C Programming Part I
2.11.3 DISPLAY
fill_rect
114
Chapter 2 Mobile-Specific Function Library
ICON_ZONE
Example ICON_ZONE(1);
115
CipherLab C Programming Part I
printf
Purpose To write character strings and values of C variables in a specified format to the
LCD.
Syntax int printf (char *format, var...);
Parameters char *format
Character string that describes the format to be used.
Var...
Any variable whose value is being printed on the LCD.
Example pritnf(“ID:%s”, id_buffer);
Return Value It returns the character count that sent to the LCD.
Remarks This routine accepts any variable and prints its value to the LCD. The value of
each variable is formatted according to the codes embedded in the format
specification format.
To print values of C variables, a format specification must be embedded in
format for each variable to be printed. The format specification for each
variable has the following form:
%[flags][width].[precision][size][type]
Field Explanation
% Indicates the beginning of a format specification. Use %% to print
(required) a percentage sign.
Flags One of more of the ‘-‘, ‘+’, ‘#’ characters or a blank space
(optional) specifies justification, and the appearance of plus/minus signs in
the values printed.
- Left justify output value. The default is right justification.
+ If the output value is a numerical one, print a ‘+’ or
‘-‘ character according to the sign of the value. A
‘-‘ character is always printed for a negative value no
matter this flag is specified or not.
Blank Positive numerical values are prefixed with blank spaces.
This flag is ignored if the + flag also appears.
# When used in printing variables of type o, x, or X (see
below), non-zero output values are prefixed with 0, 0x,
or 0X respectively.
116
Chapter 2 Mobile-Specific Function Library
117
CipherLab C Programming Part I
putchar
puts
118
Chapter 2 Mobile-Specific Function Library
WaitHourglass
119
CipherLab C Programming Part I
2.11.4 CLEAR
clr_eol
Purpose To clear from where the cursor is to the end of the line, and then move the
cursor to its original position.
Syntax void clr_eol (void);
Example clr_eol();
clr_icon
clr_rect
120
Chapter 2 Mobile-Specific Function Library
clr_scr
121
CipherLab C Programming Part I
2.11.5 IMAGE
The show_image() function can be used to display images on the LCD. The user needs
to allocate an unsigned char array to store the bitmap data of the image. This array
begins with the top row of pixels. Each row begins with the left-most pixels. Each bit of
the bitmap represents a single pixel of the image. If the bit is set to 1, the pixel is
marked, and if it is 0, the pixel is unmarked.
The 1st pixel in each row is represented by the least significant bit of the 1st byte in each
row. If the image is wider than 8 pixels, the 9th pixel in each row is represented by the
least significant bit of the 2nd byte in each row.
The following is an example to show our company logo, and the static unsigned char
array is used for storing its bitmap data.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00,
0x00, 0x00, 0xfc, 0xff, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x0b, 0x00, 0x00, 0x00,
0x00, 0xfc, 0xff, 0x0b, 0x80, 0x07, 0x00, 0x00, 0xf4, 0xff, 0x0b, 0xc0, 0xac, 0x93, 0x77,
0xf4, 0x1d, 0x0b, 0x60, 0xa0, 0x94, 0x90, 0xf4, 0xda, 0x0a, 0x20, 0xa0, 0x94, 0x90, 0xf4,
0xda, 0x0a, 0x20, 0xa0, 0xf3, 0x77, 0x74, 0x17, 0x0b, 0x60, 0xa8, 0x90, 0x30, 0x74, 0xd0,
0x0a, 0xc0, 0xac, 0x90, 0x50, 0x74, 0xd7, 0x0a, 0x80, 0xa7, 0x90, 0x97, 0x04, 0x17, 0x0b,
0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00,
0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00};
122
Chapter 2 Mobile-Specific Function Library
get_image
show_image
123
CipherLab C Programming Part I
2.11.6 GRAPHICS
SHAPE_NORMAL
124
Chapter 2 Mobile-Specific Function Library
circle
line
125
CipherLab C Programming Part I
putpixel
rectangle
int X2, Y2
(X, Y) coordinates of the ending point of a diagonal.
int type
0 SHAPE_NORMAL Hollow object
1 SHAPE_FILL Solid object
int mode
-1 DOT_REVERSE Dot in Reverse mode
0 DOT_CLEAR Dot being cleared
1 DOT_MARK Dot being marked
126
Chapter 2 Mobile-Specific Function Library
For 8500/8700 Series, the liquid crystal display (LCD) is also a touch screen when it is
initialized by InitTouchScreen().
Signature Capture
Use the stylus to write anything directly on a specific area of the LCD, which is
defined by SignatureCapture(). Then, the signature can be captured by
GetScreenItem().
Touchable Items
Graphic items can be designed to simulate a key operation when being touched, e.g.
a calculator. The information of “graphic items” (buttons), including position and size,
has to be defined in advance through the data structure ItemProperty.
Patterns of the graphic items can be designed and displayed on the LCD by
show_image(). Then, these items can be utilized and detected by
GetScreenItem().
If the display mode for a selected item is set to ITEM_REVERSE, the item will be
displayed in a reverse color once it is touched.
On the contrary, if it is set to ITEM_NORMAL, there will be no changes happening to
the item once it is touched.
typedef struct {
int UppLeftX;
int UppLeftY;
int SizeX;
int SizeY;
} ItemProperty;
Item Description
int UppLeftX X coordinate of the upper left corner of the item
int UppLeftY Y coordinate of the upper left corner of the item
int SizeX Width of the item, in dots
int SizeY Height of the item, in dots
127
CipherLab C Programming Part I
Purpose To get the position of the starting and ending points for any movement on the
touch screen.
Syntax int GetPoint (int *DownX, int *DownY, int *UpX, int *UpY);
Parameters int DownX, DownY
(X, Y) coordinates of the starting point.
int UpX, UpY
(X, Y) coordinates of the ending point.
Example val = GetPoint(&dX, &dY, &uX, &uY);
Purpose To detect and return an item number when an item is selected, or detect and
show any writing on the signature capture area.
Syntax int GetScreenItem (ItemProperty *Item, int TotalItems, int mode);
Parameters ItemProperty *Item
The list of size information of items.
int TotalItems
The amount of items.
int mode
0 ITEM_NORMAL A touched item will be displayed normally.
1 ITEM_REVERSE A touched item will be displayed in a reverse color.
128
Chapter 2 Mobile-Specific Function Library
Purpose To define a signature capture area on the touch screen. User may use the
stylus to freely write or draw on this area.
Syntax void SignatureCapture (int UppLeftX, int UppLeftY, int LowRightX, int
LowRightY)
Parameters int UppLeftX, UppLeftY
(X, Y) coordinates of the upper left corner of the area.
int LowRightX, LowRightY
(X, Y) coordinates of the lower right corner of the area.
129
CipherLab C Programming Part I
2.12.2 EXAMPLE
130
Chapter 2 Mobile-Specific Function Library
2.13 FONTS
Basically, the mobile computer allows two font size options for the system font: 6x8 and
8x16. These options are also applicable to other alphanumerical font files (for single byte
languages), such as the multi-language font file and Hebrew/Nordic/Polish/Russian font
files.
Varying by the screen size and the font size of alphanumeric characters, the display
capability can be viewed by lines and characters (per line) as follows.
Note: For 8200/8400/8500/8700, it can display up to 20 (or 10) lines when the icon
area is not available for displaying the battery icon, etc. (= ICON_ZONE enabled)
131
CipherLab C Programming Part I
The multi-language font file includes English (default), French, Hebrew, Latin, Nordic,
Portuguese, Turkish, Russian, Polish, Slavic, Slovak, etc. To display in any of these
languages except English, you need to call SetLanguage() to specify the language by
region.
Fonts with file name specifying Tc12 (Traditional Chinese), Sc12 (Simplified Chinese),
Jp12 (Japanese), or Kr12 (Korean) are referred to as the special font files. This is
because their font size for alphanumeric characters must be determined by SetFont(),
either 6x12 or 12x12. Otherwise, the characters cannot be displayed properly.
CheckFont
132
Chapter 2 Mobile-Specific Function Library
GetFont
133
CipherLab C Programming Part I
SetFont
Purpose To select a font size for the LCD to display alphanumeric characters properly.
Syntax void SetFont (int font);
Parameters int font
FONT_6X8 6x8 graphic dots per character
FONT_8X16 8x16 graphic dots per character
FONT_6X12 6x12 graphic dots per character
FONT_12X12 12x12 graphic dots per character
FONT_12X16 12x16 graphic dots per character
FONT_10X20 10x20 graphic dots per character
Example SetFont(FONT_8X16);
134
Chapter 2 Mobile-Specific Function Library
SetLanguage
Purpose To select which language is to be used from the multi-language font file.
Syntax void SetLanguage (int setting);
Parameters int setting
0x10 English_437 English (default)
0x11 French_863 Canadian French
0x12 Hebrew_862 Hebrew
0x13 Latin_850 Multilingual Latin I
0x14 Nordic_865 Nordic
0x15 Portugal_860 Portuguese
0x16 CP_1251 Cyrillic (Russian)
0x17 CP_852 Latin II (Slavic)
0x18 CP_1250 Central European, Latin II (Polish)
0x19 Turkish_857 Turkish
0x1a Latin_II Latin II (Slovak)
0x1b WIN1250 Windows 1250
0x1c ISO_28592 ISO-28592 (Latin 2)/ISO 8859-2
0x1d IBM_LATIN_II IBM-LATIN II
0x1e Greek_737 Greek
0x1f CP_1252 Latin I
0x20 CP_1253 Greek
0x21 CP_1254 Turkish (for 8200/8400/8700)
Example SetLanguage(0x14); // choose the Nodic font
135
CipherLab C Programming Part I
Note: The above font files have been recompiled to support 2 MB flash memory and
renamed accordingly.
136
Chapter 2 Mobile-Specific Function Library
137
CipherLab C Programming Part I
2.14 MEMORY
This section describes the routines related to the flash memory and SRAM, where
Program Manager and File System reside respectively.
2.14.1 FLASH
The flash memory is divided into a number of memory banks, and each bank is 64 KB.
Note: (1) Up to 256 records can be saved. The flash memory can only be erased on a
bank basis, that is, all the records stored in 0xF60000 ~ 0xF6FFFF will be gone. (2)
For 8400, the system reserves 6 banks (0xF00000~0xF5FFFF) for future use.
8200, 8700
The kernel itself takes 22 banks, and the system reserves banks (0xF60000~0xF6FFFF,
0x800000~0xBFFFFF) for data storage, such as the application settings. The rest banks are
available for storing user programs as well as font files.
User program location in flash: 0xC00000~0xDFFFFF
Kernel location in flash:0xE00000~0xF5FFFF
Bootloader location in flash: 0xFF0000~0xFFFFFF
138
Chapter 2 Mobile-Specific Function Library
EraseSector
FlashSize
Purpose To get the size of the flash memory (for storing user programs).
Syntax int FlashSize (void);
Example FlashSize();
Return Value This routine returns the size of the flash memory in kilobyte.
WriteFlash
139
CipherLab C Programming Part I
2.14.2 SRAM
The File System keeps user data in SRAM, which is maintained by the backup battery.
However, data loss may occur during low battery condition or when the battery is drained.
It is necessary to upload data to a host computer before putting away the mobile
computer.
free_memory
Return Value This routine returns the size of the free memory in byte.
Remarks This routine gets the amount of free (unused) memory of the file space.
init_free_memory
RamSize
Purpose To get the size of data memory (SRAM) for storing data files.
Syntax int RamSize (void);
Example RamSize();
140
Chapter 2 Mobile-Specific Function Library
2.14.3 SD CARD
Purpose To get the volume of SD card, excluding the space used by FAT structure.
Syntax long fsize (void) ;
Example long size;
if ((size = fsize()) == -1L)
printf(“Get card size failed!”);
Return Value If successful, it returns a long integer containing the number of free kilobytes
on SD card.
On error, it returns -1L. The global variable ferrno is set to indicate the error
condition encountered.
141
CipherLab C Programming Part I
There are many file manipulation routines available for programming the mobile
computers. These routines help manipulate the transaction data and ease the
implementation of database system.
Sequential structure called DAT file that is usually used to store transaction data.
Index structure is usually used to store lookup data. Actually, there are two types of
index file. One is DBF for storing the original data records (data members), and the
other is IDX for sorting the records according to the associate key.
These two file structures will be further discussed later in this section.
For 8200/8400/8700, it supports SD card, on which you may store DAT files, as well as
DBF and IDX files. Refer to 2.16 SD Card.
On each mobile computer, on-board SRAM is provided for data memory. This is the place
where all the system parameters, program variables, program stack, and file system
resides.
2.15.2 DIRECTORY
The file system is flat, that is, it does not support hierarchical tree directory structure,
and no sub-directory can be created. There is a limit for the total number of files, which
includes all DAT files as well as DBF files and their associated IDX files. To get the
information of the file directory, you can call filelist().
A file name is a null terminated character string containing 1 ~ 8 characters (the null
character not included), which is used to identify the file in the system. There is no file
extension as in MS-DOS operation system. The file name can be changed later by calling
rename().
If a file name specified is longer than eight characters, it will be truncated to eight
characters.
The file name is case-sensitive.
142
Chapter 2 Mobile-Specific Function Library
File handle is the identification of a file after the file is opened. Most of the file
manipulation functions need file handles instead of file names when calling them.
A file handle is a positive integer (greater than zero) that is returned from the system
when a file is created or opened. All subsequent file operations can then use the file
handle to identify the file.
A system variable “fErrorCode” is used to indicate the result of the last file operation.
A value other than zero indicates error. The error code can be accessed by calling
read_error_code().
143
CipherLab C Programming Part I
Below are the routines applicable to both types of files, DAT and DBF files (with
associated IDX files).
access
filelist
Return Value It simply returns the number of files currently exist in the system.
Remarks This routine copies the file name, file type, and file size information (separated
by a blank character) of all files in existence into a character array specified by
the argument dir.
144
Chapter 2 Mobile-Specific Function Library
get_file_number
read_error_code
remove
145
CipherLab C Programming Part I
rename
146
Chapter 2 Mobile-Specific Function Library
Data at the beginning of a DAT file can be removed by calling the delete_top() or
delete_topln() function. The new file top, the file pointer, and the size of the DAT
file will be adjusted accordingly after calling either of the two functions.
The append() and appendln() functions can write data to the EOF (end of file)
position, no matter where the file pointer points to. That is, the file pointer position is
not changed after calling these functions.
Normally, this is the scheme for handling the transaction data, that is, reading and
removing data from top of the file, and adding new data to the bottom of a file.
append
Purpose To write a specified number of bytes to the bottom (EOF) of a DAT file.
Syntax int append (int fd, char *buffer, int count);
Parameters int fd
File handle of the target DAT file.
char *buffer
Pointer to a buffer where data is stored.
int count
Number of bytes to be written.
The maximum number of characters that can be written is 32767.
Example append(fd, “1234567890”, 10);
Return Value If successful, it returns the number of bytes actually written to the file.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
9 The value of count is negative.
10 No free file space for file extension.
Remarks This routine writes a number of bytes (count) from the character array buffer
to the bottom of a DAT file (fd).
Writing of data starts at the end-of-file position, and the file pointer
position is unaffected by the operation. It will automatically extend the file
size to hold the data written.
See Also appendln, read, readln, write, writeln
147
CipherLab C Programming Part I
appendln
Purpose To write a line (null-terminated string) to the bottom (EOF) of a DAT file.
Syntax int appendln (int fd, char *buffer);
Parameters int fd
File handle of the target DAT file.
char *buffer
Pointer to a buffer where data is stored.
Example appendln(fd, data_buffer);
Return Value If successful, it returns the number of bytes actually written to the file,
including the null character.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
10 No free file space for file extension.
11 Cannot find string terminator in buffer.
Remarks This routine writes a null-terminated string from the character array buffer to
the bottom of a DAT file (fd).
Characters are written to the file until a null character (\0) is encountered.
The null character is also written to the file.
Writing of data starts at the end-of-file position, and the file pointer
position is unaffected by the operation. It will automatically extend the file
size to hold the data written.
See Also append, read, readln, write, writeln
148
Chapter 2 Mobile-Specific Function Library
chsize
149
CipherLab C Programming Part I
close
150
Chapter 2 Mobile-Specific Function Library
delete_top
Purpose To delete a specified number of bytes from the top (beginning-of-file position)
of a DAT file.
Syntax int delete_top (int fd, int count);
Parameters int fd
File handle of the target DAT file.
int count
Number of bytes to be deleted.
Example delete_top(fd, 80);
Return Value If successful, it returns the number of bytes actually removed from the file.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
9 The value of count is negative.
Remarks This routine deletes the number of bytes (count) from a DAT file (fd).
Removal of data starts at the beginning-of-file position of the file, and the
file pointer position is adjusted accordingly.
For example, if initially the file pointer points to the tenth character, after
deleting eight characters from the file, the new file pointer will points to the
2nd character of the file. It will resize the file size automatically.
See Also delete_topln
151
CipherLab C Programming Part I
delete_topln
Return Value If successful, it returns the number of bytes actually removed from the file,
including the null character.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
Remarks This routine deletes a null-terminated string specified from a DAT file (fd).
Characters are removed from the file until a null character (\0) or
end-of-file is encountered. The null character is also removed from the file.
Removal of data starts at the beginning-of-file position of the file, and the
file pointer position will be adjusted accordingly. It will resize the file size
automatically.
See Also delete_top
152
Chapter 2 Mobile-Specific Function Library
eof
Purpose To check whether or not the file pointer of a DAT file reaches the end-of-file
(eof) position.
Syntax int eof (int fd);
Parameters int fd
File handle of the target DAT file.
Example if (eof(fd)) puts(“end of file is reached!\n”);
filelength
Return Value If successful, it returns the number of bytes for file size.
On error, it returns -1L.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
153
CipherLab C Programming Part I
lseek
Parameters int fd
File handle of the target DAT file.
long offset
Offset of new position (in bytes) from origin.
int origin
1 Offset from the beginning of the file.
0 Offset from the current position of the file pointer.
-1 Offset from the end of the file.
Example lseek(fd, 512L, 0); // skip 512 bytes
Remarks This routine repositions the file pointer of a DAT file (fd) by seeking a number
of bytes (offset) from the given position (origin).
See Also tell
154
Chapter 2 Mobile-Specific Function Library
open
Purpose To open a DAT file and get its file handle for further processing.
Syntax int open (char *filename);
Parameters char *filename
Pointer to a buffer where the filename of the file to be opened is stored.
If the file specified by filename does not exist, it will be created first.
If filename exceeds eight characters, it will be truncated to eight
characters.
Example if (fd = open(“data1”) > 0) puts(“data 1 is opened!\n”);
Remarks A file handle is a positive integer (greater than zero) used to identify the file for
subsequent file manipulation on the file.
Once the file is opened, the file pointer is at the beginning of the file.
See Also close
155
CipherLab C Programming Part I
read
Return Value If successful, it returns the number of bytes actually read from the file.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
9 The value of count is negative.
Remarks This routine reads a number of bytes (count) from a DAT file (fd) to the
character array buffer.
Reading of data starts from the current position of the file pointer, which is
incremented accordingly when the operation is completed.
See Also readln, write, writeln
156
Chapter 2 Mobile-Specific Function Library
readln
Return Value If successful, it returns the number of bytes actually read from the file.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
9 The value of max_count is negative.
This routine reads a null-terminated string from a DAT file (fd) to the character
array buffer. Characters are read until end-of-file or a null character (\0) is
encountered, or the total number of character read equals the number
specified by max_count.
Remarks If characters are read until a null character (\0) is encountered, the null
character is also read into buffer. That is, it is also counted for the return
value. Otherwise, there may not be a null character stored in buffer.
Reading of data starts from the current position of the file pointer, which is
incremented accordingly when the operation is completed.
See Also read, write, writeln
157
CipherLab C Programming Part I
tell
Return Value If successful, it returns the number of bytes for the offset from the beginning of
the file to the current file pointer.
On error, it returns -1L.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
Remarks The file pointer position is expressed in number of bytes from the beginning of
file.
For example, if the file pointer is at the beginning of the file, its position is
0L.
See Also lseek
158
Chapter 2 Mobile-Specific Function Library
write
Return Value If successful, it returns the number of bytes actually written to the file.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
9 The value of count is negative.
10 No free file space for file extension.
Remarks This routine writes a number of bytes (count) from the character array buffer
to a DAT file (fd).
Writing of data starts at the current position of the file pointer, which is
incremented accordingly when the operation is completed.
If end-of-file is encountered during operation, it will automatically extend
the file size to hold the data written.
See Also append, appendln, read, readln, writeln
159
CipherLab C Programming Part I
writeln
Return Value If successful, it returns the number of bytes actually written to the file,
including the null character.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by fd does not exist.
4 File specified by fd is not a DAT file.
7 Invalid file handle.
8 File not opened.
10 No free file space for file extension.
11 Cannot find string terminator in buffer.
Remarks This routine writes a null-terminated string from the character array buffer to a
DAT file (fd).
Characters are written to the file until a null character (\0) is encountered.
The null character is also written to the file.
Writing of data starts at the current position of the file pointer, which is
incremented accordingly when the operation is completed.
If end-of-file is encountered during operation, it will automatically extend
the file size to hold the data written.
See Also append, appendln, read, readln, write
160
Chapter 2 Mobile-Specific Function Library
DBF files and IDX files form the platform of database system.
A DBF file has a fixed record length structure. This is the file that stores data records
(members). Whereas, the associate IDX files are the files that keep information of the
position of each record stored in the DBF files, but they are re-arranged (sorted)
according to some specific key values.
A library would be a good example to illustrate how DBF and IDX files work. When you
are trying to find a specific book in a library, you always start from the index. The book
can be found by looking into the index categories of book title, writer, publisher, ISBN
number, etc. All these index entries are sorted in ascending order for easy lookup
according to some specific information of books (book title, writer, publisher, ISBN
number, etc.) When the book is found in the index, it will tell you where the book is
actually stored.
As you can see, the books kept in the library are analogous to the data records stored in
the DBF file, and, the various index entries are just its associate IDX files. Some
information (book title, writer, publisher, ISBN number, etc.) in the data records is used
to create the IDX files.
KEY NUMBER
Each DBF file can have maximum 8 associate IDX files, and each of them is identified by
its key (index) number. The key number is assigned by user program when the IDX file is
created.
KEY VALUE
Data records are not fetched directly from the DBF file but rather through its associated
IDX files. The value of file pointers of the IDX files (index pointers) does not represent
the address of the data records stored in the DBF file. It indicates the sequence number
of a specific data record in the IDX file.
161
CipherLab C Programming Part I
add_member
162
Chapter 2 Mobile-Specific Function Library
close_DBF
Purpose To close a previously opened or created DBF file and its associated IDX files.
Syntax int close_DBF (int DBF_fd);
Parameters int DBF_fd
File handle of the target DBF file.
Example if (close_DBF(DBF_fd)) puts(“DBF file is closed!\n”);
Remarks This routine adds a data record (member) to a DBF file (DBF_fd) and adds
index entries to all the associated IDX files.
If the length of the added member is greater than that defined for the DBF
file (member_len in the create_DBF() function), the member will be
truncated to fit in.
See Also open_DBF
163
CipherLab C Programming Part I
create_DBF
Purpose To create a DBF file and get its file handle for further processing.
Syntax int create_DBF (char *filename, int member_len);
Parameters char *filename
Pointer to a buffer where the filename of the file to be created is stored.
If filename exceeds eight characters, it will be truncated to eight
characters.
For 8200/8400/8700 Series, if the file is created on SD card, the filename
must be given in full path and cannot exceed 250 bytes. Refer to 2.16.2
Directory for how to specify a file path.
int member_len
Maximum member (record) length of the DBF file.
Any member subsequently added to this DBF file with length greater than
the maximum length will be truncated to fit in.
Example if (fd = create_DBF(“data1”, 64) > 0) puts(“data1 is created!\n”);
Remarks This routine creates a DBF file (filename) with its member length specified
(member_len), and gets the file handle of it.
A file handle is a positive integer (greater than zero) used to identify the
file for subsequent file manipulation on the file.
User-defined indexes may be created after the DBF file is created.
See Also close_DBF, create_index, open_DBF
164
Chapter 2 Mobile-Specific Function Library
create_index
Remarks This routine creates an IDX file (key_number), which is associated with a DBF
file (DBF_fd). The key field of the IDX file is specified by key_offset and
key_len.
The key field should be within member_len as defined in the create_DBF()
function. That is, key_offset plus key_len should not be greater than
member_len.
This routine can only be called before any members are added to the DBF
file, that is, when the DBF file is empty (no members exist). If any member
exists in the DBF file, rebuild_index() should be used instead.
See Also create_DBF, rebuild_index, remove_index
165
CipherLab C Programming Part I
delete_member
Remarks This routine deletes a data record (member) pointed to by the index pointer of
an IDX file (key_number), which is associated with a DBF file (DBF_fd).
See Also add_member, has_member
166
Chapter 2 Mobile-Specific Function Library
get_member
167
CipherLab C Programming Part I
has_member
Purpose To check whether or not a specific data record (member) exists in a DBF file.
Syntax int has_member (int DBF_fd, int key_number, char *key_value);
Parameters int DBF_fd
File handle of the target DBF file.
int key_number
Key number of the target IDX file.
char *key_value
Pointer to a buffer where a key value is held to identify a specific member.
168
Chapter 2 Mobile-Specific Function Library
lseek_DBF
169
CipherLab C Programming Part I
member_in_DBF
170
Chapter 2 Mobile-Specific Function Library
open_DBF
Purpose To open an existing DBF file and get its file handle for further processing.
Syntax int open_DBF (char *filename);
Parameters char *filename
Pointer to a buffer where the filename of the DBF file to be opened is stored.
If the filename exceeds eight characters, it will be truncated to eight
characters.
For 8200/8400/8700 Series, if the file is created on SD card, the filename
must be given in full path and cannot exceed 250 bytes. Refer to 2.16.2
Directory for how to specify a file path.
Example if (fd = open_DBF(“data1”) > 0) puts(“data1 is opened!\n”);
171
CipherLab C Programming Part I
rebuild_index
172
Chapter 2 Mobile-Specific Function Library
Remarks This routine rebuilds or creates an IDX file (key_number), which is associated
with a DBF file (DBF_fd). It can be used whenever an IDX file has the same
values for a key field. The key field of the IDX file is specified by key_offset and
key_len.
base_index specifies the IDX file from which this routine takes as the input
sequence for building the new IDX file. For example, if a report is to be
generated by the sequence of date, department, and ID number, and the
date and department data may be repeated. This can be done by rebuilding
the ID number index first. Then, rebuild the department index with the ID
number index as the base index. And finally, rebuild the date index with
the department index as the base index. The resulting member sequence in
the date index will be in date, department, and ID number.
The key field should be within member_len as defined in the create_DBF()
function. That is, key_offset plus key_len should not be greater than
member_len.
See Also create_index, remove_index
173
CipherLab C Programming Part I
remove_index
174
Chapter 2 Mobile-Specific Function Library
tell_DBF
Return Value If successful, it returns the rank number for the current index pointer.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their
interpretation.
Error Code Meaning
2 File specified by DBF_fd does not exist.
4 File specified by DBF_fd is not a DBF file.
7 Invalid file handle.
8 File not opened.
13 The value of key_number is invalid.
14 IDX file specified by key_number does not exist.
Remarks This routine gets the current index pointer position of an IDX file
(key_number), which is associated with a DBF file (DBF_fd).
The index pointer position is expressed in rank number in the IDX file. For
example, if the index pointer points to the first index, its position will be 1L.
See Also lseek_DBF
175
CipherLab C Programming Part I
176
Chapter 2 Mobile-Specific Function Library
update_member
177
CipherLab C Programming Part I
while(1);
178
Chapter 2 Mobile-Specific Function Library
Remarks The source DAT file must be closed before calling this routine. If the target file
already exists, it will be overwritten; otherwise, this routine will create a new
DAT file.
See Also SDtoRAM_DAT, SDtoRAM_DBF, RAMtoSD_DBF
179
CipherLab C Programming Part I
while(1);
180
Chapter 2 Mobile-Specific Function Library
Remarks The source DAT file must be closed before calling this routine. If the target file
already exists, it will be overwritten; otherwise, this routine will create a new
DAT file.
See Also RAMtoSD_DAT, SDtoRAM_DBF, RAMtoSD_DBF
181
CipherLab C Programming Part I
Purpose To copy a DBF file and its associated IDX files from file system (SRAM) to SD
card.
Syntax int RAMtoSD_DBF (const char *filenameRAM, const char *filenameSD, int
mode);
Parameters const char *filenameRAM
Pointer to a buffer where the source DBF file name is stored.
If filename exceeds eight characters, it will be truncated to eight
characters.
const char *filenameSD
Pointer to a buffer where the target DBF file name is stored.
The filename must be given in full path. Refer to 2.16.2 Directory for how
to specify a file path.
Filename extension isn’t required. When creating DBF files, it has “.DB0”
as the filename extension for the DBF file itself and “.DB1” ~ “.DB8” for
the IDX files.
int mode
0 To remove the source file.
1 To keep the source file.
Example const static char dbfname2[ ]= “RAMdbf1”;
while(1);
182
Chapter 2 Mobile-Specific Function Library
183
CipherLab C Programming Part I
Purpose To copy a DBF file and its associated IDX files from SD card to file system
(SRAM).
Syntax int SDtoRAM_DBF (const char *filenameSD, const char *filenameRAM, int
mode);
Parameters const char *filenameSD
Pointer to a buffer where the source DBF file name is stored.
The filename must be given in full path. Refer to 2.16.2 Directory for how
to specify a file path.
const char *filenameRAM
Pointer to a buffer where the target DBF file name is stored.
If filename exceeds eight characters, it will be truncated to eight
characters.
int mode
0 To remove the source file.
1 To keep the source file.
while(1);
184
Chapter 2 Mobile-Specific Function Library
Remarks The source DBF file must be closed before calling this routine. If the target file
already exists, it will be overwritten; otherwise, this routine will create a new
DBF file.
See Also RAMtoSD_DAT, RAMtoSD_DBF, SDtoRAM_DAT
GetFileInfo 8200,8400,8700
185
CipherLab C Programming Part I
int i;
if (GetFileInfo("a:\\DBF1.DB0",&InfoBuf ) ==1){
for(i=0;i<8;i++){
else{
printf("No file\r\n”);
186
Chapter 2 Mobile-Specific Function Library
typedef struct {
unsigned char file_type;
unsigned char open_status;
unsigned long fileSize;
unsigned long total_member;
unsigned int Member_len;
unsigned char IndexNumber;
struct index_INFO index[8];
} DEVICE_FILEINFO;
struct index_INFO {
unsigned int key_len;
unsigned int key_offset;
unsigned long index_file_size;
};
187
CipherLab C Programming Part I
1 DAT
2 DBF
3 INDEX
1 Open
0 Close
188
Chapter 2 Mobile-Specific Function Library
e.g. file_type
a:/DATA1.DB0 open_status
a:/DATA1.DB1 fileSize
total_member
Member_len
IndexNumber
index[0]~index[7] (key_len, key_offset, index_file_size)
(*Index file: DB1~DB8)
file_type
open_status
fileSize
index[0] (key_len, key_offset, index_file_size)
189
CipherLab C Programming Part I
Note:
190
Chapter 2 Mobile-Specific Function Library
2.16 SD CARD
SD card can be accessed directly by using the provided functions in user application. Yet,
when 8200/8400/8700 is equipped with SD card and connected to your computer via the
USB cable, it can be treated as a removable disk (USB mass storage device) as long as it
is configured properly through programming or via System Menu | SD Card Menu |
Run As USB Disk. Refer to Part II: Chapter 9 USB Connection and 2.16.6 Mass
Storage Device.
Note: It is not allowed for the mobile computer to directly access SD card when COM5 is
set to mass storage use (pass COMM_USBDISK to SetCommType).
Note: It can have maximum 32 files and 3 directories opened at the same time. It is
suggested that you close a file or directory whenever it is no longer desired; otherwise,
the file handles may be depleted.
191
CipherLab C Programming Part I
≦ 1 GB FAT16 32
≦ 2 GB FAT16 64
≦ 8 GB FAT32 8
192
Chapter 2 Mobile-Specific Function Library
2.16.2 DIRECTORY
Unlike the file system on SRAM, the file system on SD card supports hierarchical tree
directory structure and allows creating sub-directories. Several directories are reserved
for particular use.
193
CipherLab C Programming Part I
\AG\DBF Application Generator (a.k.a. AG) Store DAT, DBF, and Lookup files that are
created and/or accessed in Application
\AG\DAT
Generator to this folder.
\AG\EXPORT
\AG\IMPORT
When a file name is required as an argument passed to a function call, it must be given
in full path as shown below.
Note: (1) For DAT files, it does not matter whether filename extension is included or not.
(2) For DBF files, it does not require including filename extension.
194
Chapter 2 Mobile-Specific Function Library
A file name must follow 8.3 format (= short filenames) — at most 8 characters for
filename, and at most three characters for filename extension. The following characters
are unacceptable: “ * + , : ; < = > ? | [ ]
It can only display a filename of 1 ~ 8 characters (the null character not included),
and filename extension will be displayed if provided. If a file name specified is longer
than eight characters, it will be truncated to eight characters.
Long filenames, at most 255 characters, are allowed when using the mobile computer
equipped with SD card as a mass storage device. For example, you may have a
filename “123456789.txt” created from your computer. However, when the same file
is directly accessed on the mobile computer, the filename will be truncated to
“123456~1.txt”.
If a file name is specified other in ASCII characters, in order for the mobile computer
to display it correctly, you may need to download a matching font file to the mobile
computer first.
The file name is not case-sensitive.
195
CipherLab C Programming Part I
typedef struct {
char fname[13];
unsigned char fattrib;
unsigned int ftime;
unsigned int fdate;
unsigned long fsize;
} FILEINFO;
Member Description
char fname[13] File name must follow 8.3 format. This field is split into two parts:
(1) 8 characters for file name
(2) 3 character s for file extension
unsigned char fattrib File attributes:
0x01 READ_ONLY
0x02 HIDDEN
0x04 SYSTEM
0x08 VOLUME_ID
0x10 DIRECTORY
0x20 ARCHIVE
unsigned int ftime Time of last write operation. This is a 16-bit field:
Bits 0~4 Seconds (each increment for 2 seconds)
Valid range 0~29 for 0~58
Bits 5~10 Minutes
Valid range 0~59
Bits 11~15 Hours
Valid range 0~23
unsigned int fdate Date of last write operation. This is a 16-bit field:
Bits 0~4 Day of month
Valid range 1~31
Bits 5~8 Month of year
Valid range 1~12
Bits 9~15 Year count since 1980
Valid range 0~127 for 1980~2107
unsigned long fsize File size in bytes.
196
Chapter 2 Mobile-Specific Function Library
Purpose To change the attributes of a file or directory, by the given file path.
Syntax int chmod (const char *filename, int attribute);
Parameters const char *filename
Pointer to a buffer where the filename of the file to be changed is stored.
int attribute
New attribute value given to the file. It can be one or more of the following:
0x00 FA_NOR Normal file (= no attributes)
0x01 FA_RDO Read-only file
0x02 FA_HID Hidden file (= does not affect accessibility)
0x04 FA_SYS System file
0x20 FA_ARC Archive bit (= this bit would be set if file is created or
updated)
197
CipherLab C Programming Part I
Purpose To change the attributes of the file by using the file handle.
Syntax int chmodfp (int fd, int function, int attribute);
Parameters int fd
File handle of the target file.
int function
0 Return the current setting
1 Set new attributes
int attribute
New attribute value given to the file. It can be one or more of the following:
0x00 FA_NOR Normal file (= no attributes)
0x01 FA_RDO Read-only file
0x02 FA_HID Hidden file (= does not affect accessibility)
0x04 FA_SYS System file
0x20 FA_ARC Archive bit (=this bit would be set if file is created or
updated)
Example int fd,result;
fd = fopen(“A:\\myfile.bin”,“rb”);
result = chmodfp(fd, 1, FA_SYS|FA_RDO);
if (result == -1)
printf(“chmodfp error\n”);
Return Value If successful, it returns the new attributes.
On error, it returns -1. The global variable ferrno is set to indicate the error
condition encountered.
Remarks This routine changes the attributes of a file. The new attributes will not take
effect until the file is closed and re-opened. For example, if the file is currently
open for writing, and then made read-only, writing to the file is still allowed
until the file is closed and re-opened.
See Also chmod
198
Chapter 2 Mobile-Specific Function Library
Purpose To close a file opened earlier for buffered input and output using fopen().
Syntax int fclose (int fd);
Parameters int fd
File handle of the target file.
Example int fd;
fd = fopen(“A:\\myfile.bin”,“wb”);
if (fclose(fd)!=0)
printf(“file close error\n”);
Return Value If successful, it returns 0.
On error, it returns -1. The global variable ferrno is set to indicate the error
condition encountered.
Remarks If the file has been opened for writing data, the contents of the buffer
associated with the file are flushed before the file is closed.
See Also fflush, fopen
199
CipherLab C Programming Part I
Purpose To check whether or not the file pointer reaches the end-of-file (eof) position.
Syntax int feof (int fd);
Parameters int fd
File handle of the target file.
200
Chapter 2 Mobile-Specific Function Library
Purpose To flush the output buffer associated with a file opened for buffered I/O. This
will cause any remaining data in the output buffer written to the file.
Syntax int fflush (int fd);
Parameters int fd
File handle of the target file.
Example int fd;
char buf[]=”test”;
fopen(“A:\\myfile.bin”,“wb”);
fwrite(buffer, 1, 4, fd);
fflush(fd);
Return Value If successful, it returns 0.
On error, it returns -1. The global variable ferrno is set to indicate the error
condition encountered.
See Also fclose
201
CipherLab C Programming Part I
Purpose To read one character from a file opened for buffered input.
Syntax int fgetc (int fd);
Parameters int fd
File handle of the target file.
Example int fd;
int c;
fd = fopen(“A:\\myfile.bin”,“rb”);
while (!feof(fd)) {
c = fgetc(fd);
}
Return Value If successful, it returns the character read from the buffer.
On error, it returns -1.
Call ferror() and feof() to determine if there was an error or the file simply
reached its end.
Remarks This routine reads a character from the current position of the file, and then
increments this position. The character is returned as an integer.
See Also fgets, fputc, fputs
202
Chapter 2 Mobile-Specific Function Library
203
CipherLab C Programming Part I
Purpose To read a line from a file opened for buffered input. This line is read until a
newline (\n) character is encountered or until the number of characters reaches
the specified maximum.
Syntax char *fgets (char *string, int max_char, int fd);
Parameters char *string
Pointer to a buffer where the string is stored (by character).
int max_char
The maximum number of characters to be stored.
int fd
File handle of the target file.
Example int fd;
char string [81];
fd = fopen(“A:\\myfile.bin”, “r”);
if(fgets(string, 80, fd) != 0)
printf(“%s\n”, string);
Return Value If successful, it returns the pointer string.
On error, it returns 0.
Call ferror() and feof() to determine if there was an error or the file simply
reached its end.
Remarks This routine reads at most one less than the number of characters specified by
max_char from the file into the buffer pointed to by string. No additional
characters are read after the newline character (which is retained). A null
character is written immediately after the last character read into the buffer.
See Also fgetc, fputc, fputs
204
Chapter 2 Mobile-Specific Function Library
Purpose To open or create a file for buffered input and output operations.
Syntax int fopen (const char *filename, const char *mode);
Parameters const char *filename
Pointer to a buffer where the filename of the file to be opened is stored. The
filename must be given in full path and follow 8.3 format.
const char *mode
Type of access permitted:
“r” Open for reading in text mode.
“w” Create or truncate for writing in text mode.
“a” Append in text mode. (open/create for writing at EOF)
“rb” Open for reading in binary mode.
“wb” Create or truncate for writing in binary mode.
“ab” Append in binary mode. (open/create for writing at EOF)
“r+” Open for reading and writing in text mode.
“w+” Create or truncate for reading and writing in text mode.
“a+” Open/create for reading and appending in text mode.
“r+b” Open for reading and writing in binary mode.
“w+b” Create or truncate for reading and writing in binary mode.
“a+b” Open/create for reading and appending in binary mode.
205
CipherLab C Programming Part I
206
Chapter 2 Mobile-Specific Function Library
207
CipherLab C Programming Part I
Purpose To read a specified number of data items, each of a given size, from the
current position in a file opened for buffered input.
Syntax int fread (void *buffer, int size, int count, int fd);
Parameters void *buffer
Pointer to a buffer where data is stored.
int size
Size in bytes of each data item.
int count
The maximum number of items to be read.
int fd
File handle of the target file.
208
Chapter 2 Mobile-Specific Function Library
209
CipherLab C Programming Part I
210
Chapter 2 Mobile-Specific Function Library
211
CipherLab C Programming Part I
Purpose To set the position where reading or writing can take place in a file opened for
buffered I/O.
Syntax int fsetpos (int fd, const unsigned long *newposition);
Parameters int fd
File handle of the target file.
const unsigned long *newposition
Pointer to a buffer where the new position of the file is stored.
Example int fd;
unsigned long curpos;
fd =fopen(“A:\\myfile.bin”,”rb”);
curpos=10;
if (fsetpos(fd, &curpos) != 0){
printf(“fsetpos failed.\n”);
}
Return Value If successful, it returns 0.
On error, it returns a non-zero value. The global variable ferrno is set to
indicate the error condition encountered.
Remarks This routine sets the file pointer of the opened file to a new position
newposition.
See Also fgetpos
212
Chapter 2 Mobile-Specific Function Library
Purpose To write a specified number of data items, each of a given size, from a buffer
to the current position in a file opened for buffered output.
Syntax int fwrite (const void *buffer, int size, int count, int fd);
Parameters const void *buffer
Pointer to a buffer where data is stored.
int size
Size in bytes of each data item.
int count
The maximum number of items to be written.
int fd
File handle of the target file.
Example int fd;
char buffer [81] = “Testing the fwrite function”;
int count;
fd = fopen(“A:\\myfile.bin”, “wb”)
count = fwrite(buffer, 1, 20, fd);
printf(“%d characters written to a file\n”, count);
fclose(fd);
213
CipherLab C Programming Part I
Return Value It returns the number of items actually written to the file.
If the number of items written is not equal to count, call ferror() to determine if
there was an error.
Remarks The number of items returned will be equal to count unless an error occurs.
After the write operation is complete, the current position will be updated.
See Also fread
Example if (mkdir(“A:\\SubDir”) != 0)
printf(“Fail to create a directory.”);
Return Value If successful, it returns 0.
On error, it returns a non-zero value. The global variable ferrno is set to
indicate the error condition encountered.
Remarks This routine creates a new directory specified by the argument newdir. The
directory name must be given in full path and follow 8.3 format.
See Also rmdir
214
Chapter 2 Mobile-Specific Function Library
When mass storage is in use, (1) all opened files will be closed automatically and (2) if
any of the functions in 2.16.5 SD Card Manipulation is called before close_com(5), the
error code E_SD_OCCUPIED is returned to indicate the SD card is currently occupied as
mass storage device.
215
CipherLab C Programming Part I
For most SD-related functions, the global variable ferrno is set to indicate the error
condition encountered. For example,
fd = fopen(“A:\\file1”, “rb”);
if(!fd){
printf(“%d”,ferrno);
For information on the condition encountered, refer to the Error Code list in ferror().
Alternatively, you may call ferror() to access the error code after performing read/write
operation to a file.
Using ferrno
fwrite (X, X, X, fd1);
error1 = ferrno
fwrite (X, X, X, fd2);
error2 = ferrno
After executing an SD-related function, the global variable ferrno will be updated accordingly.
Therefore, in the example above error1 and error2 may be different.
Using ferror()
fwrite (X, X, X, fd1);
error1 = ferror (fd1);
fwrite (X, X, X, fd2);
error2 = ferror (fd2);
error1 = ferror (fd1);
After executing a function related to read/write operation to a file, the value you get by calling
ferror() is the same as the one ferrno holds. The only difference is the value returned by
ferror() will not be updated until executing a function related to read/write operation to the
same file. Therefore, in the example above the first error1 and the second error1 are exactly the
same.
216
Chapter 2 Mobile-Specific Function Library
217
CipherLab C Programming Part I
Purpose To check whether or not an error has occurred during a previous read/write
operation on a file.
Syntax int ferror (int fd) ;
Parameters int fd
File handle of the target file.
Example int fd;
fd = fopen (“A:\\myfile.bin”, “wb”);
if(fgetc(fd)==-1){
printf(“error code:%d”,ferror(fd));
}
Return Value If any error occurred, it returns the error code.
Otherwise, it returns 0.
Remarks You may call ferror() to access the error code for fgetc(), fgets(), fputc(),
fputs(), fread() and fwrite().
218
Chapter 2 Mobile-Specific Function Library
Include File
All programs that call GUI routines need to contain the following include statement.
#include <8xxxlib.h>
#include <8xGUI.h>
This header file “8xGUI.h” contains the function prototypes (declarations) and error code
definitions. These files should normally be placed under the “include” directory of the C compiler -
C:\C_Compiler\INCLUDE\
Library File
Any GUI application written in C language requires a number of libraries specific to 8700:
Link File
Below is an example of link file (partial).
/*** Link File ***/
-lm -lg -ll
tnet.rel
8xGUI.lib
8700lib.lib
c900ml.lib
Note: The library files must be in the above sequence. That is, “8xGUI.lib” must be
specified first, then “8xxxlib.lib”, and finally the standard C library file “c900ml.lib”.
219
CipherLab C Programming Part I
gui_TouchScreenCenterStr 8700
220
Chapter 2 Mobile-Specific Function Library
2.17.2 TITLE
gui_TouchScreenPrintTitle 8700
221
CipherLab C Programming Part I
2.17.3 BACKGROUND
gui_TouchScreenPrintScreenLines 8700
startRow
endRow
222
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenActivateForm 8700
223
CipherLab C Programming Part I
if (i == 1) // PREV button
{
}
else if (i == 2) // NEXT button
{
}
else if (i == 3) // INFO button
{
}
OSTimeDly(4);
}
gui_TouchScreenDisableForm();
y_dot
height
224
Chapter 2 Mobile-Specific Function Library
Title Icon
(2)
Button(s)
(0) (1)
Sequence of Item Number Returned by GetScreenItem()
gui_TouchScreenDisableForm 8700
225
CipherLab C Programming Part I
gui_TouchScreenDefineField 8700
1 FORMFIELD_2
2 FORMFIELD_3
3 FORMFIELD_4
4 FORMFIELD_5
5 FORMFIELD_6
6 FORMFIELD_ALL
int field_type
Specify which data type is allowed for field input.
1 FIELDTYPE_INTEGER Accpets 0~9 and the minus sign.
2 FIELDTYPE_UINTEGER Accpets 0~9 only.
3 FIELDTYPE_FLOAT Accpets 0~9, decimal point and the minus
sign.
4 FIELDTYPE_UFLOAT Accpets 0~9 and decimal point only.
5 FIELDTYPE_STRING Accpets 0~9 and all printable characters
except for the following:?+-/*\.,;:#$
int display_mode
0 VIDEO_NORMAL Normal mode in use
1 VIDEO_REVERSE Reverse mode in use
int font
1 FONT_6X8
2 FONT_8X16
int column
Specify the x coordinate of the upper left corner of the field.
int row
Specify the y coordinate of the upper left corner of the field.
int max_len
Specify the maximum length allowed for field input.
226
Chapter 2 Mobile-Specific Function Library
char *initial_value
Pointer to a buffer where the initial value or text is stored. The cursor position
will be shifted accordingly. For example, you may specify “US$” as the initial
value and input data starting from the 4th-character position.
char *input_mark
Pointer to a buffer where the input mark is stored. By default, the character
“_” (underline) is in use. The number of input marks shown in the field equals
to the maximum length allowed for input. It is to be replaced by input data.
Example gui_TouchScreenDefineField(
FORMFIELD_1, FIELDTYPE_STRING, VIDEO_NORMAL, FONT_8X16, 7, 5, 11,
(char*)"16/07/2010", NULL);
gui_TouchScreenDefineField(
FORMFIELD_2, FIELDTYPE_INTEGER, VIDEO_NORMAL, FONT_8X16, 7, 7, 11,
(char*)"", NULL);
Return Value None
Remarks Each set of field definition will be saved to S_FormField FormFieldCollection[6].
Refer to 2.17.21 S_FormField Structure.
Here is an example screenshot, where the prompt strings are “Date:” and
“Order#:”, and you may specify “16/07/2010” as the initial value of the Date
field.
(column, row)
However, you may treat the initial value as a prompt string. In a different
design for the same screenshot shown above, the initial value of the 1st field is
“ Date:16/07/2010”, and “Order#:” for the 2nd field. The initial value cannot
be modified unless the input focus is moved to the area where it is. For
example, you may activate the area of “16/07/2010_” to allow changes made
to the initial value. Alternatively, you may call gui_TouchScreenSetFieldFocus()
in your code to move the input focus.
227
CipherLab C Programming Part I
gui_TouchScreenClearField 8700
Purpose To clear data of a specifc input field, or reset all input fields to defaults.
Syntax void gui_TouchScreenClearField (int field_index);
Parameters int field_index
Specify the field by index, 0~6.
0 FORMFIELD_1 Clear data of a specifc input field.
1 FORMFIELD_2
2 FORMFIELD_3
3 FORMFIELD_4
4 FORMFIELD_5
5 FORMFIELD_6
6 FORMFIELD_ALL Reset all input fields to defaults.
Example gui_TouchScreenClearField(FORMFIELD_ALL);
228
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenFieldInput 8700
1 FORMFIELD_2
2 FORMFIELD_3
3 FORMFIELD_4
4 FORMFIELD_5
5 FORMFIELD_6
int password
Specify whether to use asterisk to display each character input.
0 FALSE Show input
1 TRUE Show asterisk
char key
Specify the ASCII character. Call gui_TouchScreenGetCharFromSWKeypad()
to get the ASCII character for the key that has been touched or pressed when
input comes from the software keypad.
Return Value If successful, it returns 1.
On error, it returns 0.
Remarks Call this routine until it displays all the input characters in the field. It will save
any input character to FormFieldCollection[field_index].InputData, and if not
followed by a keystroke of [Backspace], the input character will be output to
the screen.
229
CipherLab C Programming Part I
gui_TouchScreenSetFieldFocus 8700
1 FORMFIELD_2
2 FORMFIELD_3
3 FORMFIELD_4
4 FORMFIELD_5
5 FORMFIELD_6
Example gui_TouchScreenSetFieldFocus(FORMFIELD_2);
230
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenActivateField 8700
Purpose To create and activate the responsive area of a whole field, or of a partial
section of the field.
Syntax void gui_TouchScreenActivateField (int field_index, int startColumn, int
endColumn);
Parameters int field_index
Specify the field by index, 0~5.
0 FORMFIELD_1
1 FORMFIELD_2
2 FORMFIELD_3
3 FORMFIELD_4
4 FORMFIELD_5
5 FORMFIELD_6
int startColumn
Specify from which column the responsive area starts.
int endColumn
Specify from which column the responsive area ends.
Example gui_TouchScreenDefineField(
FORMFIELD_1, FIELDTYPE_STRING, VIDEO_NORMAL, FONT_8X16, 7, 5, 11,
(char*)"16/07/2010", NULL);
gui_TouchScreenDefineField(
FORMFIELD_2, FIELDTYPE_INTEGER, VIDEO_NORMAL, FONT_8X16, 7, 7, 11,
(char*)"", NULL);
gotoxy(0, 5);
clr_eol();
printf(" Date:");
gui_TouchScreenActivateField(FORMFIELD_1, 7, 17);
gotoxy(0, 7);
clr_eol();
printf("Order#:");
gui_TouchScreenActivateField(FORMFIELD_2, 7, 17);
gui_TouchScreenSetFieldFocus(FORMFIELD_2);
while(1)
{
if (getchar() == KEY_ESC)
break;
i = GetScreenItem((void*)&CompiledTouchButtons,
nCompiledTouchButtons, ITEM_REVERSE);
231
CipherLab C Programming Part I
if (i == 1) // FORMFIELD_1
{
}
else if (i == 2) // FORMFIELD_2
{
}
OSTimeDly(4);
}
Return Value None
Remarks An input field must be defined before use. Refer to 2.17.5 Field Settings.
When being activated, touchable “graphic items” (icon or buttons) will be
defined automatically through the data structure ItemProperty. Two global
variables extern ItemProperty CompiledTouchButtons[70] and extern int
nCompiledTouchButtons are defined, and GetScreenItem(ItemProperty
CompiledTouchButtons[70], nCompiledTouchButtons, mode) must be called to
detect whether the icon or a button is touched or pressed.
The item number of each graphic item is assigned accordingly when it is
activated (the best practice is from left to right and top to bottom), and the
icon on the title bar is always the last one. Refer to 2.12 Touch Screen.
Here is an example screenshot.
Whole field
Partially activated
startColumn endColumn
232
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenDisableField 8700
1 FORMFIELD_2
2 FORMFIELD_3
3 FORMFIELD_4
4 FORMFIELD_5
5 FORMFIELD_6
Example gui_TouchScreenDisableField(FORMFIELD_1);
233
CipherLab C Programming Part I
2.17.7 TOUCHPAD
gui_TouchScreenActivateSWKeypad 8700
234
Chapter 2 Mobile-Specific Function Library
When being activated, touchable “graphic items” (keys or buttons here) will be
defined automatically through the data structure ItemProperty. Two global
variables extern ItemProperty CompiledTouchButtons[70] and extern int
nCompiledTouchButtons are defined, and GetScreenItem(ItemProperty
CompiledTouchButtons[70], nCompiledTouchButtons, mode) must be called to
detect which key is touched or pressed.
The item number of each graphic item is assigned accordingly when it is
activated (the best practice is from left to right and top to bottom), and the
icon on the title bar is always the last one. Refer to Refer to 2.12 Touch
Screen. Also, gui_TouchScreenGetCharFromSWKeypad() must be called to get
the ASCII character for the key that has been touched or pressed.
Here is an example screenshot.
Touchpad in a form
y_dot
Lower-case
(default)
235
CipherLab C Programming Part I
gui_TouchScreenDisableSWKeypad 8700
236
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenGetCharFromSWKeypad 8700
Purpose To get the ASCII character for the key that has been pressed on the touchpad.
Syntax char gui_TouchScreenGetCharFromSWKeypad (int itemNumber, int
mode_TKB);
Parameters int itemNumber
Specify the item number returned by GetScreenItem().
int mode_TKB
Specify the keypad layout.
0 Lower-case (Default)
1 Shift/CAPS keyboard
2 Symbols lower keyboard
3 Reserved
4 Numeric keyboard
Return Value If successful, it returns the ASCII character for the key.
Remarks When being activated, touchable “graphic items” (keys or buttons here) will be
defined automatically through the data structure ItemProperty. Two global
variables extern ItemProperty CompiledTouchButtons[70] and extern int
nCompiledTouchButtons are defined, and GetScreenItem(ItemProperty
CompiledTouchButtons[70], nCompiledTouchButtons, mode) must be called to
detect which key is touched or pressed.
237
CipherLab C Programming Part I
gui_TouchScreenActivateFieldTouchPad 8700
1 FORMFIELD_2
2 FORMFIELD_3
3 FORMFIELD_4
4 FORMFIELD_5
5 FORMFIELD_6
int password
Specify whether to use asterisk to display each character input.
0 FALSE Show input
1 TRUE Show asterisk
Example gui_TouchScreenClearField(FORMFIELD_ALL);
gui_TouchScreenDefineField(
FORMFIELD_1, FIELDTYPE_STRING, VIDEO_NORMAL, FONT_8X16, 7, 5, 11,
(char*)"16/07/2010", NULL);
gui_TouchScreenDefineField(
FORMFIELD_2, FIELDTYPE_INTEGER, VIDEO_NORMAL, FONT_8X16, 7, 7, 11,
(char*)"", NULL);
gotoxy(0, 5);
clr_eol();
printf(" Date:");
gui_TouchScreenActivateField(FORMFIELD_1, 7, 17);
gotoxy(0, 7);
clr_eol();
printf("Order#:");
gui_TouchScreenActivateField(FORMFIELD_2, 7, 17);
gui_TouchScreenSetFieldFocus(FORMFIELD_2);
238
Chapter 2 Mobile-Specific Function Library
while(1)
{
if (getchar() == KEY_ESC)
break;
i = GetScreenItem((void*)&CompiledTouchButtons,
nCompiledTouchButtons, ITEM_REVERSE);
if (i == 1) // FORMFIELD_1
{
}
else if (i == 2) // FORMFIELD_2
{
cTouchKey = gui_TouchScreenActivteFieldTouchPad(9, (char*)
"TOUCHPAD", FORMFIELD_2, FALSE);
if (cTouchKey == KEY_CR)
{
}
else if (cTouchKey == KEY_ESC)
{
}
}
OSTimeDly(4);
}
Return Value Return Value
KEY_CR One of the following is detected:
The ENTER button of the touchpad has been
pressed.
The ENTER key on the physical keypad has been
pressed.
KEY_ESC One of the following is detected:
The Close icon on the touchpad has been pressed.
The ESC key on the physical keypad has been
pressed.
Remarks An input field must be defined before use. Refer to 2.17.5 Field Settings.
Keypad type is dcecided by the two global variables TKB_MODE and
TKBShiftState. Refer to 2.17.7 Touchpad.
239
CipherLab C Programming Part I
gui_TouchScreenDisableFieldTouchPad 8700
240
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenActivateTextBoxInput 8700
FONT_6X8
241
CipherLab C Programming Part I
gui_TouchScreenDisableTextBoxInput 8700
242
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenActivateSignatureBox 8700
Input area
243
CipherLab C Programming Part I
(0, 39)
(160, 132)
Input area when the screen is flipped: (0, 19) ~ (160, 112)
(0, 19)
(160, 112)
gui_TouchScreenDisableSignatureBox 8700
244
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenActivateTabList 8700
245
CipherLab C Programming Part I
2 FONT_8X16
246
Chapter 2 Mobile-Specific Function Library
Exit the process: Tap the button(s). When two buttons are present, the
user may press the ENTER or ESC key on the physical keypad instead.
(Right button = ENTER; left button = ESC)
Caption Lines 5, 6
Items
Tab1
Tab2
gui_TouchScreenDisableTabList 8700
247
CipherLab C Programming Part I
gui_TouchScreenActivateListBox 8700
2 FONT_8X16
Example int iChoice = 1; char cChoice;
char szChoiceItems[]=
{"Order System\rItem2\rItem3\rItem4\rItem5\rItem6\rItem7\rItem8"};
cChoice = gui_TouchScreenActivateListBox((char*)"CHOICE BOX",
(char*)"Select an operation system from below listing", (char
*)szChoiceItems, &iChoice, DIALOG_PREVDONE, FONT_8X16);
248
Chapter 2 Mobile-Specific Function Library
if( cChoice==KEY_CR)
{
}
else if( cChoice==KEY_ESC)
{
}
Lines 7~11
249
CipherLab C Programming Part I
gui_TouchScreenDisableListBox 8700
250
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenActivateComboList 8700
251
CipherLab C Programming Part I
(x, y)
FONT_6X8
252
Chapter 2 Mobile-Specific Function Library
(x, y)
FONT_8X16
gui_TouchScreenDisableComboList 8700
253
CipherLab C Programming Part I
gui_TouchScreenActivatePopUpMenu 8700
254
Chapter 2 Mobile-Specific Function Library
case KEY_F2:
break;
.
.
.
case KEY_F6:
break;
default:
break;
}
FONT_6X8
FONT_8X16
255
CipherLab C Programming Part I
gui_TouchScreenDisablePopUpMenu 8700
256
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenShowMsgBox 8700
2 BEEP_TRYAGAIN
3 BEEP_FAIL
4 BEEP_ERROR
5 BEEP_KEYCLICK
6 BEEP_PLUSONE
int vibrate
Specify whether to vibrate when a message is received.
0 FALSE Do not vibrate
1 TRUE Vibrate
int button_type
Specify which button(s) to be displayed on the bottom row, or for how long
the message box is displayed.
1 DIALOG_OK Show the OK button
2 DIALOG_OKCANCEL Show the OK and CANCEL buttons
3 DIALOG_YESNO Show the YES and NO buttons
8 DIALOG_3SECONDS Show the message for 3 seconds.
10 DIALOG_1SECOND Show the message for 1 second.
int font
1 FONT_6X8
2 FONT_8X16
257
CipherLab C Programming Part I
Title
258
Chapter 2 Mobile-Specific Function Library
gui_TouchScreenShowMemoBox 8700
2 FONT_8X16
FONT8X16
FONT6X8
259
CipherLab C Programming Part I
2.17.18 CALENDAR
gui_TouchScreenActivateCalendar 8700
260
Chapter 2 Mobile-Specific Function Library
Exit the process: Tap the button(s). When two buttons are present, the
user may press the ENTER or ESC key on the physical keypad instead.
(Right button = ENTER; left button = ESC)
gui_TouchScreenDisableCalendar 8700
261
CipherLab C Programming Part I
gui_TouchScreenShowResourceInfo 8700
262
Chapter 2 Mobile-Specific Function Library
typedef struct {
int TotalButtons;
char ButtonLabel[5][27];
} S_Button;
Item Description
int TotalButtons The amount of buttons to be displayed on the bottom of a
form or a dialog. Up to five buttons are allowed.
char ButtonLabel Label of each button
unsigned char ButtonReturnKey Return value of each button
Note that such user-defined return values can only be applied
to objects such as Tab List, List Box, Combo List and
Calendar.
Note: A global variable, extern S_Button* btnLabel, is declared in 8xGUI.h to govern the
properties of each user-defined button.
263
CipherLab C Programming Part I
typedef struct {
} S_FormField;
Item Description
int FieldType Data type allowed for field input —
FIELDTYPE_INTEGER: 0~9 and the minus sign
FIELDTYPE_UINTEGER: 0~9 only
FIELDTYPE_FLOAT: 0~9, decimal point and the minus
sign
FIELDTYPE_UFLOAT: 0~9 and decimal point only
FIELDTYPE_STRING: 0~9 and all printable characters
except for the following twelve characters ?+-/*\.,;:#$
int DisplayMode Display mode: Normal or Reverse
int Font Font size: FONT_6X8 or FONT_8X16
int Origin_Column X coordinate of the upper left corner of the field
int Origin_Row Y coordinate of the upper left corner of the field
int MaxLength Maximum length allowed for field input
int CursorPosition The cursor position starts after the initial value or text, if
there is any.
char InputMark[27] By default, the character “_” (underline) is in use. The
number of input marks shown in the field equals to the
maximum length allowed for input. It is to be replaced by
input data.
char InputData[27] Data input for a specific field
264
Chapter 2 Mobile-Specific Function Library
typedef struct {
char Caption[27];
char Item[10][27];
} S_MenuData;
Item Description
char Caption[27] Menu caption (Not recommended for combo list.)
char Item[10][27] Menu items by sequence
unsigned char ItemReturnKey[10] Return value for each item
unsigned char ShowCaption 0: Do not show
1: Show caption (Not recommended for combo list.)
265
CipherLab C Programming Part I
266
Chapter 3
STANDARD LIBRARY ROUTINES
The standard library routines supported are categorized and listed below.
In addition, there are two functions that convert the case of letters:
int tolower (c) convert c to lower-case
int toupper (c) convert c to upper-case
267
CipherLab C Programming Part I
268
Chapter 3 Standard Library Routines
void *s;
size_t n;
int c;
void *memcpy (s, ct, n) copy n characters from ct to s, return s
void *memmove (s, ct, n) same as memcpy except that it works fine even if objects
overlap
int memcmp (cs, ct, n) compare first n characters of cs with ct, return as strcmp
void *memchr (cs, c, n) return pointer to first occurrence of character c in cs or NULL if
not present among first n characters
void *memset (s, c, n) place character c into first n characters of s, return s
269
CipherLab C Programming Part I
270
Chapter 3 Standard Library Routines
271
CipherLab C Programming Part I
Diagnostics: <assert.h>
Not supported.
Signals: <signal.h>
Not supported.
272
Chapter 4
REAL-TIME KERNEL
All the mobile computers come with a real-time kernel (µC/OS) that allows user to
generate a preemptive multi-tasking application. User can apply the real-time kernel
functions to split the application into multiple tasks that each task takes turns to gain the
access to the system resource by a priority-based schedule.
µC/OS applies the semaphore mechanism to control the access to the shared resource
for the multiple tasks. Generally, there are only three operations that can be performed
on a semaphore: CREATE, PEND, and POST. A semaphore is a key that the task has to
require so that it can continue execution. If a semaphore is already in use, the requesting
task is suspended until the semaphore is released by its current owner.
A task is an infinite loop function or a function which deletes itself when it is done
executing. Each task is assigned with an appropriate priority. The more important the
task is, the higher the priority given to it. µC/OS can manage up to 32 tasks (with
priority set from 0 to 31, the lower number, the higher priority) for the user program.
The main task, main(), takes priority 16.
A task desiring the semaphore will perform a PEND operation. A task releases the
semaphore by performing a POST operation. If there are several tasks on the pending list,
the task with highest priority waiting for the semaphore will receive the semaphore when
the semaphore is posted. The pending list of tasks is always initially empty.
Semaphores are often overused. Disabling and enabling interrupts could do the job more
efficiently. All real-time kernels will disable interrupts during critical sections of code. You
are thus basically allowed to disable interrupts for as much time as the kernel does
without affecting interrupt latency.
Include File
#include <ucos.h>
This header file, “ucos.h”, contains the function prototypes (declarations) and error
code definitions. This file should normally be placed under the “include” directory of
the C compiler - C:\C_Compiler\INCLUDE\
273
CipherLab C Programming Part I
OS_ENTER_CRITICAL
OS_EXIT_CRITICAL
274
Chapter 4 Real-Time Kernel
OSSemCreate
unsigned value
The initial value of the semaphore, which is allowed to be between 0 and
32767.
Return Value A pointer to the event control block allocated to the semaphore.
If no event control blocks are available, a NULL pointer will be returned.
Remarks This function creates and initializes a semaphore. A semaphore is used to:
Allow a task to synchronize with either an ISR or a task.
Gain exclusive access to a resource.
Signal the occurrence of an event.
Note that semaphores must be created before they are used. This function
cannot be called from an ISR.
275
CipherLab C Programming Part I
OSSemPend
276
Chapter 4 Real-Time Kernel
OSSemPost
277
CipherLab C Programming Part I
OSTaskCreate
278
Chapter 4 Real-Time Kernel
OSTaskDel
OSTimeDly
279
CipherLab C Programming Part I
280
Appendix I
SCANNERDESTBL ARRAYS
IN THIS CHAPTER
Symbology Parameter Table for CCD/LASER/Long Range Reader .............. 281
Symbology Parameter Table for 2D/Extra Long Range Reader .................. 290
SCANNERDESTBL[]
281
CipherLab C Programming Part I
282
Appendix I ScannerDesTbl Array
283
CipherLab C Programming Part I
284
Appendix I ScannerDesTbl Array
285
CipherLab C Programming Part I
286
Appendix I ScannerDesTbl Array
13 7-0 Industrial 25 Min Code Length / Fixed Length 2 Min. 1 CCD, Laser,
8700-Long
Range
15 7-0 Interleaved 25 Min Code Length / Fixed Length 2 Min. 1 CCD, Laser,
8700-Long
Range
287
CipherLab C Programming Part I
17 7-0 Matrix 25 Min Code Length / Fixed Length 2 Min. 1 CCD, Laser,
8700-Long
Range
19 7-0 MSI Min Code Length / Fixed Length 2 Min. 1 CCD, Laser,
8700-Long
Range
21 7-0 Scanner time-out duration in seconds for Aiming mode, 3 sec. CCD, Laser,
Laser mode, Auto Off mode, and Auto Power Off mode 8700-Long
Range
1 ~ 255 (sec): Decode time-out
0: No time-out
288
Appendix I ScannerDesTbl Array
SCANNERDESTBL2[]
289
CipherLab C Programming Part I
SCANNERDESTBL[]
290
Appendix I ScannerDesTbl Array
291
CipherLab C Programming Part I
292
Appendix I ScannerDesTbl Array
293
CipherLab C Programming Part I
19 7–0 MSI Min Code Length / Fixed Length 2 Min. 3 2D, (Extra)
Note Long Range
Length1 must be greater than Length2.
294
Appendix I ScannerDesTbl Array
295
CipherLab C Programming Part I
296
Appendix I ScannerDesTbl Array
33 7-0 Industrial 25 (Discrete 25) Min Code Length / Fixed 0 2D, (Extra)
Length2 Long Range
Note
Length1 must be greater than Length2.
297
CipherLab C Programming Part I
38 7-0 Scanner time-out duration in seconds for Aiming mode, 3 sec. 2D, (Extra)
Laser mode and Auto-off mode Long Range
1 ~ 255 (sec): Decode time-out
0: No time-out (= always scanning)
298
Appendix I ScannerDesTbl Array
299
CipherLab C Programming Part I
300
Appendix I ScannerDesTbl Array
45 --- Bytes 45 ~ 47 are reserved for 8200, 8300, 8400, 8700 --- 2D
~
Bytes 45 ~ 82 are reserved for 8500
82
301
Appendix II
SYMBOLOGY PARAMETERS
Each of the scan engines can decode a number of barcode symbologies. This appendix
describes the associated symbology parameters accordingly.
IN THIS CHAPTER
Scan Engine, CCD or Laser .............................................. 303
Scan Engine, 2D or (Extra) Long Range Laser .................... 319
2D Scan Engine Only ...................................................... 331
CODABAR
ScannerDesTbl[]
303
CipherLab C Programming Part I
CODE 2 OF 5 FAMILY
INDUSTRIAL 25
ScannerDesTbl[]
304
Appendix II Symbology Parameters
Length Qualification
Because of the weak structure of the 2 of 5 symbologies, it is possible to make a “short scan”
error. To prevent the “short scan” error, define the “Length Qualification” settings to ensure that
the correct barcode is read by qualifying the allowable code length.
If “Fixed Length” is selected, up to 2 fixed lengths can be specified.
If “Max/Min Length” is selected, the maximum length and the minimum length must be
specified. It only accepts those barcodes with lengths that fall between max/min lengths
specified.
INTERLEAVED 25
ScannerDesTbl[]
305
CipherLab C Programming Part I
MATRIX 25
ScannerDesTbl[]
306
Appendix II Symbology Parameters
COOP 25
Currently, the support of Coop 25 is implemented on 8000, 8200, 8300, 8400 and 8700.
ScannerDesTbl[]
Note: “Verify Check Digit” must be enabled so that the check digit can be left out when it
is preferred not to transmit the check digit.
CODE 39
ScannerDesTbl[]
307
CipherLab C Programming Part I
CODE 93
ScannerDesTbl[]
308
Appendix II Symbology Parameters
ScannerDesTbl[]
ITALIAN/FRENCH PHARMACODE
ScannerDesTbl[]
309
CipherLab C Programming Part I
Decide whether or not to include the check digit in the data being transmitted.
Note: Share the Transmit Start/Stop Character setting with Code 39.
MSI
ScannerDesTbl[]
310
Appendix II Symbology Parameters
Length Qualification
Because of the weak structure of the symbology, it is possible to make a “short scan” error. To
prevent the “short scan” error, define the “Length Qualification” settings to ensure that the correct
barcode is read by qualifying the allowable code length.
If “Fixed Length” is selected, up to 2 fixed lengths can be specified.
If “Max/Min Length” is selected, the maximum length and the minimum length must be
specified. It only accepts those barcodes with lengths that fall between max/min lengths
specified.
NEGATIVE BARCODE
ScannerDesTbl[]
PLESSEY
ScannerDesTbl[]
Convert to UK Plessey
Decide whether or not to change each occurrence of the character 'A' to character 'X' in the
decoded data.
311
CipherLab C Programming Part I
ScannerDesTbl[]
Transmit Code ID
Decide whether or not to include the Code ID (“]e0”) in the data being transmitted.
Transmit Application ID
Decide whether or not to include the Application ID (“01”) in the data being transmitted.
312
Appendix II Symbology Parameters
TELEPEN
ScannerDesTbl[]
UPC/EAN FAMILIES
EAN-8
ScannerDesTbl[]
313
CipherLab C Programming Part I
Decide whether or not to expand the read EAN-8 barcode into EAN-13. If true, the next
processing will follow the parameters configured for EAN-13.
EAN-13
ScannerDesTbl[]
ScannerDesTbl2[]
314
Appendix II Symbology Parameters
315
CipherLab C Programming Part I
GTIN
ScannerDesTbl[]
UPC-A
ScannerDesTbl[]
Note: UPC-A is to be enabled together with EAN-13, therefore, check associated EAN-13
settings first.
316
Appendix II Symbology Parameters
UPC-E
ScannerDesTbl[]
317
CipherLab C Programming Part I
ScannerDesTbl2[]
318
Appendix II Symbology Parameters
CODABAR
ScannerDesTbl[]
Length Qualification
The barcode can be qualified by “Fixed Length” or “Max/Min Length”. The length of a barcode
refers to the number of characters (= human readable characters), including check digit(s) it
contains.
If “Fixed Length” is selected, up to 2 fixed lengths can be specified.
If “Max/Min Length” is selected, the maximum length and the minimum length must be
specified. It only accepts those barcodes with lengths that fall between max/min lengths
specified.
Note: When it is configured to use Fixed Length format, Length1 must be greater than
Length2. Otherwise, the format will be converted to Max/Min Length Format, and
Length1 becomes Min. Length while Length2 becomes Max. Length. In either length
format, when both of the values are configured to 0, it means no limit in length.
319
CipherLab C Programming Part I
CODE 2 OF 5
ScannerDesTbl[]
Length Qualification
Because of the weak structure of the 2 of 5 symbologies, it is possible to make a “short scan”
error. To prevent the “short scan” error, define the “Length Qualification” settings to ensure that
the correct barcode is read by qualifying the allowable code length. Refer to Codabar.
INTERLEAVED 25
ScannerDesTbl[]
320
Appendix II Symbology Parameters
Length Qualification
Because of the weak structure of the 2 of 5 symbologies, it is possible to make a “short scan”
error. To prevent the “short scan” error, define the “Length Qualification” settings to ensure that
the correct barcode is read by qualifying the allowable code length. Refer to Codabar.
Convert to EAN-13
Decide whether or not to convert a 14-character Interleaved 25 barcode into EAN-13. If true, the
next processing will follow the parameters configured for EAN-13.
Interleaved 25 barcode must have a leading zero and a valid EAN-13 check digit.
CODE 39
ScannerDesTbl[]
321
CipherLab C Programming Part I
Note: “Verify Check Digit” must be enabled so that the check digit can be left out when it
is preferred not to transmit the check digit.
Length Qualification
Refer to Codabar.
CODE 93
ScannerDesTbl[]
Length Qualification
Refer to Codabar.
322
Appendix II Symbology Parameters
CODE 128
CODE 128
ScannerDesTbl[]
ISBT 128
ScannerDesTbl[]
Note: ISBT 128 is a variant of Code 128 used in the blood bank industry.
UCC/EAN-128
ScannerDesTbl[]
MSI
ScannerDesTbl[]
323
CipherLab C Programming Part I
Length Qualification
Because of the weak structure of the symbology, it is possible to make a “short scan” error. To
prevent the “short scan” error, define the “Length Qualification” settings to ensure that the correct
barcode is read by qualifying the allowable code length. Refer to Codabar.
324
Appendix II Symbology Parameters
ScannerDesTbl[]
325
CipherLab C Programming Part I
UPC/EAN FAMILIES
The UPC/EAN families include No Addon, Addon 2, and Addon 5 for the following
symbologies:
UPC-E0
UPC-E1
UPC-A
EAN-8
EAN-13
Bookland EAN (ISBN)
For any member belonging to the UPC/EAN families, Bit 0 of Byte 25 is used to decide
the joint configuration of No Addon, Addon 2, and Addon 5. Other parameters are listed
below.
ScannerDesTbl[]
326
Appendix II Symbology Parameters
327
CipherLab C Programming Part I
ScannerDesTbl[]
JOINT CONFIGURATION
ScannerDesTbl[]
When Results in
Byte 25 - bit 0 Byte/bit listed in Byte/bit listed in No Addon Addon 2 & 5
Table A Table B
=1 =1 N/A Enabled Enabled
=1 =0 N/A Disabled Disabled
Note
=0 N/A Any = 1 Disabled EnabledNote
(All) (All)
=0 =1 All = 0 Enabled DisabledNote
(All)
=0 =0 All = 0 Disabled DisabledNote
(All)
Note: The result marked with “All” indicates it occurs with the whole UPC/EAN families.
328
Appendix II Symbology Parameters
Table A
Note: (1) If Byte 25 - bit 0 is set to 1, No Addon, Addon 2, Addon 5 of the symbology
are enabled. (2) If Byte 25 - bit 0 is set to 0 (and all bits in Table B below must be set 0):
Only No Addon of the symbology is enabled.
Table B
329
CipherLab C Programming Part I
CODE 11
The support of Code 11 on Long Range scan engine is currently implemented for 8300
only.
ScannerDesTbl[]
Length Qualification
The barcode can be qualified by “Fixed Length” or “Max/Min Length”. The length of a barcode
refers to the number of characters (= human readable characters), including check digit(s) it
contains.
If “Fixed Length” is selected, up to 2 fixed lengths can be specified.
If “Max/Min Length” is selected, the maximum length and the minimum length must be
specified. It only accepts those barcodes with lengths that fall between max/min lengths
specified.
Note: When it is configured to use Fixed Length format, Length1 must be greater than
Length2. Otherwise, the format will be converted to Max/Min Length Format, and
Length1 becomes Min. Length while Length2 becomes Max. Length. In either length
format, when both of the values are configured to 0, it means no limit in length.
330
Appendix II Symbology Parameters
In addition to those symbologies described previously, the 2D scan engine supports the
following symbologies:
1D SYMBOLOGIES
CHINESE 25
ScannerDesTbl[]
MATRIX 25
ScannerDesTbl[]
ScannerDesTbl[]
331
CipherLab C Programming Part I
1D INVERSE
ScannerDesTbl[]
332
Appendix II Symbology Parameters
ScannerDesTbl[]
333
CipherLab C Programming Part I
COMPOSITE CODES
CC-A/B/C
ScannerDesTbl[]
TLC-39
ScannerDesTbl[]
334
Appendix II Symbology Parameters
UPC COMPOSITE
ScannerDesTbl[]
Note: If “UPC Always Linked” is enabled, either CC-A/B or CC-C must be enabled.
Otherwise, it will not transmit even there are UPC barcodes.
ScannerDesTbl[]
335
CipherLab C Programming Part I
2D SYMBOLOGIES
ScannerDesTbl[]
2D INVERSE/MIRROR
ScannerDesTbl[]
336
Appendix II Symbology Parameters
PDF417
ScannerDesTbl[]
337
CipherLab C Programming Part I
Decide whether or not to transmit the Escape character. If true, it uses the backslash “\” as an
Escape character for systems that can process transmissions containing special data sequences.
It will format special data according to the Global Label Identifier (GLI) protocol, which only
affects the data portion of a Macro PDF symbol transmission. The Control Header is always
sent with GLI formatting.
338
Appendix III
SCANNER PARAMETERS
This appendix describes the associated scanner parameters.
IN THIS CHAPTER
Scan Mode ..................................................................... 339
Read Redundancy ........................................................... 342
Time-Out ....................................................................... 343
User Preferences ............................................................ 343
SCAN MODE
Byte 20 of the unsigned character array ScannerDesTbl is used to define a scan mode
that best suits the requirements of a specific application. Refer to Time-Out.
339
CipherLab C Programming Part I
For CCD or Laser scan engine, it supports 9 scan modes. See the comparison table
below. Byte 21 is used for timeout duration, if necessary.
For (Extra) Long Range Laser scan engine, it only supports Laser and Aiming modes.
When in aiming mode, it will generate an aiming dot once you press the trigger key.
The aiming dot will not go off until it times out or you press the trigger key again to
start scanning. Byte 38 is used for timeout duration, if necessary.
COMPARISON TABLE
Test mode
Repeat mode
Momentary mode
Alternate mode
Aiming mode
Laser mode
Continuous Mode
Non-stop scanning
To decode the same barcode repeatedly, move away the scan beam and target it at the
barcode for each scanning.
Test Mode
Non-stop scanning (for testing purpose)
Capable of decoding the same barcode repeatedly.
Repeat Mode
Non-stop scanning
Capable of re-transmitting barcode data if triggering within one second after a successful
decoding.
Such re-transmission can be activated as many times as needed, as long as the time interval
between each triggering does not exceed one second.
340
Appendix III Scanner Parameters
Momentary Mode
Hold down the scan trigger to start with scanning.
The scanning won't stop until you release the trigger.
Alternate Mode
Press the scan trigger to start with scanning.
The scanning won't stop until you press the trigger again.
Aiming Mode
Press the scan trigger to aim at a barcode. Within one second, press the trigger again to decode
the barcode.
The scanning won't stop until (a) a barcode is decoded, (b) the preset timeout expires, or (c)
you release the trigger.
Note: The system global variable AIMING_TIMEOUT can be used to change the default
one-second timeout interval for aiming. The unit for this variable is 5 ms.
Laser Mode
Hold down the scan trigger to start with scanning.
The scanning won't stop until (a) a barcode is decoded, (b) the preset timeout expires, or (c)
you release the trigger.
341
CipherLab C Programming Part I
READ REDUNDANCY
This parameter is used to specify the level of reading security. You will have to
compromise between reading security and decoding speed.
342
Appendix III Scanner Parameters
TIME-OUT
These parameters are used to limit the maximum scanning time interval for a specific
scan mode.
Note: For aiming time-out duration for Aiming mode, use global variable
AIMING_TIMEOUT. Refer to 2.1.3 System Global Variables.
USER PREFERENCES
Note: Picklist mode enables the decoder to decode only barcodes aligned under the
center of the laser aiming pattern.
Note: If the reader is powered off during system suspend, it will save battery power.
However, it takes about 3 seconds to restart the power after system resumes.
343
CipherLab C Programming Part I
344
INDEX
_ D
_KeepAlive__ • 22 DayOfWeek • 84
DecContrast • 104
A Decode • 56
access • 144 delete_member • 166
ActivateProgram • 41 delete_top • 151
add_member • 162 delete_topln • 152
AIMING_TIMEOUT • 27 DeleteBank • 41
append • 147 DeviceType • 30
appendln • 148 dis_alpha • 95
AUTO_OFF • 27 DownLoadPage • 49
DownLoadProgram • 42
B
E
BC_X • 28
BC_Y • 28 en_alpha • 95
beeper_status • 78 eof • 153
BKLIT_TIMEOUT • 27 EraseSector • 139
BootloaderVersion • 33
F
C fclose • 199
ChangeSpeed • 22 fclosedir • 199
charger_status • 88 fcopy • 200, 213
CheckFont • 132 feof • 200
CheckKey • 90 ferror • 218
CheckKeyEnter • 103 fflush • 201
CheckPasswordActive • 37 fformat • 201
CheckSysPassword • 37 ffreebyte • 141
CheckWakeUp • 23 fgetc • 202
chmod • 197 fgetinfo • 202
chmodfp • 198 fgetpos • 203
chsize • 149 fgets • 204
circle • 125 filelength • 153
close • 150 filelist • 144
close_DBF • 163 fill_rect • 114
clr_eol • 120 FlashSize • 139
clr_icon • 120 FontVersion • 33
clr_kb • 91 fopen • 205
clr_rect • 120 fopendir • 206
clr_scr • 121 fputc • 206
CodeBuf • 54 fputs • 207
CodeLen • 55 fread • 208
CodeType • 54, 55 freaddir • 209
Configure_Reader • 55 free_memory • 140
create_DBF • 164 fremove • 209
create_index • 165 frename • 210
fscan • 210
fseek • 211
CipherLab C Programming Part I
L rectangle • 126
remove • 145
lcd_backlit • 107, 108 remove_index • 174
LibraryVersion • 34 rename • 146
line • 125 RFIDReadFormat • 66
LoadProgram • 43 RFIDVersion • 36
LockAlphaState • 97 RFIDWriteFormat • 66
lseek • 154 rmdir • 214
lseek_DBF • 169
S
M
SaveSysPassword • 38
ManufactureDate • 34 ScannerDesTbl • 54
member_in_DBF • 170 SDtoRAM_DAT • 180
mkdir • 214 SDtoRAM_DBF • 184, 185
N SendData • 70
SerialNumber • 36
NetVersion • 35 set_alpha_lock • 97
O set_beeper_vol • 78
set_led • 81
off_beeper • 79 set_shift_lock • 98
on_beeper • 79 set_time • 85
open • 155 SetAlarm • 86
open_DBF • 171 SetAltKey • 99
OriginalSerialNumber • 35 SetAutoBklit • 108
OS_ENTER_CRITICAL • 274 SetBklitControl • 110
OS_EXIT_CRITICAL • 274 SetBklitLevel • 107
OSKToggle • 94 SetContrast • 105
OSSemCreate • 275 SetContrastControl • 111
OSSemPend • 276 SetCursor • 112
OSSemPost • 277 SetFont • 134
OSTaskCreate • 278 SetFuncExtKey • 102
OSTaskDel • 279 SetFuncToggle • 101
OSTimeDly • 279 SetHeaterMode • 83
SetKeyClick • 94
P
SetLanguage • 135
play • 80 SetMenuPauseTime • 53
POWER_ON • 27 SetMiddleEnter • 103, 104
prc_menu • 51 SetPistolEnter • 104
printf • 116 SetPwrKey • 25
ProgramInfo • 43 SetRFIDSecurityKey • 68
ProgramManager • 44 SetTrigger • 94
ProgVersion • 29 SetUSBChargeCurrent • 89
putch • 93 SetVibrator • 82
putchar • 118 SetVideoMode • 106
putpixel • 126 show_image • 123
puts • 118 shut_down • 25
SignatureCapture • 129
R sys_msec • 27
RamSize • 140 sys_sec • 27
RAMtoSD_DAT • 178 SysSuspend • 25
RAMtoSD_DBF • 182 system_restart • 25
read • 156
T
read_error_code • 145
readln • 157 tell • 158
rebuild_index • 172 tell_DBF • 175
CipherLab C Programming Part I
TriggerStatus • 94
U
UnpackDBF • 176
update_member • 177
UpdateBank • 44
UpdateBootloader • 45
UpdateKernel • 46
UpdateUser • 47
W
WaitHourglass • 119
WakeUp_Event_Mask • 28
WedgeReady • 70
WEDGESETTING • 69
wherex • 113
wherexy • 113
wherey • 113
write • 159
WriteFlash • 139
writeln • 160