29.04.2014 - Version 0.4.0_prealpha. PICodeParser, namespace PICodeInfo, new tool "pip_cmg" in dir "code_model_generator". New feature in PIIODevice - "createFromFullPath", all parameters of all I/O devices now works with PIObjects`s properties.
This commit is contained in:
57
piusb.h
57
piusb.h
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
USB, based on libusb
|
||||
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2014 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -27,7 +27,9 @@
|
||||
|
||||
struct usb_dev_handle;
|
||||
|
||||
class PIP_EXPORT PIUSB: public PIIODevice {
|
||||
class PIP_EXPORT PIUSB: public PIIODevice
|
||||
{
|
||||
PIIODEVICE(PIUSB)
|
||||
public:
|
||||
PIUSB(ushort vid = 0, ushort pid = 0);
|
||||
|
||||
@@ -58,7 +60,7 @@ public:
|
||||
ushort class_code;
|
||||
ushort subclass_code;
|
||||
ushort protocol_code;
|
||||
PIVector<Endpoint> endpoints;
|
||||
PIVector<PIUSB::Endpoint> endpoints;
|
||||
};
|
||||
|
||||
struct Configuration {
|
||||
@@ -69,7 +71,7 @@ public:
|
||||
ushort max_power; // mA
|
||||
bool self_powered;
|
||||
bool remote_wakeup;
|
||||
PIVector<Interface> interfaces;
|
||||
PIVector<PIUSB::Interface> interfaces;
|
||||
};
|
||||
|
||||
struct Descriptor {
|
||||
@@ -85,37 +87,38 @@ public:
|
||||
uchar index_manufacturer;
|
||||
uchar index_product;
|
||||
uchar index_serial;
|
||||
PIVector<Configuration> configurations;
|
||||
PIVector<PIUSB::Configuration> configurations;
|
||||
};
|
||||
|
||||
const Descriptor & currentDescriptor() const {return desc_;}
|
||||
const Configuration & currentConfiguration() const {return conf_;}
|
||||
const Interface & currentInterface() const {return iface_;}
|
||||
const PIUSB::Descriptor & currentDescriptor() const {return desc_;}
|
||||
const PIUSB::Configuration & currentConfiguration() const {return conf_;}
|
||||
const PIUSB::Interface & currentInterface() const {return iface_;}
|
||||
|
||||
ushort vendorID() const {return vid_;}
|
||||
ushort productID() const {return pid_;}
|
||||
|
||||
int deviceNumber() const {return dev_num;}
|
||||
int deviceNumber() const {return property("deviceNumber").toInt();}
|
||||
int timeoutRead() const {return property("timeoutRead").toInt();}
|
||||
int timeoutWrite() const {return property("timeoutWrite").toInt();}
|
||||
const PIUSB::Endpoint & endpointRead() {return ep_read;}
|
||||
const PIUSB::Endpoint & endpointWrite() {return ep_write;}
|
||||
|
||||
const PIVector<Endpoint> & endpoints() const {return eps;}
|
||||
PIVector<Endpoint> endpointsRead();
|
||||
PIVector<Endpoint> endpointsWrite();
|
||||
Endpoint getEndpointByAddress(uchar address);
|
||||
const PIVector<PIUSB::Endpoint> & endpoints() const {return eps;}
|
||||
PIVector<PIUSB::Endpoint> endpointsRead();
|
||||
PIVector<PIUSB::Endpoint> endpointsWrite();
|
||||
PIUSB::Endpoint getEndpointByAddress(uchar address);
|
||||
|
||||
const Endpoint & endpointRead() {return ep_read;}
|
||||
const Endpoint & endpointWrite() {return ep_write;}
|
||||
|
||||
void setVendorID(ushort vid) {vid_ = vid; path_ = PIString::fromNumber(vid_, 16).expandLeftTo(4, "0") + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, "0");}
|
||||
void setProductID(ushort pid) {pid_ = pid; path_ = PIString::fromNumber(vid_, 16).expandLeftTo(4, "0") + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, "0");}
|
||||
void setVendorID(ushort vid) {vid_ = vid; setPath(PIString::fromNumber(vid_, 16).expandLeftTo(4, "0") + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, "0"));}
|
||||
void setProductID(ushort pid) {pid_ = pid; setPath(PIString::fromNumber(vid_, 16).expandLeftTo(4, "0") + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, "0"));}
|
||||
|
||||
bool setConfiguration(uchar value);
|
||||
bool setInterface(uchar value);
|
||||
|
||||
void setEndpointRead(const Endpoint & ep) {ep_read = ep;}
|
||||
void setEndpointWrite(const Endpoint & ep) {ep_write = ep;}
|
||||
void setDeviceNumber(int dn) {dev_num = dn;}
|
||||
void setTimeoutRead(int t) {timeout_r = t;}
|
||||
void setTimeoutWrite(int t) {timeout_w = t;}
|
||||
void setEndpointRead(const PIUSB::Endpoint & ep) {ep_read = ep;}
|
||||
void setEndpointWrite(const PIUSB::Endpoint & ep) {ep_write = ep;}
|
||||
void setDeviceNumber(int dn) {setProperty("deviceNumber", dn);}
|
||||
void setTimeoutRead(int t) {setProperty("timeoutRead", t);}
|
||||
void setTimeoutWrite(int t) {setProperty("timeoutWrite", t);}
|
||||
|
||||
int read(void * read_to, int max_size);
|
||||
int write(const void * data, int max_size);
|
||||
@@ -124,16 +127,18 @@ public:
|
||||
void flush();
|
||||
|
||||
protected:
|
||||
PIString fullPathPrefix() const {return "usb";}
|
||||
void configureFromFullPath(const PIString & full_path);
|
||||
bool configureDevice(const void * e_main, const void * e_parent = 0);
|
||||
//bool init();
|
||||
bool openDevice();
|
||||
bool closeDevice();
|
||||
|
||||
PIVector<Endpoint> eps;
|
||||
PIVector<PIUSB::Endpoint> eps;
|
||||
ushort vid_, pid_;
|
||||
int dev_num, intefrace_, timeout_r, timeout_w;
|
||||
int intefrace_, timeout_r, timeout_w;
|
||||
int interface_claimed;
|
||||
Endpoint ep_read, ep_write;
|
||||
PIUSB::Endpoint ep_read, ep_write;
|
||||
Descriptor desc_;
|
||||
Configuration conf_;
|
||||
Interface iface_;
|
||||
|
||||
Reference in New Issue
Block a user