The text of a manual · part 19 of 21
Symbol Palm Terminal Scanner System Software Manual: Chapter 7 2-Dimensional Scanning Considerations
Pages 153 to 158 of 168, from Symbol Palm Terminal Scanner System Software Manual
The original document is the PDF (1.2 MB). 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 Symbol SPT-1700
Page 153
Chapter 7 2-Dimensional Scanning Considerations Introduction In the Scan Manager for the SPT 1500 and SPT 17xx, the maximum length of decoded data was set to 255, which is long enough for any 1-Dimensional barcode. However, it is possible for the information encoded in a 2-Dimensional PDF417 symbol to exceed the 255-byte limit. For models of the SPT 1700 that perform 2-dimensional scanning, the maximum length of decoded data is 3000 bytes. Because of these ‘Extended Data’ barcodes, and because of the need to maintain compatibility with legacy applications, a new method was created for applications to retrieve this ‘Extended Data’.
Issue Because the maximum length of decoded data is increased for 2D barcodes, the shared scanner library needs to be changed to support this. However, the Scanner Manager cannot just assume the application has been written to handle receiving large amounts of decode data, since legacy applications were written assuming the maximum data length was 255 bytes. A new API, described below, allows applications written with the original scanner library to still function properly, while also allowing applications written for 2D bar codes to receive the extended data.
Solutions To allow new applications to receive Extended Data bar codes, we must create a new API that does not use the MESSAGE structure for delivering the decode data to the application. However, to allow existing scanning applications to function on both a standard SPT 1500/
7-1
Page 154
Symbol Palm Terminal Scanner System Software Manual
SPT 1700 and the SPT 1700 2-Dimensional unit, we need to ensure that if an application is using the MESSAGE structure, then only a maximum of 255 bytes of data are returned to that application, even if a larger bar code has been scanned. To allow the receiving of Extended decode data, a new API has been added to the scanner SDK. ScanGetExtendedDecodeData(int length, int *type, unsigned char *buf)
where: length:
passed to the function by the application, and is the size of the buffer pointed to by *buf.
*type:
pointer to an int, and will contain the bar code type after the API is successfully called.
*buf:
pointer to the buffer to place the decoded data.
Two dimensional scanning can be implemented as follows: After the Scan Manager receives the decoded data, a flag is set in the scanDecodeEvent message to notify the application that extended data is being sent and the length of the extended data is passed to the user. The flag is bit 0 of scanData.scanGen.data1 of struct ScanEventType, which is defined in ScanMgrStruct.h. The length of the extended data is stored in scanData.scanGen.data2 of struct ScanEventType: typedef struct { enum events eType; Boolean penDown; SWord screenX; SWord screenY; union scanData { struct scanGen { Word data1; //Bit 0 is the flag to tell app //if decode data has extended data. Word data2; //Length of the decoded data. Word data3; Word data4; Word data5; Word data6; Word data7; Word data8; } scanGen; struct { UInt batteryLevel;// The current voltage // measured in millivolts
7-2
Page 155
2-Dimensional Scanning Considerations
UInt batteryErrorType;// not used } batteryError; } scanData;// End of union } ScanEventType; typedef ScanEventType *ScanEventPtr;
In ScanMgrDef.h, we have added the following #define for the extended data flag: #define EXTENDED_DATA_FLAG 0x01 An application gets the flag and the length of the extended data from the event in function MainFormHandleEvent: Word extendedDataFlag; int extendedDataLength; Boolean extend; . . . case scanDecodeEvent: extendedDataFlag=((ScanEventPtr)event)->scanData.scanGen.data1; extendedDataLength=(int)(((ScanEventPtr)event) ->scanData.scanGen.data2); if (extendedDataFlag & EXTENDED_DATA_FLAG){ extend = true; } else { extend = false; } OnDecoderData(extend); . . .
In function OnDecoderData, check extendedDataFlag. If this is set, the application allocates a buffer with the size of extendedDataLength and retrieves the decoded data in it by calling ScanGetExtendedDecodedData(). Please note: this buffer must be freed by the user after use. If this flag is not set, the application retrieves the decoded data by calling ScanGetDecodedData() as before: Boolean OnDecoderData(Boolean extend) { static Char BarTypeStr[80]=" "; MESSAGE decodeDataMsg;
7-3
Page 156
Symbol Palm Terminal Scanner System Software Manual int status; VoidHand hExtendedData; unsigned char*pExtendedData; int extendedDataType;
if (extend){ hExtendedData = MemHandleNew( extendedDataLength ); pExtendedData = MemHandleLock( hExtendedData ); status = ScanGetExtendedDecodedData(extendedDataLength, &extendedDataType, pExtendedData); } else
{ status = ScanGetDecodedData( &decodeDataMsg ); extendedDataType = decodeDataMsg.type; extendedDataLength = decodeDataMsg.length; hExtendedData = MemHandleNew(extendedDataLength+1); pExtendedData = MemHandleLock( hExtendedData ); pExtendedData[extendedDataLength] = '\0'; MemMove( &pExtendedData[0], &decodeDataMsg.data[0], extendedDataLength+1 );
} if( status == STATUS_OK ) { /* if we successfully got the decode data from the API, place the barcode data into the field and display. Please read the sample code Scan2D.c about using scroll bar to show extended data. */ } . . . return(0); }
7-4
Page 157
2-Dimensional Scanning Considerations
If an application ignores the extendedDataFlag and calls ScanGetDecodedData(), then the scan manager will return only the first 255 bytes of the data.
Scan Manager
ScanDecodeEvent multiPacketFlag set?
N
Y
ScanGetDecodedData
ScanGetExtendedDecodedData
Figure 7-1. Scanner Library
7-5
Page 158
Symbol Palm Terminal Scanner System Software Manual
7-6