47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#ifndef C5ADE9DB_6B16_4E4F_8C58_0101E9832DE0
|
|
#define C5ADE9DB_6B16_4E4F_8C58_0101E9832DE0
|
|
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include <string>
|
|
#include <poll.h>
|
|
|
|
namespace Util
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DECLARE
|
|
*******************************************************************************
|
|
*/
|
|
class Device
|
|
{
|
|
public:
|
|
enum Mode
|
|
{
|
|
RD_ONLY,
|
|
WR_ONLY,
|
|
RDWR,
|
|
};
|
|
|
|
public:
|
|
Device(std::string path, Mode mode = Mode::RD_ONLY);
|
|
~Device();
|
|
|
|
virtual void open();
|
|
virtual int write(uint8_t* data, int size);
|
|
virtual int read(uint8_t* buffer, int count);
|
|
virtual void close();
|
|
virtual int fcntl(int cmd);
|
|
virtual int fcntl(int cmd, long arg);
|
|
virtual int fcntl(int cmd, long arg, void* lock);
|
|
virtual int poll(unsigned int& revents, int timeout);
|
|
|
|
private:
|
|
std::string _path;
|
|
Mode _mode;
|
|
int _fd;
|
|
};
|
|
}
|
|
#endif
|