Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 4 of 42

JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 31 to 40

Pages 31 to 40 of 414

The original document is the PDF (690 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Intermec J2020, Intermec J2010 and Intermec J2050

Page 31

C Language Support

2

This chapter describes how to compile and link applications in C using the Programmer’s Software Kit (PSK) library functions. It also provides the syntax and parameters for each function.

Building Your Program Using Borland C/C++ Use the following procedure to compile and link a C/C++ program that uses the Borland C/C++ library functions that you installed from the PSK disk. You will use one make file and one example program: XCDEMO.PRJ

Sample make file to create XCDEMO.EXE.

XDEMO.PRJ

Sample make file to create XDEMO.EXE.

XCDEMO.C

Sample reader program using im_receive_input.

XDEMO.C

Sample reader program using IRL-like functions.

If you are building your own program, make sure that you set the following options. The sample programs already include these settings: • The project must be set to create a DOS-executable file. • The memory model must be set to the Large compilation model.

To build a sample program using Borland C/C++ 1. Start the Borland Programmer’s Platform from Microsoft Windows. 2. Open the project file XDEMO.PRJ or XCDEMO.PRJ from: \INTERMEC\BORLANDC\SAMPLES 3. Open XDEMO.C or XCDEMO.C from: \INTERMEC\BORLANDC\SAMPLES 4. From the Options menu, set the Directories to the directory containing your Borland C include files and your Borland C library files: \BORLANDC\INCLUDE;\INTERMEC\BORLANDC\INCLUDE \BORLANDC\LIB;\INTERMEC\BORLANDC\LIB 5. Compile and link the demo program.

2-3

Page 32

JANUS PSK for C/C++ Reference Manual

Building Your Program Using Microsoft C/C++ Use the following procedure to compile and link a C/C++ program that uses the Microsoft C/C++ library functions that you installed from the PSK disk. You will use one make file and one example program: XCDEMO.MAK Sample make file to create XCDEMO.EXE. XDEMO.MAK

Sample make file to create XDEMO.EXE.

XCDEMO.C

Sample reader program using im_receive_input.

XDEMO.CPP

Sample reader program using IRL-like functions.

If you are building your own program, make sure that you set the following options. The sample programs already include these settings: • The project must be set to create a DOS-executable file. • The memory model must be set to the Large compilation model.

To build a sample program using Microsoft C/C++ 1. Start the Microsoft Programmer’s Workbench from Microsoft Windows. 2. Open XCDEMO.MAK or XDEMO.MAK from: \INTERMEC\MICROSFT\SAMPLES 3. Open XCDEMO.C or XDEMO.CPP from: \INTERMEC\MICROSFT\SAMPLES 4. Set OPTIONS | DIRECTORIES to the directory containing your Microsoft C include files and your Microsoft C library files. The sample project uses the following include files and library files: \MICROSFT\INCLUDE;\INTERMEC\MICROSFT\INCLUDE \MICROSFT\LIB;\INTERMEC\MICROSFT\LIB 5. Build the demo program from the Project menu.

2-4

Page 33

C Language Support

2

Debugging With JANUS Application Simulator The JANUS Application Simulator is a terminate-and-stay resident (TSR) program that you use to run JANUS applications on a PC. Without the Simulator, you cannot run JANUS applications on your PC. Whenever you start a program that uses PSK library functions, the program checks for a JANUS reader and for the JANUS Simulator. If you attempt to run a JANUS program on a PC without the Simulator, you get an error message. The Simulator captures the JANUS functions and interrupts to make the PC mimic a JANUS reader. For more information on the Simulator, refer to the JANUS Application Simulator User’s Manual, Part No. 062778. To debug a JANUS application with the Simulator 1. Start the Simulator from the DOS prompt by entering this command: janussim 2. Start your application development software, such as Microsoft C/C++. 3. Set the application development software to use a DOS debugger, such as CodeView for DOS. 4. Follow the debugging instructions provided with your application development software.

Debugging a Program With Turbo Debugger Turbo Debugger is the application debugging environment supplied with Borland C/C++. Since Turbo Debugger requires a lot of memory and is easier to use on a large display, you will probably want to debug your programs using the remote debugging feature. Turbo Debugger runs on your PC while the program you want debugged runs on the reader. To use remote debugging, you must connect the PC to your reader with a null modem cable and you must run TDREMOTE.EXE on the reader. Note: If you need to debug a program on the JANUS 2010 or 2050 that uses COM1, you can use the scanner port (COM2) with the remote debugger. Use IC.EXE to configure the scanner port as COM2.

2-5

Page 34

JANUS PSK for C/C++ Reference Manual

To debug your program 1. Connect the PC to your reader with a null modem cable. 2. Copy the TDREMOTE.EXE program to a drive on the reader. 3. If your application uses reader services, make sure they are loaded on the reader. If you use the Intermec-supplied AUTOEXEC.BAT file, they are loaded automatically. Otherwise, start reader services on the reader by entering this command: RSERVICE 4. On the reader, change to the drive with TDREMOTE.EXE and enter the command: TDREMOTE -rpm -rsn where: rpm sets the reader’s communications port m is 1, 2, or 4 for COM1, COM2, or COM4 rsn sets the transmission baud rate as follows:

JANUS Reader

Port

Switch

Baud

2010 and 2050

COM1 and COM2

-rs2

19,200

-rs3

38,400

-rs4

115,000

-rs2

19,200

2020

COM1

-rs3

38,400

-rs4

115,000

5. On the PC where Turbo Debugger will run, go to the directory where your program file is located and enter: TD -rpm -rsn progname.exe where: rpm sets the PC communications port. Omit this for COM1.

rsn sets the transmission baud rate. This parameter must match the value you entered for -rsn on the reader.

progname is your executable program file.

2-6

Page 35

C Language Support

2

6. Use Turbo Debugger as described in the user’s guide supplied with Borland C/C++ to debug your application. Note: Turbo Debugger uses the communications port of the reader for remote debugging. You need to avoid conflict with portions of your programs that use the reader’s communications functions. Either use COM2 on the JANUS 2010 or 2050, or use COM4 on the JR2010, JR2020, or JR2050 for debugging. You can also skip over the portions that use communications functions.

Status Code Macros When using any of the C library functions, you can check for a specific return value or you can use one of the PSK macros to determine the severity of the returned status codes. For portability with future Intermec products, we recommend that you use the macros. The following macros are located in IMMSG.H: IM_ISERROR(status) This macro returns a nonzero number when status indicates an error (either fatal or nonfatal). Zero is returned if status indicates either success or warning. IM_ISSUCCESS(status) This macro returns a nonzero number when status indicates either success or warning. Zero is returned if status indicates an error (either fatal or nonfatal). IM_ISGOOD(status) indicates success.

This macro returns a nonzero number when status

IM_ISWARN(status) This macro returns a nonzero number when status indicates a warning. The following example uses IM_ISERROR to test for an error, and then prints the error message on the reader display. status = im_transmit_byte( com_port, outchar); if ( IM_ISERROR(status)) im_message(status);

2-7

Page 36

JANUS PSK for C/C++ Reference Manual

Runtime Requirements For some library functions to work properly, you must install and run specific software components at program execution time. For example, if the reader is using a communications port, you must load a protocol handler. Because protocol handlers use a lot of memory, they are not automatically loaded for you. Other functions require the Reader Wedge TSR program. Note: Large C language programs can require more memory than is currently available in the reader. One possible solution is to use overlays. For more information, see your C language programmer’s guide.

Protocol Handlers You use the Intermec protocol handler (PHIMEC.EXE) when the reader is connected with other Intermec devices. PHIMEC.EXE works with UserDefined, Point-to-Point, Polling Mode D, and Multi-Drop protocols. You use the PC standard protocol handler (PHPCSTD.EXE) when the reader is connected to devices that use PC standard protocol. PHPCSTD.EXE provides low-level communication abilities and protocol services at the DOS level for non-communication software. It also provides byte-by-byte transfer. If your reader is a radio frequency (RF) unit, RFPH.EXE is automatically loaded. For more information on protocol handlers, refer to your JANUS user’s manual. To install a protocol handler on the reader • From the DOS prompt, enter the following command:

handler n where: handler is either PHIMEC or PHPCSTD. n is the number of the communications port.

When your application is finished, the protocol handler TSR continues to run and can prevent other applications from running due to lack of memory. You can unload the protocol handler TSR by adding the unload command as the last line of the batch file that launches your application.

2-8

Page 37

C Language Support

2

To unload a protocol handler on the reader • From the DOS prompt, enter the following command: unload handler n where: handler is either PHIMEC or PHPCSTD. n is the number of the communications port.

Reader Wedge Some functions, such as im_receive_input, allow the reader to receive input from multiple sources and process the input depending on the source. You must load the Reader Wedge (RWTSR.EXE) TSR to use these functions. When your application is finished, the Reader Wedge TSR continues to run in the background and take up memory. The Reader Wedge TSR can prevent other applications from running due to lack of memory. Make sure that your application unloads the Reader Wedge TSR as part of the exit routine or as part of a batch file. Note: PSK version 2.1 automatically loads RWTSR.EXE for C language applications. However, you get optimal memory management by loading and unloading RWTSR.EXE at the command line. The autoload feature uses about 6K additional memory. To load the Reader Wedge TSR on the reader • From the DOS prompt, enter the following command: RWTSR To unload the Reader Wedge TSR on the reader • From the DOS prompt, enter the following command: RWTSR -D

2-9

Page 38

JANUS PSK for C/C++ Reference Manual

Specific Functions With Runtime Requirements The following table lists the PSK functions that have runtime requirements.

Specific Runtime Requirements

2-10

This Function

Requires im_cancel_rx_buffer

Protocol Handler im_cancel_tx_buffer

Protocol Handler im_clear_abort_callback

Reader Wedge im_command

Reader Wedge im_get_input_mode

Reader Wedge im_get_label_symbology

Reader Wedge im_get_length

Reader Wedge im_input_status

Reader Wedge im_irl_a

Reader Wedge im_irl_k

Reader Wedge im_irl_n

Reader Wedge im_irl_v

Reader Wedge If the data is from a communications port, use a Protocol Handler and im_link_comm.

im_irl_y

Reader Wedge Protocol Handler Use im_link_comm.

im_link_comm

Reader Wedge Protocol Handler im_parse_host_response

Protocol Handler im_receive_buffer

Protocol Handler Do not use im_link_comm.

im_receive_buffer_no_wait

Protocol Handler Do not use im_link_comm.

im_receive_buffer_noprot

Protocol Handler Do not use im_link_comm.

im_receive_byte

PHPCSTD.EXE You must use PC standard protocol on the host. Do not use im_link_comm.

Page 39

C Language Support

2

Specific Runtime Requirements (continued) This Function

Requires im_receive_input

Reader Wedge Protocol Handler Use im_link_comm if data is from a communications port.

im_rx_check_status

Protocol Handler im_serial_protocol_control

Use im_link_comm.

im_set_abort_callback

Reader Wedge im_set_display_mode

Reader Wedge im_set_input_mode

Reader Wedge im_setup_trx

Protocol Handler im_standard_trx

Protocol Handler im_standby_wait

Reader Wedge im_transmit_buffer

Protocol Handler im_transmit_buffer_no_wait

Protocol Handler im_transmit_buffer_noprot

Protocol Handler im_transmit_byte

Protocol Handler You must install PHPCSTD.

im_unlink_comm

Reader Wedge Protocol Handler

2-11

Page 40

JANUS PSK for C/C++ Reference Manual

Certified C Language Functions Because of the large number of functions in the C language, not all functions are known to work correctly when used with the JANUS family of readers. Many of these have been tested, however, and are known to operate on the reader the same as on a PC. These tested functions are listed below.

Tested C Functions

2-12 atol

_dos_settime fseek bdos dostounix

_fstrlen

_bios_keybrd enable fwrite bioskey exit geninterrupt

_bios_serialcom farcoreleft getch

_chain_intr farfree getchar chdir farmalloc getche

_chdrive ffeof getcwd

_chmod fflush getdate

_clock fgets

_getdcwd chsize filelength getdfree close fileno getdisk clrscn findfirst

_getdrive corel findnext getenv cprintf fnmerge getpsp cputs fnsplit gets delay fopen gettext disable fprintf gettextinfo

_dos_findnext fputc gettime

_dos_getdate fputs getvect

_dos_getdiskfree

FP_OFF gotoxy

_dos_getfileattr

FP_SEG

_harderr

_dos_gettime fread

_hardresume

_dos_setdate free

_hardretn