Opticon PHL5x00 SDK

PHL5x00 SDK Help

This PHL5x00 SDK manual is for controlling the barcode reader inside the PHL5x00 terminal range.

More information can be found at the Opticon Sensors Europe website.


Property: ComPort

ComPort

Description | This property is used to tell the PHL5x00 terminal to what serial port the scanner is connected. This property is added for future use. At this moment all barcode reader modules are connected to the COM2 serial port. The default setting for this ComPort property is 2 matching COM2. To use this property in the embedded visual C++ intergrated development environment you can change this property by using the getter and setter for this property.
Syntax short CScannerCtl::GetComPort( void );
void CScannerCtl::SetComPort( short nNewValue );
Arguments
short nNewValue
Sets the new serial port that is opened when the ConnectScanner is called. The value that can be entered for nNewValue can range from 0 to 9. Setting a value outside this range result that the ComPort property is not changed.
Returns | The current set serial port.
Remarks | Setting a value outside the range will result in changes in the ComPort property. The default value for the ComPort property is 2.
Example
BOOL CScanDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Set the icon for this dialog.  The framework does this automatically
    // when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);     // Set big icon
    SetIcon(m_hIcon, FALSE);    // Set small icon

    CenterWindow(GetDesktopWindow());   // center to the hpc screen

    // TODO: Add extra initialization here
    if( m_ScanCtl.GetComPort() != 2 )
        m_ScanCtl.SetComPort( 2 );

    return TRUE;  // return TRUE  unless you set the focus to a control
}


Methods: ConnectScanner

ConnectScanner

Description | Opens the ComPort that identifies the barcode reader module inside the PHL5x00.
Syntax | short CScannerCtl::ConnectScanner( void );
Arguments | None
Returns
0 | Connection successful.
-1 | Error opening the ComPort.
-2 | Error already connected to the barcode reader module.
-3 | Error creating the reading event.
Remarks | If the scanner application in the notification bar is enabled the ConnectScanner will result in -1 when using the default ComPort. Closing the barcode reader module is done by the DisconnectScanner function.
Example
BOOL CScanDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Set the icon for this dialog.  The framework does this automatically
    // when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);     // Set big icon
    SetIcon(m_hIcon, FALSE);    // Set small icon

    CenterWindow(GetDesktopWindow());   // center to the hpc screen

    // TODO: Add extra initialization here
    if( m_ScanCtl.GetComPort() != 2 )
        m_ScanCtl.SetComPort( 2 );

    if( m_ScanCtl.ConnectScanner() != 0 )
        ::MessageBox( NULL,
                _T("ERROR Getting connection to Scanner"),
                _T("Error"),
                MB_OK | MB_ICONERROR | MB_TOPMOST );

    return TRUE;  // return TRUE  unless you set the focus to a control


Methods: DisonnectScanner

DisconnectScanner

Description | Closes the barcode reader module that was previously opened by the ConnectScanner() function.
Syntax | void CScannerCtl::DisconnectScanner( void );
Arguments | None
Returns | None
Remarks | This DisconnectScanner() function is also automatically called when the ScannerCtl object is destroyed.
Example
void CScanDlg::OnDestroy()
{
    CDialog::OnDestroy();

    m_ScanCtl.DisconnectScanner();


Methods: EnableLaser

EnableLaser

Description | Send a command to the barcode reader module that it must emit the laser beam.
Syntax | short CScannerCtl::EnableLaser( void );
Arguments | None
Returns
0 | Laser line enabled.
-4 | Error not connected to barcode reader module.
-5 | Error sending the trigger command.
Remarks To make the EnableLaser() function return successful the barcode reader module must be opened with the ConnectScanner() function.

The barcode(s) that can be read by the Barcode reader module:
Codabar
Code 39
Code 93
Code 128
JAN/EAN
IATA
Industrial 2 of 5
Interleaved 2 of 5
Tri-Optic
MSI plessey
Matrix 2 of 5
Scode
Telepen
UK plessey
UPC
Example
void CScanDlg::OnButtonScan()
{
    if( m_ScanCtl.IsConnected() != 0 )
        m_ScanCtl.ConnectScanner();

    m_ScanCtl.EnableLaser();


Methods: GetCtrlVersion

GetCtrlVersion

Description | Get the version number of the ScannerCtrl ActiveX component.
Syntax | CString CScannerCtl::GetCtrlVersion( void );
Arguments | None
Returns | A string that contains the version number of the ScannerCtl ActiveX component.
Remarks | None
Example
void CScanDlg::OnButtonGetCtlVersion()
{
    ::MessageBox( NULL,
            m_ScanCtl.GetCtrlVersion(),
            _T("Information"),
            MB_OK | MB_TOPMOST | MB_ICONINFORMATION );


Methods: GetModuleVersion

GetModuleVersion

Description | Get the barcode reader modules version number.
Syntax | CString CScannerCtl::GetModuleVersion( void );
Arguments | None
Returns | A string that contains the version number of the barcode reader module or an empty string when ScannerCtl was unable to retrieve the version number.
Remarks | The ScannerCtrl needs to be connected with the ConnectScanner() function to retrieve the barcode reader module version.
Example
void CScanDlg::OnButtonGetModuleVersion()
{
    if( m_ScanCtl.GetModuleVersion().IsEmpty() )
        ::MessageBox( NULL,
                _T("Unable to get module version number."),
                _T("Information"),
                MB_OK | MB_TOPMOST | MB_ICONINFORMATION );
    else
        ::MessageBox( NULL,
                m_ScanCtl.GetModuleVersion(),
                _T("Information"),
                MB_OK | MB_TOPMOST | MB_ICONINFORMATION );


Methods: IsConnected

IsConnected

Description | Checks to see if the ComPort that is connected to the barcode reader module is connected.
Syntax | short CScannerCtl::IsConnected( void );
Arguments | None
Returns
0 | Connected.
-4 | Error not connected to barcode reader module.
Remarks | If the ConnectScanner() function got connected to a valid serial port the IsConnected() function wil return 0 even it is not the ComPort to where the barcode reader module is connected.
Example
void CScanDlg::OnButtonScan()
{
    if( m_ScanCtl.IsConnected() != 0 )
        m_ScanCtl.ConnectScanner();

    m_ScanCtl.EnableLaser();


Methods: SetSystemSetting

SetSystemSetting

Description | Sets some special control options for the barcode reader module.
Syntax | short CScannerCtl::SetSystemSetting( LPCTSTR syssetting );
Arguments | A string that can contain upto 50 characters (25 commands).
Returns
0 | System settings string transmitted OK.
-4 | Error not connected to barcode reader module.
-6 | Error reading from the barcode reader module.
-7 | Error in the systemsetting command string.
-8 | Error Empty systemsettin string.
-9 | Error systemsetting string exceeds 50 characters.
-10 | Error systemsetting string has odd number off charcaters.
Remarks | System settings can be founf in the Opticon Universal Menu Book. The ScannertCtl can only handle 2 character codes. The SetSystemSetting() function can be called more then once.
Example
void CScanDlg::OnButtonSetSystemSetting()
{
    if( m_ScanCtl.SetSystemSetting( _T("RZ1M0O0K") ) != 0 )
    {
        ::MessageBox( NULL,
                _T("Unable to set the requested systemsetting."),
                _T("Information"),
                MB_OK | MB_TOPMOST | MB_ICONINFORMATION );


Events: RcvDataEvent

RcvDataEvent

Description | This function is trigger when the barcode reader module has red a valid barcode.
Syntax | void RcvDataEvent( LPCTSTR strRcvData );
Arguments | A string that holds the readed data.
Returns | None
Remarks | To receive the RcvDataEvent a sink is needed to catch the event. This is done differently by a lot of languages. To get the RcvDataEvent the ScannerCtl needs to be connected with ConnectScanner() to the barcode module the laser needs to be enabled with EnableLaser() and a valid barcode needs to be red.
Example
BEGIN_EVENTSINK_MAP(CScanDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CScanDlg)
    ON_EVENT(CScanDlg, IDC_SCANNERCTL, 1 /* RcvDataEvent */, OnRcvDataEventScannerctl, VTS_BSTR)
    //}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CScanDlg::OnRcvDataEventScannerctl( LPCTSTR strRcvData )
{
    ::MessageBox( NULL,
            strRcvData,
            _T("INFORMATION"),
            MB_OK | MB_TOPMOST | MB_ICONINFORMATION );


Example: JavaScript and HTML

Install ScannerCtl

Description This examples shows how to get control the barcode reader that is inside the PHL5x00 with the ScannerCtl. Before this example can be used make sure that the Scanner application is not enabled and that the OScanCE.DLL is installed and registered on the PHL5x00.
Connect to ScannerCtl Object
<OBJECT ID="ScannerCtl"
    CLASSID="CLSID:F09D063F-229B-4FEF-85BA-ECF6BD2470FF">
    if you see this text then the control cannot be loaded!!!!
</OBJECT>
ConnectScanner
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function Window_OnLoad()
{
    if( ScannerCtl.ConnectScanner() != 0 )
    {
        alert('Error ConnectScanner() ');
    }
}
//-->
</SCRIPT>
DisconnectScanner
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function Window_OnUnLoad()
{
    ScannerCtl.DisconnectScanner();
}
//-->
</SCRIPT>
EnableLaser
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function StartScanning()
{
    if( ScannerCtl.EnableLaser() != 0 )
    {
        alert('Error EnableLaser()');
    }
}
//-->
</SCRIPT>
GetCtrlVersion
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function GetCtrlVersion()
{
    var version;
    version = ScannerCtl.GetCtrlVersion();
    alert( version );
}
//-->
</SCRIPT>
GetModuleVersion
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function GetModVersion()
{
    var version;
    version = ScannerCtl.GetModuleVersion();
    alert( version );
}
//-->
</SCRIPT>
IsConnected
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function Connected()
{
    if( ScannerCtl.IsConnected() != 0 )
    {
        alert('Not connected!!!');
    }
    else
    {
        alert('Connected!!!');
    }
}
//-->
</SCRIPT>
SetSystemSetting
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
function SetSystemSetting()
{
    var sysSet;
    sysSet = systemsetting.value; // systemsetting is a text input field
    if( ScannerCtl.SetSystemSetting( sysSet ) != 0 )
    {
        alert('SystemSetting error!!!');
    }
}
//-->
</SCRIPT>
RcvDataEvent
<SCRIPT LANGUAGE="JAVASCRIPT" FOR="ScannerCtl" EVENT="RcvDataEvent( bcr)">
<!--
    scanned.value = bcr;    // scanned is a text input field to show what barcode is scanned
//-->
</SCRIPT>


Install ScannerCtl (OScanCE.DLL)

Install ScannerCtl

Description There are 3 different versions of the DLL added with the control package. The package contains versions for the PHL5x00, emulator and a Desktop version. The desktop version is only used for registering the ScannerCtl component in the Embedded VC++ IDE.
PHL5x00 3 setup packages are available for the PHL5x00.
OScanCE.DLL | The ScannerCtl object. This can be added to a new cab file with the build application. The OScanCE.DLL can be registered with the regsvrce.exe that is included with eVC++.
OScanCE.ARMV4.cab | Cab file for registering the OSCanCE.DLL. This cab file can be added to a setup package. The cab file can also be used to do a automatic registration of the OScanCe.DLL, just copy the file to the PHL5x00 now tab the file and installation and registration is done automatically. NOTE: To make this cab file automatically install itself copy the cab file to the My Device\DiskOnChip\AutoSetup folder. When the PHL5x00 is cold booted the OSCanCE.DLL will be automatically installed. If the AutoSetup Folder does not exist on the DiskOnChip then the AutoSetup needs to be created.
ScanSetup.exe | Installer for installing the OSCanCE.DLL. To install run the self extracting executable on the desktop when the device is connected to ActiveSync.
Desktop For the EVC++ IDE there is just on package available.
OScanCE.DLL Copy the OSCanCE.DLL for the desktop to your windows\System32 directory.

Register the control on the desktop by doing:

Start -> Run -> regsvr32 c:\Windows\system32\OSCanCE.DLL

This message should appear: "DllRegisterServer in c:\Windows\system32\OScanCE.DLL Succeeded."
Emulator Ther are 2 packages for the emulator included.
OScanCE.DLL | You need to copy and register the OSCanCE.DLL yourself.
OScanCE.x86.CAB | Pocket PC 2003 emulator does not work with ActiveSync by default. You can use Remote File Viewer tool to upload OScanCE.x86.cab file to Pocket PC 2003 emulator. Now tab the cab file to intall and register the OScanCE.DLL.