⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb.h

📁 an example of programming philips pegoda reader
💻 H
字号:
/*
*         Copyright (c), Philips Semiconductors Gratkorn / Austria
*
*                     (C)PHILIPS Electronics N.V.2000
*       All rights are reserved. Reproduction in whole or in part is 
*      prohibited without the written consent of the copyright owner.
*  Philips reserves the right to make changes without notice at any time.
* Philips makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. Philips must not be liable for any loss or damage
*                          arising from its use.
*/

/*! \file USB.h
*
* Projekt: MF EV X00 Firmware
*
* $Workfile:: USB.h                                                 $ 
* $Modtime:: 11.07.01 14:09                                             $ 
* $Author:: Hb                                                          $
* $Revision:: 14                                                        $
*
*/
#ifndef USB_H
#define USB_H

#ifdef __cplusplus
extern "C" {
#endif

//----------------------------------------------------------------------------
// INCLUDES
//----------------------------------------------------------------------------
#include <ReaderInterface.h>
#include <windows.h>
#include <USBDll.h>

/// USB communication interface
/*!
* \ingroup hostrdcom
* 
*/
class DLLEXP_IMP USB 
: public ReaderInterface
{
public:
    /// Construction, destruction
    //@{
    USB();
    virtual ~USB();
    //@}

    /// Overloaded member functions from ReaderInterface
    /*!
    */
    //@{

    /// Open and initialize the interface
    /*!
    * \param none
    * \return
    *
    */
    virtual short OpenInterface();

    /*!
    * \param none
    * \return
    *
    */
    virtual short CloseInterface();

    /// Closes the open interface and reopens it
    /*!
    * \param none
    * \return
    *
    */
    virtual short ResetInterface();

    /// Purge all remaining data and initialize internal structures 
    /*!
    * \param none
    * \return
    *
    */
    virtual short ClearInternalBuffers();

    /// Send a given number of bytes to the reader
    /*!
    * \param data    pointer to the data array
    * \param datalen number of bytes in the data array
    * \param dwBytesWritten number of bytes written to the device
    * \param Timeout  timeout periode for writing to the device
    * \return
    *
    */
    short WriteBytesUnblocked(unsigned char* data, 
                              unsigned long datalen,
                              unsigned long &dwBytesWritten,
                              unsigned long Timeout);

    /// Receive a given number of bytes from the reader
    /*!
    * \param none
    * \return
    *
    */
    short ReadBytesUnblocked(unsigned char* data, 
                             unsigned long datalen,
                             unsigned long &dwBytesRead,
                             unsigned long Timeout);
    //@}

    //! BUG: Wrong Operator Delete Called for Exported Class
    /*!
    * \name BUG: Q122675
    *
    * When allocating and deleting an object of a class that is exported from a DLL, 
    * you may find that the new operator in the EXE is called to allocate the memory but 
    * the delete operator in the DLL is called to delete the memory. Therefore, there is 
    * a new/delete mismatching problem, which may cause run-time errors. 
    */
    //@{
    void* operator new( size_t tSize );
    void  operator delete( void* p );
    //@}

private:
    //! protected copy constructor
    USB(const USB& usb) {};

    //! protected overridden assignment operator
    USB& operator= (const USB& usb)
         { return * this;} ;

private:
    /// Function Pointer for USB-dll
    /*! \name Function Handles
    * For each member function of the USB-dll, a function pointer is
    * provided.
    */
    //@{
    HINSTANCE           m_hDll;

    HANDLE              m_hInterface;

    TUSBLib_Register    _USBLib_Register;
    TUSBLib_Release     _USBLib_Release;
    TUSBLib_ReadPipe    _USBLib_ReadPipe;
    TUSBLib_WritePipe   _USBLib_WritePipe;
    //@}

    /// Change status message received from USB-dll to "MfErrNo"
    /*!
    * \param winErr  Status from the USB-dll
    * \param isWriteAccess <ul>
    *                        <li> 0   read access from the DLL
    *                        <li> 1   write access to the DLL
    *                      </ul>
    * \return <ul>
    *          <li> COM_SUCCESS           operation successful
    *          <li> COM_USB_SEND_TIMEOUT  timeout periode exceeded while writing to the device
    *          <li> COM_USB_RECV_TIMEOUT  timeout periode exceeded while reading from the device
    *          <li> COM_USB_FILE_NOT_FOUND file descriptor not longer valid
    *          <li> COM_USB_ACCESS_DENIED device could not be accessed
    *          <li> COM_ERROR             unknown error message from the USB device API
    *         </ul>
    *
    * Changes the error received from the USB-dll to a error code
    * which ist defined in the file "MfErrNo.h".
    */
    short dllToComError(unsigned long winErr, bool isWriteAccess);
};

#ifdef __cplusplus
}
#endif

#endif // RS232_100101_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -