Changeset e017851 in thomson for elec/CrO2/software/device.h


Ignore:
Timestamp:
Jan 14, 2013, 11:05:27 PM (11 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
6bd7144
Parents:
4a558d7
Message:

Port to Haiku. Untested.

git-svn-id: svn://localhost/thomson@28 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • elec/CrO2/software/device.h

    r4a558d7 re017851  
    88
    99#include <stdint.h>
    10 #include <lusb0_usb.h>
     10#include <string.h>
    1111
    1212class Tape;
     
    1515{
    1616        public:
     17                // Implemented in subclasses object files. Only one of them is linked
     18                // and takes care of instanciating itself.
    1719                static Device& getDevice() throw(const char*);
    1820
    19                 ~Device();
     21                // High-level layer (will call functions below)
     22                void write(const Tape& file) throw (const char*);
    2023
    21                 int read(uint8_t* buffer, size_t max); // Fill the buffer with data from device
    22                 int write(const uint8_t* buffer, size_t size, int blktype);
    23                 void write(const Tape& file) throw (const char*);
    24                 uint8_t getStatus();
     24                // Low-level layer (to be implemented by subclasses
     25                virtual int read(uint8_t* buffer, size_t max) = 0;
     26                        // Fill the buffer with data from device
     27                virtual int write(const uint8_t* buffer, size_t size, int blktype) = 0;
     28                virtual uint8_t getStatus() = 0;
     29                        // Get the status word from the device
    2530
    26         private:
    27                 Device() throw(const char*); // Open device and set it up for communication
    28                 Device(const Device& other);
    29 
    30 
    31                 usb_dev_handle* handle;
    32 
    33                 static bool initOnce;
    34                 static Device* instance;
     31        protected:
     32                /* These are the vendor specific commands implemented by our USB device */
     33                static const int PSCMD_CONFIG = 0;
     34                static const int PSCMD_GET = 1;
     35                static const int PSCMD_PUT = 2;
     36                static const int PSCMD_STATUS = 3;
    3537
    3638                static const uint32_t vid;
     
    3840                static const char* vendor;
    3941                static const char* product;
     42        private:
     43                static bool initOnce;
     44                static Device* instance;
    4045};
Note: See TracChangeset for help on using the changeset viewer.