The text of a manual · part 31 of 40
2D JANUS PSK for C/C++ Reference Manual, pages 301 to 310
Pages 301 to 310 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 301
Using the PSK With DCM
5
//Wait for 1 second (optional) im_standby_wait(1000); } //********************************************************************* //Demostrate batch process to clean up the database table. // Log records into the standby file, and then flush them. // Use TSTDEL to delete all records from BONUS table. // Use IM_BATCH_ENABLE to log transactions, then process in batch mode //********************************************************************* void DemoBatch(void) { BONUSTYPE *pszBonus; IM_USHORT status; IM_USHORT del_status; IM_USHORT iDBPrtcl; IM_UCHAR pszTid[8]="TSTDEL";
// handshake, pace, request type //delete transaction
//Turn on batch process iDBPrtcl = IM_BATCH_ENABLE + IM_DBPACE_ENABLE; status = im_setup_trx(iPort, 240, IM_INFINITE_TIMEOUT, iDBPrtcl, ',', NULL, ',', 256, standby_fh); if (status != IM_DCM_OK) printf("Batch setup error: %x\n", status); //Send all records first pszBonus = EmpTable; while (pszBonus->emp != NULL) { status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszBonus, 256, pszInString, pszGetData, &chOperation); //It will receive IM_DCM_STANDBY, because IM_BATCH_ENABLE is on if (status != IM_DCM_STANDBY) printf("Standby error: %x\n", status); pszBonus++;
//go to next record
} //Flush standby records do { //Continue flushing standby records until receive IM_DCM_OK status = im_standard_trx(pszTid, IM_ZIP_RECORD, pszBonus, 256, pszInString, pszGetData, &chOperation); //If the TSTDEL transaction deletes a record in table, then reader receives // ACK and im_standard_trx() continues sending logged records until the // standby file is empty. When the file is empty, the function returns // IM_DCM_OK. // If the database table has no records, then the DCM TSTDEL transaction sends
5-21
Page 302
2D JANUS PSK for C/C++ Reference Manual
// NAK to the reader. im_standard_trx() returns IM_DCM_NAK_RCD and any records // remain in the standby file. Use IM_ADVANCE_RECORD to discard any // remaining records in the standby file. // If IM_DOBEST_ENABLE is on, then do not check for IM_DCM_NAK_RCD. // im_standard_trx() treats NAK the same as ACK and uploads the next record. if (status == IM_DCM_NAK_RCD) { printf("NAK: %s\n", pszInString); //See which record is //Skip this TSTDEL transaction because no records in database table. del_status = im_standard_trx(pszTid, IM_ADVANCE_RECORD, pszBonus, 256, pszInString,pszGetData, &chOperation); //If Error occurs, print it if (del_status != IM_DCM_OK) printf("%x\n", del_status); } } while (status != IM_DCM_OK); printf("\nDelete Complete!\n"); } //************************************************************************ //Demostrate standby functionality. // Use TSTINS transaction to insert all records into the BONUS table // using a standby file. // Use batch process to log five transactions, then turn off batch process // and send remaining transactions in normal mode. Upload all standby // records before sending current record. //************************************************************************ void DemoStandby(void) { IM_USHORT i; BONUSTYPE *pszBonus; IM_USHORT status; IM_USHORT iDBPrtcl; IM_UCHAR pszTid[8]="TSTINS"; //Turn on Batch process iDBPrtcl = IM_BATCH_ENABLE
// handshake, pace, request type //delete transaction.
+ IM_DBPACE_ENABLE;
status = im_setup_trx(iPort, 240, IM_INFINITE_TIMEOUT, iDBPrtcl, ',', ',', 256, standby_fh); if (status != IM_DCM_OK) printf("error: %x\n", status); //Process 5 records in batch mode pszBonus = EmpTable; for (i= 0; i < 5; i++) { status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszBonus, 256, pszInString, pszGetData, &chOperation); if (status != IM_DCM_STANDBY) printf("Standby error: %x\n", status);
5-22
Page 303
Using the PSK With DCM pszBonus++;
5
//go to next records
} //Turn off batch processing iDBPrtcl = IM_DBPACE_ENABLE; status = im_setup_trx(iPort, 240, IM_INFINITE_TIMEOUT, iDBPrtcl, ',', NULL, ',', 256, standby_fh); if (status != IM_DCM_OK) printf("error: %x\n", status); //Sending the rest of records. while (pszBonus->emp != NULL) { status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszBonus, 256, pszInString, pszGetData, &chOperation); if (status != IM_DCM_ACK_RCD) printf("Sending error: %x\n", status); pszBonus++;
//go to next record
} //Flush standby records and make sure no records left in standby file do { status = im_standard_trx(pszTid, IM_ZIP_RECORD, pszBonus, 256, pszInString, pszGetData, &chOperation); //See what is problem if (status != IM_DCM_OK) printf("Flush error: %x\n", status); } while (status != IM_DCM_OK); printf("\nInsert Complete!\n"); //Wait for 5 seconds im_standby_wait(5000); } //********************************************************************* // Demostrate reading records without pacing protocol. // TSTRD transaction reads records, without pacing protocol. // It reads records by department, so it needs to loop thru 4 times. //********************************************************************* void HandNoPace(void) { IM_USHORT i; IM_USHORT status; IM_USHORT iDBPrtcl; // Handshake, No pace, request type IM_UCHAR pszTid[16]="TSTRD"; //Handshaking, no pacing iDBPrtcl = 0; //Set up protocol status = im_setup_trx(iPort, 240, IM_INFINITE_TIMEOUT, iDBPrtcl, ',', ',', 256, standby_fh);
5-23
Page 304
2D JANUS PSK for C/C++ Reference Manual if (status != IM_DCM_OK) printf("error: %x\n", status); //Read records with FOR loop. Each loop covers each department. for (i = 0; i < DEPT_NUM; i++) { status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszRead[i], 256, pszInString, pszGetData, &chOperation); if (status & 0x0010) //See if data has been received { do { //Display Salary Grade, Employee name, department on screen. printf("%s, %s, %s\n", pszGetData[2].pszField, pszGetData[0].pszField, pszGetData[1].pszField); //Get next record because protocol is no pace. status = im_parse_host_response( 256, pszInString, pszGetData, &chOperation); } while ((status & 0x0010) != 0); //End of records is ACK/NAK, // instead of data received. } //Returns ACK when no more records coming from database if (status != IM_DCM_ACK_RCD) { printf("NoPace: %x\n", status); printf("%s\n", pszInString); } } printf("\nRead No Pace Complete!\n"); } //********************************************************************* // Demonstrate reading records with pacing protocol on. // TSTRD transaction reads records with pacing protocol on. // It reads records by department, so it needs to loop thru 4 times. //********************************************************************* void HandPace(void) { IM_USHORT i; IM_USHORT status; IM_USHORT iDBPrtcl; // handshake, pace, request type IM_UCHAR pszTid[16]="TSTRD"; //Handshaking and pacing. iDBPrtcl = IM_DBPACE_ENABLE; //Set up protocol status = im_setup_trx(iPort, 240, IM_INFINITE_TIMEOUT, iDBPrtcl, ',', ',', 256, standby_fh); if (status != IM_DCM_OK) printf("error: %x\n", status);
5-24
Page 305
Using the PSK With DCM
5
//Read records with FOR loop. Each loop covers each department. for (i= 0; i < DEPT_NUM; i++) { //Read first record back if record exists status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszRead[i], 256, pszInString, pszGetData, &chOperation); if ( status & 0x0010) //data received { do { //Display Salary Grade, Employee name, Department on screen. printf("%s, %s, %s\n", pszGetData[2].pszField, pszGetData[0].pszField, pszGetData[1].pszField); //wait 2 seconds im_standby_wait(2000); //Ask for next records status = im_standard_trx(pszTid, IM_DBRQT_NEXTROW, NULL, 256, pszInString, pszGetData, &chOperation); } while ((status & 0x0010) != 0); //End of records is ACK/NAK, // instead of data received. } //Returns ACK when no more records coming from database if (status != IM_DCM_ACK_RCD) { printf("Pace: %x\n", status); printf("%s\n", pszInString); } } printf("\nRead Pace Complete!\n"); } //********************************************************************* //Demostrate discarding records with pacing protocol on. //********************************************************************* void HandDiscard(void) { IM_USHORT i; IM_USHORT j; IM_USHORT status; IM_USHORT iDBPrtcl; // handshake, pace, request type IM_UCHAR pszTid[16]="TSTRD"; IM_UCHAR chPaceChar; //Handshaking and pacing. iDBPrtcl = IM_DBPACE_ENABLE; //Set up protocol status = im_setup_trx(iPort, 240, IM_INFINITE_TIMEOUT, iDBPrtcl, ',', ',', 256, standby_fh); if (status != IM_DCM_OK) printf("error: %x\n", status);
5-25
Page 306
2D JANUS PSK for C/C++ Reference Manual
//Read 3 records with FOR loop. Each loop covers a department. for (i= 0; i < DEPT_NUM; i++) { //Read first record in database if record exists status = im_standard_trx(pszTid, IM_DBRQT_DATA, pszRead[i], 256, pszInString, pszGetData, &chOperation); //Initialize count so that after 3 records, // rest of the records j = 0; if ( status & 0x0010) //data received { do { j++;
we can discard the
//Display Salary Grade, Employee name, department on screen. printf("%s, %s, %s\n", pszGetData[2].pszField, pszGetData[0].pszField, pszGetData[1].pszField); if (j > 2) chPaceChar = IM_DBRQT_DATA; else chPaceChar = IM_DBRQT_NEXTROW;
//'S' -Discard records //'N' -next row
//wait 2 seconds im_standby_wait(2000); //Ask for next record or discard rest of records status = im_standard_trx(pszTid, chPaceChar, NULL, 256, pszInString, pszGetData, &chOperation); } while ((status & 0x0010) != 0); }
} if (status != IM_DCM_ACK_RCD) { printf("Discard: %x\n", status); printf("%s\n", pszInString); } //for printf("\nRead Discard Complete!\n"); }
5-26
//End of records is ACK/NAK, // instead of data received.
Page 307
A Status Codes
Page 308
blank
Page 309
A
Status Codes
This appendix lists the status code hex values and error messages. Use the tables in this appendix to look up the meaning of a specific status code.
Status Code Bit Values Most of the PSK functions return status codes. You can use the codes to test for error conditions that your application will act upon. How you test for the status codes depends on the complexity of the function returning the status and your application needs. In some cases, you may use the status code macros discussed in “Status Code Macros” in Chapter 2 to check the severity level. In other cases, you may want to check the exact status code value. Each status code is a 16-bit word structured as follows:
15
14
13
12
10
9
8
7
6
5
4
3
2
1
0 s s f f f f f m m m m m m m m
JPSK.002 where: s is severity code:
00 = Success 10 = Error 01 = Warning 11 = Fatal f is the subsystem code, explained later in this appendix. m is the message code that identifies the error or warning condition. The status codes are IM_USHORT (unsigned short) values. The tables in this appendix list the hex value of the message codes.
A-3
Page 310
2D JANUS PSK for C/C++ Reference Manual
Status Codes Listed Numerically The following table lists the return codes and the error message text provided by im_message and imMessage. For each message, there is an associated status return code, subsystem, and severity. Some messages are abbreviated to fit the display and to save memory on the JANUS reader. The table includes an easy-to-read version of the abbreviated messages.
Status Codes and Error Messages Listed in Numerical Order Hex Code
Severity
Subsystem
Reader Message and Description
0000
Good
NO
Request successful
0001
Good
NO
Prohibited
0100
Good
RS
Rservice request success Reader services successful
0103
Good
RS
Rservice resume success Reader services resume successful
0200
Good
CM
Request success Request successful
0201
Good
CM
Read End Of Record End of record reached
0202
Good
CM
Read End Of File End of file reached
0300
Good
SC
Scan success Scan successful
0400
Good
DC
Success Successful command
0401
Good
DC
Symbology already enabled Symbology is already enabled
0402
Good
DC
Symbology not enabled Symbology is not enabled
040A
Good
DC
Good decode Successful decode
040B
Good
DC
Intermediate row re-read Intermediate row reread
A-4