The text of a manual · part 29 of 42
JANUS PSK for C/C++ Reference Manual, Version 2.1, pages 281 to 290
Pages 281 to 290 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 281
Suspend System
4
Suspend System Purpose:
This function directs the system BIOS to place the system into the low-power Suspend state. The caller invokes this function in response to a Suspend system request notification from the system BIOS. First, the caller finishes any incomplete processing of its own, and then the caller invokes the Suspend system interrupt. In addition to responding to system BIOS requests, the caller can initiate a Suspend operation. For example, if the caller determines that the system has been completely idle during a given time interval (for other than normal background processing such as servicing timer interrupts), it could request a system Suspend using this function. Because the system BIOS does not return to the caller until the system is resumed from the Suspend state, there is no need to check for most resume notifications from the system BIOS. Upon return, and when safe to do so, the caller can notify any PM-aware applications of the resume status. Since the system may have been suspended for a long period of time, the caller might need to update the date and time values.
Call With:
Notes:
AH =
53H
AL =
07H
BX =
0001H
CX =
0002H
This call is available in both the APM INT 15H and protect mode interfaces.
4-39
Page 282
System Standby
System Standby Purpose:
This function commands the system BIOS to place the system into the Standby state. The caller invokes this function in response to a system standby request notification from the system BIOS after the caller has performed any processing of its own. The caller can also initiate a standby operation. For example, if the caller determines that the system is idle and is not already in the Standby state, it could request a system standby using this function. Typically, you exit the Standby state by raising an interrupt. Interrupts are serviced normally.
Call With:
Notes:
4-40
AH =
53H
AL =
07H
BX =
0001H
CX =
0001H
This call is available in both the APM INT 15H and protect mode interfaces.
Page 283
5 Using the PSK With DCM
Page 284
Page 285
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 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. Basic and Ada do not support these operations.
5-3
Page 286
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 287
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 288
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 289
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 290
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