HT630 Application Note For C Language
HT630 Application Note For C Language
Application Note
Chapter 1 Introduction
This Application Note Guide demonstrates some application examples that will help users to develop
quickly and efficiently for their applications. Since the system of PT630 is an open architecture, you are
able to write a program run on PT630 to fully control its input/output facilities or have a complicate
accumulation, data validation or table look up features for your application program. The PT630 provides
an MS-DOS compatible platform that allows the user to write his application program by the following
programming tools.
JobGen Plus, a Windows base program generator that requiring the minimum programming
skills. Please contact your local distributor or dealer for more detailed information.
Microsoft C version 5.x, 6.x, 7.x or 8.x for MSDOS application
Microsoft Visual C/C++ V1.xx for MSDOS application
Borland C or Turbo C for MSDOS application
Macro Assembler for MSDOS application
1.2 Why C
If you are familiar with Microsoft C or other equivalent C programming language, you may adopt one of
them as your programming tool to develop your application program and download it into the PT630.
Or if the JobGen Plus can not meet your requirement, the C language is recommended to be adopted, due
to the size of its executable object program is compact. The executable file generated by C compiler can
be downloaded to and run on PT630.
1) The DOS-compatible system of PT630 supports part of MS/DOS system and uses different BIOS
calls for its hardware driver. Some functions in the run-time library of your C programming tool kit
PT630 Application Notes Page: 2
are not supported by PT630. Please refer to PT630 Programming Reference Manual for more
detailed information to write C program to comply PT630’s system.
2) Select the small or large memory model to compile your program, according to its memory
requirement. Using parameter /AS or /AL or /AH to compile your program, according to its memory
requirement. Remember that the available memory of your PT630 terminal is limited.
Following notes will help you to develop application programs more efficiently and reliably.
Communication environment
Compatibility
1) The PT630 doesn’t support PC BIOS function call, you should not use them in your program.
2) Programs compiled by Microsoft C, Borland C and Microsoft Assembly (8088 instruction set) can
be executed on the PT630.
PT630 Application Notes Page: 4
STEP 1. Open/create the necessary files for read/write, depended on the usage purpose.
STEP 2. Secure your application, recommended.
STEP 3. Change the keypad mapping table, if you have your own keypad layout or definition.
STEP 4. Setup communication parameters.
STEP 5. Enable the communication port and designate the protocol used.
STEP 6. Enable the devices which will be used for data collection or signal controlling.
STEP 7. Disable the barcode symbologies which will not be used. (the system default is all enabled)
STEP 8. Prompt the message on terminal LCD display.
STEP 9. Execute INT22 to force PT630 go to Standby mode for saving PT630's battery power, it
will be waked up to Active mode when key-pressing, scanning or receiving data from
R232.
STEP 10. Scanning the available devices for data input or signal occurred.
STEP 11. Processing and validating the data or signal.
STEP 12. Store input data into RAM disk.
STEP 13. Go back to step 8 for next processing, or exit program.
STEP 14. Restore the system default keypad mapping table, if you have changed it in step 3.
STEP 15. Exit program.
PT630 Application Notes Page: 5
2 -- 600
3 -- 800
4 -- 1K
5 -- 2K
6 -- 2.5K
7 -- 3K
8 -- 5K
tm:Time Duration(ms) 0 -- 10
1 -- 50
2 -- 100
3 -- 200
4 -- 500
5 -- 800
6 -- 1K
7 -- 1.5K
8 -- 2K
1 -- disable
BOOL HM_get_power_saving_status();
Function description
Get Power saving status
Parameter
no
Return
True/False
int HM_get_power_saving_return();
Function description
When HM_set_power_saving_status(TRUE). System will keep the return code of Power saving
on/off setting in one variable. Use can get this return code by this function
Return:
0,3,4,5,6 (Please return value table)
long HM_get_time_out();
Function description
Get current time-out time setting
Return:
mini-second (Default is 400L = 0.4 second)
int HM_get_ESC_delay()
Function description
Get ESC delay time (milliseconds)
Return
PT630 Application Notes Page: 21
int HM_get_NAK_delay()
Function description
Get NAK delay time
Return:
the number of milliseconds to be delay
for MR350/360/380
byte 0 : Code 39 N: enable D: disable F: full
byte 1 : I 2 of 5 N: enable F: disable
byte 2 : Codar bar N: enable F: disable
byte 3 : EAN/UPC N: enable F: disable
byte 4 : Code 128 N: enable F: disable
for PT700
byte 0 : Code 39 E: enable D: disable F: full
byte 1 : I 2 of 5 E: enable D: disable
byte 2 : Codar bar E: enable D: disable
byte 3 : EAN/UPC E: enable D: disable
byte 4 : Code 128 E: enable D: disable
byte 5 : EAN 128 E: enable D: disable
byte 6 : Code 93 E: enable D: disable
byte 7 : Trioptic E: enable D: disable
Returns
0,2,3,4,5,6 (Please return value table)
int HM_download(UINT port, char address, char FAR* sour_name, char FAR* dest_name);
Function description
Download specified file to terminal(This function will not exit until download complete . If user
want to show bytes count or packet count , please use HM_download1 and HM_download2)
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
sour_name :File name in PC to be download
PT630 Application Notes Page: 25
int HM_download1(UINT port, char address, char FAR* sour_name, char FAR* dest_name,
long FAR* lTotalLength);
Function description
Download specified file to terminal (just check file and send first packet). This function must
combine with HM_download2.
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
sour_name :File name in PC to be download
dest_name :Assign new file name in terminal
lTotalLength :size of specified file
Returns
0,2,3,4,5,6,0x30 (Please return value table)
Example:
long lTotalLength;
if (HM_download1(1,'A',"ABC.DAT","DEF.DAT",&lTotalLength) == 0)
{
do {
ret = HM_download2(&lByteCounter,&lPacketCounter);
Invalidate(FALSE);
} while (ret == 1);
}
Function description
Check the program name that currently running on terminal
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
file_name :store file name that is running on terminal
Returns
0,3,4,5,6,0x35 (Please return value table)
int HM_poll(UINT port, char address, unsigned char FAR* data_buf, int FAR* data_len)
Function description
Poll data from terminal
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
data_buf :store polled data
data_len :length of poll data
Returns
0,3,4,5,7 (Please return value table)
int HM_ram_size(UINT port, char address, int FAR* t_size, int FAR* e_size, int FAR* f_size,
int FAR* et_size, int FAR* ef_size);
Function description
Get terminal's memory size
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
t_size :Total memory size
e_size :Execution area size
f_size :Free RAM disk size
et_size :Total EMS RAM disk size (If EMS exist)
ef_size :Free EMS RAM disk size (If EMS exist)
Returns
0,3,4,5,6 (Please return value table)
int HM_sendback(UINT port, char address, char FAR* in_buf, char FAR* out_buf)
Function description
Send and receive check
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
in_buf :data to be sent
out_buf :received data
Returns
0,3,4,5 (Please return value table)
int HM_upload(UINT port, char address, char FAR* sour_name, char FAR* dest_name)
Function description
PT630 Application Notes Page: 29
Upload specified file from terminal (This function will not exit until whole file is uploaded. So
user must wait for a while when file’s size is big. If user want to monitor the status of each
packet ,please use HM_upload1 and HM_upload2)
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
sour_name :File name in terminal to be upload
dest_name :Assign new file name in PC (include path) If this new file was exist in PC,
system will change it to non-exist file name automatically)
Returns
0,3,4,5,0x30,0x33,0x34 (Please return value table)
int HM_upload1(UINT port, char address, char FAR *sour_name, char FAR *dest_name)
Function description
Upload specified file from terminal (just check file and send first packet).This function must
combine with HM_upload2.
Parameter
port :COM port
1-n for COM1 - COMn
address :Terminal address range form 'A'-'Y', '0'-'6'
sour_name :File name in terminal to be upload
dest_name :Assign new file name in PC (include path), If this new file was exist in PC, system
will change it to non-exist file name automatically)
Returns
0,3,4,5,0x30,0x33,0x34 (Please return value table)
Example :
char fn[100];
strcpy(fn,"C:\\DEF.DAT");
if (HM_upload1(1,'A',"ABC.DAT","C:\\DEF.DAT") ==0)
{
strcpy(cUploadSaveAs,chg_name);
do {
ret = HM_upload2(&lByteCounter,&lPacketCounter);
Invalidate(FALSE);
} while (ret == 1);
}
int HM_file_exist(UINT port, char address, char FAR* fn, long FAR* len);
Function description
Check whether specified file is exist in terminal
Parameter
port :COM port
PT630 Application Notes Page: 31
Returns : No
int HM_get_upload_file_save_mode()
Function Description:
Get mode of how to save file uploaded from terminal
Parameter: no
Return : save mode (Default is 0)
0 -- Search for an available file(not exist)
1 -- Over-write target file
2 -- Append to target file
int HM_version()
Function Description:
Get DLL version no.
Returns : Version No.
0 Successfully
0x01 Unsuccessful or successflly download/upload one
packed
0x02 Illegal command
0x03 Host get NAK
0x04 Time out
0x05 Get unknown response
0x06 Return string BBC error
0x07 No data to be enquired
0x08 User press ESC to break
0x09 Set Power saving off fail
0x10 Power failure
0x11 Processor exception occurred
0x12 Reset by host
0x13 User reset
0x14 Application reset
0x15 Cold start
0x16 Warm start
0x20 Terminal in diagnostic state
0x21 Terminal already start
0x22 Invalid number of parameter
0x30 File doesn't exist
0x31 Illegal file name
0x32 File already exist ,upload file name to be changed
0x33 File already exist ,system can't change file name
0x34 File open error
0x35 No program is executed
0x40 RAM disk isn't empty
0x41 Out of memory size
0x50 Upload mode
200 Timeout
PT630 Application Notes Page: 36
File description
Dir \VB
MULTIDLL.DLL DLL(This file is same with \32bit\dll32\multidll.dll)
MULTI.BAS Communication Function declare module (Please insert
this file to your application as Module)
Dir \VB\Sample
Project1.exe Test program (VB 4.0)
Project1.MAK Make file
FORM1.FRM form1 source
Multi.bas Declare module
Sub HM_CloseCommPort(port)
Function Description:
Close communication COM port
Parameter: [input]
port :ByVal As long :Serial COM port
1-n for COM1 - COMn
Return : No
Sub HM_time_delay(time_period)
Function description
Delay specify time period
Parameter: [input]
time_period : ByVal As long : the number of milliseconds that have elapsed
Sub HM_set_power_saving_status(status)
Function description:
For the portable terminal (700/870) , user must execute power saving command before and after
each ESC command. This function will set whether each ESC command do power saving
setting before and after each command or not.
For example , if status is set TRUE , each ESC command will do follow step
1. Remote set power saving off, if OK do next step.
If fail return 9 then. User can execute HM_get_power_saving_return() to get error code
2. If step 1 OK, do the ESC command you call
3. Remote set power saving on, User can execute HM_get_power_saving_ return() to get
return code of power saving on setting
If status is set False , each ESC command only execute step 2 (POLL command is not
include , use must execute power saving command by himself).
Parameter [input]
PT630 Application Notes Page: 38
Function HM_get_power_saving_status()
Function description
Get Power saving status (please see HM_set_power_saving_status)
Parameter : no
Return : As Boolean
True/False
Function HM_get_power_saving_return()
Function description
When HM_set_power_saving_status(TRUE). System will keep the return code of remote power
saving setting in one variable. Use can get this return code by this function
Parameter : No
Return: As long
0,3,4,5,6 (Please see return value table)
Function HM_get_time_out()
Function description
Get current time-out time setting
Return: As Long
mini-second (Default is 400 = 0.4 second)
Sub HM_set_time_out(delay_time)
Function description
Set current time-out period
Parameter [input]
delay_time: ByVal As Long :mini-second, Default is 400 = 0.4 second
Sub HM_set_ESC_delay(delay_time)
Function description
After each ESC command executed. MULTI.DLL will delay this time period default time is 10
milliseconds for on-line terminal or 30 for portable terminal
Parameter: [input]
time_delay : ByVal As long :the number of milliseconds to be delay
Function HM_get_ESC_delay()
Function description
Get ESC delay time (milliseconds)
Return : As long :the number of milliseconds to be delay
Sub HM_set_NAK_delay(delay_time)
Function description
When NAK response is got ,system will delay this time period before do re-try. The default
value is 100 for portable terminal or 30 for on-line
Parameter [input]
time_delay: ByVal As long :the number of milliseconds to be delay
Function HM_get_NAK_delay()
PT630 Application Notes Page: 40
Function description
Get NAK delay time
Return: As long :the number of milliseconds to be delay
PT630 Application Notes Page: 41
byte 8 : always F
for PT700/870/860
byte 0-3 same with MR350
byte 4 : Flow control : F-none, C-CTS/RTS, X-Xon/Xoff
byte 5 : Protocol : F-none, M-multi, N-Null, A-ACK/NAK
byte 6 : Address : Terminal address range form 'A'-'Y', '0'-'6'
byte 7-9 : always SPACE
Returns : As long
0,2,3,4,5,6 (Please see return value table)
65-89, 48-54
fname : ByVal As String :File name to be executed (without file extension)
Returns :As long
0,3,4,5,6,0x30,ox31 (Please see return value table)
Function description
Terminal enter Kermit server mode
Parameter [input]
port :ByVal As long :Serial COM port
1-n for COM1 - COMn
address :ByVal As Byte :Terminal address range form 'A'-'Y', '0'-'6'
65-89, 48-54
Returns : As long
0,3,4,5 (Please see return value table)
Returns : As long
0,3,4,5,6,0x30 (Please see return value table)
Add new return code 0x36 -- When file is existed on flash ROM
Function HC_getch(Port)
Function description
Get one byte (character) from COM port
Parameter [input]
port :ByVal As long :Serial COM port
1-n for COM1 - COMn
Returns : As Byte
ASCII 0 ~ 254
ASCII 255 = no character input
PT630 Application Notes Page: 56
Sub HC_puttch(Port,cc)
Function description
Output one byte (character) to COM port
Parameter [input]
port :ByVal As long :Serial COM port
1-n for COM1 - COMn
cc :ByVal As Byte :output character
ASCII 0 ~ 254
Returns : No
Sub HM_set_upload_file_save_mode(mode)
Function Description:
Setup how to save file uploaded from terminal
Parameter [input]:
mode :ByVal As long : Save mode (Default is 0)
0 -- Search for an available file(not exist)
1 -- Over-write target file
2 -- Append to target file
Function HM_get_upload_file_save_mode()
Function Description:
Get mode of how to save file uploaded from terminal
Parameter [input]: no
Return : As long
0 -- Search for an available file(not exist)
1 -- Over-write target file
2 -- Append to target file
PT630 Application Notes Page: 57
Function HM_version()
Function Description:
Get DLL version no
Parameter [input]: no
Return : As long
3 NO CARRIER
4 ERROR
6 NO DIALTONE
7 BUSY
8 NO ANSWER
24 DELAYED
32 BLACKLISTED
33 FAX
35 DATA
40 CARRIER
200 Timeout
PT630 Application Notes Page: 59
procedure HM_CloseCommPort(port)
Function Description:
Close communication COM port
Parameter: [input]
port : UINT :Serial COM port
1-n for COM1 - COMn
procedure HM_time_delay(time_period)
Function description
Delay specify time period
Parameter: [input]
time_period : integer : the number of milliseconds that have elapsed
PT630 Application Notes Page: 61
procedure HM_set_power_saving_status(status)
function description
For the portable terminal (700/870) , user must execute power saving command before and after
each ESC command. This function will set whether each ESC command do power saving
setting before and after each command or not.
For example , if status is set TRUE , each ESC command will do follow step
1. Remote set power saving off, if OK do next step.
If fail return 9 then. User can execute HM_get_power_saving_return() to
get error code
2. If step 1 OK, do the ESC command you call
3. Remote set power saving on, User can execute HM_get_power_saving_ return() to get
return code of power saving on setting
If status is set False , each ESC command only execute step 2
(POLL command is not include , use must execute power saving command by himself).
Parameter [input]
status : BOOL
True for remote setting power saving
False for NOT remote setting power saving
procedure HM_get_power_saving_status()
function description
Get Power saving status (please see HM_set_power_saving_status)
Parameter : no
Return : BOOL
True/False
function HM_get_power_saving_return()
Function description
When HM_set_power_saving_status(TRUE). System will keep the return code of remote power
saving setting in one variable. Use can get this return code by this function
Return : integer
0,3,4,5,6 (Please see return value table)
PT630 Application Notes Page: 62
function HM_get_time_out()
Function description
Get current time-out time setting
Return : longint
mini-second (Default is 400 = 0.4 second)
procedure HM_set_time_out(delay_time)
Function description
Set current time-out period
Parameter [input]
delay_time : longint :mini-second
Default is 400 = 0.4 second
procedure HM_set_ESC_delay(delay_time)
Function description
After each ESC command executed. MULTI.DLL will delay this time period default time is 10
milliseconds for on-line terminal or 30 for portable terminal
Parameter: [input]
time_delay : integer :the number of milliseconds to be delay
function HM_get_ESC_delay()
Function description
Get ESC delay time (milliseconds)
Return : integer :the number of milliseconds to be delay
procedure HM_set_NAK_delay(delay_time)
Function description
When NAK response is got ,system will delay this time period before do re-try. The default
value is 100 for portable terminal or 30 for on-line
Parameter [input]
time_delay :integer :the number of milliseconds to be delay
function HM_get_NAK_delay()
Function description
Get NAK delay time
Return : integer :the number of milliseconds to be delay
Function description
Set file name that terminal will auto-execute after power on
Parameter [input]
port : UINT :Serial COM port
1-n for COM1 - COMn
address : char :Terminal address range form 'A'-'Y', '0'-'6'
fn : PChar :File name (without file extention)
Returns : integer
0,3,4,5,6,0x30,0x31 (Please see return value table)
Returns : integer
0,2,3,4,5,6 (Please see return value table)
Repeat
ret := HM_download2(Addr(lByteCounter), Addr(lPacketCounter));
{ print packet counter and bytes counter }
until ret <> 1;
end;
end;
HM_CloseCommPort(2);
Returns : integer
0,3,4,5,6,0x40,ox41 (Please see return value table)
Parameter [input]
port : UINT :Serial COM port
1-n for COM1 - COMn
address : char :Terminal address range form 'A'-'Y', '0'-'6'
Parameter [output]
data_buf : PChar :store polled data
data_len : pointer (integer) :length of poll data
Returns : integer
0,3,4,5,7 (Please see return value table)
Returns : integer
0,3,4,5,0x50 (Please see return value table)
Function description
Get terminal's directory from flash ROM
Parameter
port : UINT :Serial COM port
1-n for COM1 - COMn
address : char :Terminal address range form 'A'-'Y', '0'-'6'
Parameter [output]
str : PChar :Buffer for directory
Returns :integer
0,3,4,5,6 (Please see return value table)
function HM_cancel_download(port;address)
Function description
Cancel download
Parameter
port : UINT :Serial COM port
1-n for COM1 - COMn
address : char :Terminal address range form 'A'-'Y', '0'-'6'
Returns :0,3,4,5,6 (Please return value table)
9 for HM_set_power_saving_status(TRUE)
Parameter [input]
port : UINT :Serial COM port
1-n for COM1 - COMn
address : char :Terminal address range form 'A'-'Y', '0'-'6'
Parameter [output]
str : PChar :Terminal type and version no
returns :0,3,4,5,6 (Please return value table)
9 for HM_set_power_saving_status(TRUE)
Function HC_getch(Port)
Function description
Get one byte (character) from COM port
Parameter [input]
port : UINT :Serial COM port
1-n for COM1 - COMn
Returns : char
ASCII 0 ~ 254
ASCII 255 = no character input
procedure HC_puttch(Port,cc)
Function description
Output one byte (character) to COM port
Parameter [input]
port : UINT :Serial COM port
1-n for COM1 - COMn
cc : char :output character
ASCII 0 ~ 254
Returns : No
procedure HM_set_upload_file_save_mode(mode)
Function description :
Setup how to save file uploaded from terminal
Parameter:[input]
mode : integer
0 -- Search for an available file(not exist)
1 -- Over-write target file
2 -- Append to target file
function HM_get_upload_file_save_mode()
Function description
Get mode of how to save file uploaded from terminal
Parameter: no
return : integer
0 -- Search for an available file(not exist)
1 -- Over-write target file
2 -- Append to target file
function HM_version()
Function description
Get DLL version
Parameter: no
Return : integer