The text of a manual · part 17 of 21
Symbol Palm Terminal Scanner System Software Manual, pages 137 to 144
Pages 137 to 144 of 168: Chapter 5 Power Considerations; Chapter 6 Sample Scanning Application
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 137
Chapter 5 Power Considerations The power-consumption characteristics of the SPT device are different than those of a normal Palm III device, and it is important to keep this in mind when writing your application. The normal low-battery alert is displayed whenever the battery voltage falls below the acceptable operating level. However, a scan operation requires a different power threshold. When battery levels fall below this threshold (approximately 2.3 volts) an attempted scan will fail, and the scanner is disabled. Your application must alert the end-user in this situation, explaining why the scan failed, and directing them to install fresh batteries.
scanBatteryErrorEvent Your code needs to handle the scanBatteryErrorEvent. The Scan Manager application generates this event whenever it detects the low-battery condition. Consult one of the two sample programs (ScanDemo or SScan) for an example of how to handle this event. Be sure to catch this event in all of your event handlers that might be in effect when a scan operation is attempted. For example, the ScanDemo program catches the scanBatteryErrorEvent in ApplicationHandleEvent so that it is handled in whatever form being displayed.
Sudden Loss of Power If the terminal is put into sleep mode (through the unit’s on/off button) while a scan-aware application is running, the state of the scanner will be preserved when the unit is turned back on. If the terminal is put into sleep mode while a scan is in progress, the scan will be aborted before the unit goes to sleep.
5-1
Page 138
Symbol Palm Terminal Scanner System Software Manual
If the end-user removes the batteries while a scan-aware application is running (and the unit is not in sleep mode), Scan Manager removes power to the scanner and tries to maintain its current settings. However, this is not recommended, and you may see unpredictable results.
Backlighting If your application controls or relies on the Palm device’s backlighting feature, be aware that Scan Manager turns backlighting off at the outset of a scan operation. It also restores backlighting after the scan is completed.
Other Power Notes Certain decoder settings affect power consumption, and therefore affect battery life. The “laser pointer” mode set in ScanCmdAimOn draws a lot of power. Selecting pulse mode rather then trigger mode generally draws more power. Also, increasing values from the defaults for the following increases power consumption somewhat: !
LaserOnTime
!
DecodeLedTime
!
DecodeBeepDuration
!
AimDuration
The scanner draws no power until ScanOpenDecoder() is called. It stops drawing power when ScanDecoderClose() is called. Therefore, if you need the scanner’s capabilities only during certain portions of your application, you may want to issue the ScanOpenDecoder call before you enter that portion of the application, and ScanCloseDecoder when you exit that portion of the application. For example, you may need the scanner for entering data in fields on only one form of your application. To avoid excessive voltage draw, the Scan Manager software puts the terminal into sleep mode while the laser is on. You should be careful to preserve this functionality. For this reason, it is recommended that you do not pass a timeout value to “EvtGetEvent.” (For example, do not generate a nilEvent every few milliseconds in a scanning situation). Doing so could cause the terminal to come out of sleep mode at one of your timeout intervals while the laser is firing. Finally, to reduce instantaneous power draw, your application should avoid opening the IR Exchange Manager or HotSync port while the scanner is open.
5-2
Page 139
Chapter 6 Sample Scanning Application The Scan Manager application described in this chapter is called SScan. It is a sample scanaware application that demonstrates the basics of building a scan-aware application. The sections in this chapter describe, at a high level, the components in the Sscan application. The Scan Manager library also includes a detailed application, called Scan Demo, that exercises nearly all of the API. Refer to the Scan Manager library for the location of Scan Demo.
Writing the Code Include Files The following three #include statements provide you with the Scan Manager interface definitions, including the API functions, constants, and data structures. #include "ScanMgrDef.h"// Scan Manager constant definitions #include "ScanMgrStruct.h"// Scan Manager structure definitions #include "ScanMgr.h" // Scan Manager API function definitions
PilotMain Routine The PilotMain function is a standard Palm organizer application. It contains the code for handling a normal application launch (sysAppLaunchCmdNormalLaunch) by calling three other functions: StartApplication, EventLoop, and StopApplication.
6-1
Page 140
Symbol Palm Terminal Scanner System Software Manual
/***************************************************************** * * FUNCTION: PilotMain * * DESCRIPTION: This function is the equivalent of a main() * function in standard C. It is called by the * Emulator to begin execution of this application. * * PARAMETERS: cmd - command specifying how to launch the * application. * cmdPBP - parameter block for the command. * launchFlags - flags used to configure the launch. * * RETURNED: Any applicable error code. * *****************************************************************/ DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags) { // Check for a normal launch. if (cmd == sysAppLaunchCmdNormalLaunch) { Err error = STATUS_OK; // Set up Scan Manager and the initial (Main) form. StartApplication(); // Start up the event loop. EventLoop(); // Close down Scan Manager, decoder StopApplication(); } return(0); }
6-2
Page 141
Sample Scanning Application
The StartApplication Function Sscan’s StartApplication function demonstrates what you need to do at the outset of your program to properly initialize the scanner. The first thing the StartApplication function does is call ScanIsPalmSymbolUnit, which tells the application whether it is running on a device that contains scanner hardware and software. This function is useful when your application needs to run on both an unmodified Palm III device and on a SPT device. Based on the result of this call, you can continue either as a normal application or as a scan-aware application. Before calling any other Scan Manager library function, you must call ScanOpenDecoder. This function: !
Loads the Scan Manager shared library
!
Powers on the decoder
!
Initiates communication between the application and the scanner unit
Be sure to check the return value of the ScanOpenDecoder call. If it does not return a value of STATUS_OK, do not proceed with other Scan Manager calls. If your application successfully performs ScanOpenDecoder, you may configure the decoder to suit your application’s needs. This could involve enabling the scanner, setting the trigger mode, and enabling the appropriate barcode types. The Sscan application enables the scanner by calling ScanCmdScanEnable. Next, it calls the ScanSetTriggeringModes function with a parameter of HOST to configure the triggering mode so that software-initiated scanning can be performed. Finally, several UPC and EAN barcode types (or symbologies) are enabled by the function ScanSetBarcodeEnabled. For these parameters to actually take effect, you must call the ScanCmdSendParams function. All ScanSet... functions must be set with this function call. You only need to call ScanCmdSendParams once, after you have set all of your parameters. NOTE: You are not required to call ScanCmdSendParams after you call other ScanCmd... functions, such as ScanCmdScanEnable. ScanCmd... functions take effect automatically.
6-3
Page 142
Symbol Palm Terminal Scanner System Software Manual
/***************************************************************** * * FUNCTION: StartApplication * * DESCRIPTION: This routine sets up the initial state of the * application. * * PARAMETERS: None. * * RETURNED: Nothing. * *****************************************************************/ static void StartApplication(void) { Err error; // Call up the main form. FrmGotoForm( MainForm ); if (ScanIsPalmSymbolUnit()) { // Now, open the scan manager library error = ScanOpenDecoder(); // Set decoder parameters we care about... ScanCmdScanEnable(); // enable scanning // allow software-triggered scans (from Scan button) ScanSetTriggeringModes( HOST ); // Enable any barcodes to be scanned ScanSetBarcodeEnabled( barUPCA, true ); ScanSetBarcodeEnabled( barUPCE, true ); ScanSetBarcodeEnabled( barUPCE1, true ); ScanSetBarcodeEnabled( barEAN13, true ); ScanSetBarcodeEnabled( barEAN8, true ); ScanSetBarcodeEnabled( barBOOKLAND_EAN, true); ScanSetBarcodeEnabled( barCOUPON, true); ScanSetBarcodeEnabled( barPDF417, true);
6-4
Page 143
Sample Scanning Application
// We've set our parameters... // Call "ScanCmdSendParams" to send to decoder ScanCmdSendParams( No_Beep); } }
The MainFormHandleEvent Function After calling StartApplication, PilotMain calls EventLoop, which initiates the standard event-processing routine familiar to Palm organizer application developers. From the standpoint of scan-aware application developers, the most interesting code in Sscan is the MainFormHandleEvent function, which is the event handler for Sscan's main form. /***************************************************************** * * FUNCTION: MainFormHandleEvent * * DESCRIPTION: Handles processing of events for the ÒmainÓ form. * * PARAMETERS: event - the most recent event. * * RETURNED: True if the event is handled, false otherwise. * *****************************************************************/ static Boolean MainFormHandleEvent(EventPtr event) { Boolean bHandled = false; Word extendedDataFlag; switch( event->eType ) { case frmOpenEvent: MainFormOnInit(); bHandled = true; break; case menuEvent: MainFormHandleMenu(event->data.menu.itemID); bHandled = true; break;
6-5
Page 144
Symbol Palm Terminal Scanner System Software Manual case scanDecodeEvent: // A decode has been performed. // Use decoder API to retrieve decoder data. // Get barcode parameters from the registers. extendedDataFlag= ((ScanEventPtr)event) ->scanData.scanGen.data1; extendedDataLength = (int)(((ScanEventPtr)event) ->scanData.scanGen.data2); extend = extendedDataFlag & EXTENDED_DATA_FLAG; OnDecoderData(); bHandled = true; break; case scanBatteryErrorEvent: { Char szTemp[10]; StrIToA( szTemp, ((ScanEventPtr)event) ->scanData.batteryError.batteryLevel ); FrmCustomAlert( BatteryErrorAlert, szTemp, NULL, NULL ); bHandled=true; break; } case ctlSelectEvent: { if (ScanIsPalmSymbolUnit()) { // Scan Button if (event->data.ctlEnter.controlID == MainSCANButton) { ScanCmdStartDecode(); bHandled = true; } } break; } case fldChangedEvent;
6-6