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 29 of 40

2D JANUS PSK for C/C++ Reference Manual, pages 281 to 290

Pages 281 to 290 of 400

The original document is the PDF (793 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 281

5 Using the PSK With DCM

Page 282

blank

Page 283

Using the PSK With DCM

5

The Programmer’s Software Kit Language Libray includes three C language functions you can use for accessing a remote database from the JANUS reader.

Accessing a Database Server Through DCM You can easily write an application program to run on the JANUS reader that accesses a remote database server through Intermec data collection manager (DCM) software. DCM does not run on the reader. It runs on a separate PC or workstation and provides transparent access to the remote database. The database may or may not be on the same computer as DCM. You need the following items to access a database server: • The database table definition, including field types and field lengths • Intermec DCM software version 4.3 or higher configured to access the database • im_setup_trx, which sets up the protocol parameters for accessing the database server • im_standard_trx, which packs and sends a transaction to the database • im_parse_host_response, which reads the response from the host Note: These functions are only available in the C language library.

5-3

Page 284

2D JANUS PSK for C/C++ Reference Manual

Defining a Database Transaction DCM handles the actual translation of a packet of data from the reader into a database-usable packet, based on settings that you configure in DCM. Your application defines the variables for the data, calls the function to pack and transmit the data, and handles the response from the database. You must understand how the data on the reader maps to the data in the database structure and design your application and the DCM configuration around this relationship. The following figure shows how the information in the reader relates to the information in the database.

JANUS

1

3

9

6

2

4

5

8

7

Host database

Packet translation to host database

3 18 1 DCM Packet translation from host database

9 44

2 20 6 4 17 12 31 25 11 56 8

0

5

7

4 JPSK.003

For this chapter, the term transaction means a function call on the JANUS reader that sends a message to the database server and then receives and distributes the returned values. The transaction includes a transaction ID, data fields, and a database operation request. The database operation can be a read, a write, an update, or a delete. The return message is ACK, NAK, or data.

5-4

Page 285

Using the PSK With DCM

5

A read operation returns a status code and record information from the host that your application can process with im_parse_host_response (if pacing is off). The other database operations return only status codes. To set up a reader to database transaction 1. Configure the database destination in DCM and map the fields in the JANUS reader to the database table. 2. Send a transaction to the database using im_standard_trx. 3. Check the return status codes from im_standard_trx. 4. If the transaction is a read operation, parse the returned records until the JANUS reader receives an ACK. 5. If needed, provide a standby file for transmitting transactions later if the transmit channel is unavailable. The following sections explain each step.

Configuring DCM Before writing your application on the JANUS reader, you need to configure DCM for the database transactions. Refer to the appropriate DCM user’s manual for the database actions available and for detailed instructions on configuring DCM. Manual

Part Number

DCM for OS/2 Manual Kit

057433

DCM for HP-UX Manual Kit

062223

DCM for SCO Manual Kit

062765

To set up DCM to access a database 1. Define the database interface and network configuration. 2. Define the database action: read, insert (write), update, or delete. 3. Define the JANUS reader transaction fields and map the fields to the database table. For example, the second field in the JANUS reader transaction is numeric and corresponds to the third column in the database table.

5-5

Page 286

2D JANUS PSK for C/C++ Reference Manual

Sending a Transaction to the Database You use im_setup_trx and im_standard_trx for defining protocol parameters and sending a transaction to a database. You can use the default im_setup_trx protocol values, without calling im_setup_trx, or you can define your own values. The following table lists the default protocol values. For more information, see Chapter 2, “C Language Support.” Description

Default Value

Communications port (COM1)

IM_COM1

Transmit timeout value (infinite)

IM_INFINITE_TIMEOUT

Receive timeout value (infinite)

IM_INFINITE_TIMEOUT

Read one record at a time (only affects read operations)

IM_DBPACE_ENABLE

Standby file and batch processing disabled im_batch_enable is off

Do not ignore NAK during batch processing im_dobest_enable is off

System delimiter character (comma)

,

Field delimiter character (comma)

,

Maximum packet length

256 characters

No standby file (safety = 0)

0

Note: Handshaking is always on when the JANUS reader accesses a host database. Your application handles two cases of database actions: database reads and other database transactions. A read operation returns data that your application must process. The data is either an ACK or NAK mesage from the database host or data fields that must be parsed. Database write, update, and delete operations return only an ACK or NAK message from the database host. To set up a database write, update, or delete 1. If needed, use im_setup_trx to set up the protocol for the database server. 2. Use im_standard_trx to pack and transmit a record to the database. 3. Provide error trapping by checking the return status codes.

5-6

Page 287

Using the PSK With DCM

5

To set up a database read 1. If needed, use im_setup_trx to set up the protocol for the database server. 2. Use im_standard_trx to pack and transmit a record to the database. 3. Provide error trapping by checking the return status codes. 4. Use im_parse_host_response to parse the returned records until the end of the database records is reached.

Checking the Return Status Codes The database functions provide many return codes to help you pinpoint an error. You must decide which errors to check for and how your application will handle each situation. In some situations your application may only need to verify the category of the error. In others, your application needs to verify the exact error condition. For example, a database read operation may successfully read the database, but the data returned to the JANUS reader may overflow the receive buffer you defined. Your application can use one of the status code macros defined in Chapter 2, “C Language Support.” You can also test for the successful category by testing bit 4 in the return code. If bit 4 is set to 1 (mask with 0x0010), you know that the database operated correctly and sent at least one record to the JANUS reader. However, you do not know that all of the data was received. If your application needs to verify the exact error and provide a correction, you need to test for the specific status value. The following example shows two ways to test the return codes.

5-7

Page 288

2D JANUS PSK for C/C++ Reference Manual

Example * Checking return codes with macros and by value * status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszRead[i], 256, pszInString, pszGetData, &chOperation); if im_isgood(status) //See if any data has been received. { //Process received data. //Add your code here. } * Test for receive data and specific return code status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszRead[i], 256, pszInString, pszGetData, &chOperation); if (status == IM_DCM_ACK_RCD) { //Received data and successful parse. //Add your code here. } elseif (status == IM_DCM_TRUNCATED) { //Received data but parse buffer too small //Add your code here. } elseif (status == IM_DCM_EXCESSFIELD) { //Received data but too many fields //Add your code here. }

The example referred to the symbolic name of the return code, such as IM_DCM_ACK_RCD. You can also check for the exact hex value. The following sections list the return code hex values for the DCM functions im_parse_host_response, im_setup_trx, and im_standard_trx, grouped as follows: • By calling parameter • In numerical order • Symbolic return code with its hex value

5-8

Page 289

Using the PSK With DCM

5

Return Codes Listed by Calling Parameter The following two tables list the return codes arranged by the calling parameters and severity. The first table lists the return codes for the parameters that affect the standby file. The second table lists the return codes for accessing the remote database.

im_standard_trx Return Codes for Manipulating the Standby File Request Type Parameter

Return Code

Description

IM_ERROR_RECORD

1A00

Retrieved record from standby file

5A07

Standby file is empty

9A08

Standby file I/O error

9A09

Standby file is missing

1A00

Retrieved record from standby file

5A07

Standby file is empty

9A08

Standby file I/O error

9A09

Standby file is missing

1A00

All standby records sent successfully

9A09

Standby file is missing

5A02

NAK received. If im_dobest_enable is not set, then stop sending records.

9A03

Transmit channel error

9A04

Receive channel timeout

9A05

Packet header error

9A06

Missing transaction ID

IM_ADVANCE_RECORD

IM_ZIP_RECORD

5-9

Page 290

2D JANUS PSK for C/C++ Reference Manual im_standard_trx Return Codes for Accessing the Remote Database Request Type Parameter

Return Code

Description

All

1A00

Transaction successful

1A10

Received message on Read operation

5A11

Data was truncated

5A12

Too many fields

1A01

Transaction successful, ACK

5A02

Transaction failed, NAK

5A20

Record stored in standby file successfully

5A21

Record stored in standby file, but upload standby error

9A03

Transmit failed

9A04

Receive port timeout

9A40

Buffer overflow

9A41

Buffer overflow with upload standby error

9A05

Packet header error

9A06

Missing transaction ID

9A08

Standby file I/O error

9A09

Standby file is missing

5-10