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:
peri4
2014-04-29 11:50:13 +04:00
parent 77abb0bbea
commit 2e5e75c4c4
98 changed files with 2545 additions and 768 deletions

View File

@@ -9,16 +9,19 @@
# endif
#endif
REGISTER_DEVICE(PIUSB);
PIUSB::PIUSB(ushort vid, ushort pid): PIIODevice("", ReadWrite, false) {
PIUSB::PIUSB(ushort vid, ushort pid): PIIODevice("", ReadWrite) {
vid_ = vid;
pid_ = pid;
path_ = PIString::fromNumber(vid_, 16).expandLeftTo(4, "0") + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, "0");
dev_num = 1;
intefrace_ = 0;
hdev = 0;
interface_claimed = -1;
timeout_r = timeout_w = 1000;
setPath(PIString::fromNumber(vid_, 16).expandLeftTo(4, "0") + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, "0"));
setDeviceNumber(1);
setTimeoutRead(1000);
setTimeoutWrite(1000);
}
@@ -145,9 +148,9 @@ bool PIUSB::configureDevice(const void * e_main, const void * e_parent) {
bool PIUSB::openDevice() {
#ifdef PIP_USB
if (path_.size_s() >= 8) {
vid_ = path_.left(4).toInt(16);
pid_ = path_.right(4).toInt(16);
if (path().size_s() >= 8) {
vid_ = path().left(4).toInt(16);
pid_ = path().right(4).toInt(16);
}
if (hdev != 0) closeDevice();
hdev = 0;
@@ -172,7 +175,7 @@ bool PIUSB::openDevice() {
for (bus = usb_get_busses(); bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
if (dev->descriptor.idVendor == vid_ && dev->descriptor.idProduct == pid_) {
if (cur_num == dev_num) {
if (cur_num == deviceNumber()) {
struct usb_device_descriptor & dd(dev->descriptor);
desc_.usb_spec_number = dd.bcdUSB;
desc_.device_class = dd.bDeviceClass;
@@ -383,3 +386,18 @@ PICout operator<<(PICout s, const PIUSB::Endpoint & v) {
s.restoreControl();
return s;
}
void PIUSB::configureFromFullPath(const PIString & full_path) {
PIStringList pl = full_path.split(":");
for (int i = 0; i < pl.size_s(); ++i) {
PIString p(pl[i]);
switch (i) {
case 0: setVendorID(p.toUShort(16)); break;
case 1: setProductID(p.toUShort(16)); break;
case 2: setDeviceNumber(p.toInt()); break;
case 3: setEndpointRead(Endpoint(p.toInt())); break;
case 4: setEndpointWrite(Endpoint(p.toInt())); break;
}
}
}