BIG deep clean
This commit is contained in:
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
USB, based on libusb
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piusb.h"
|
||||
#include "piincludes_p.h"
|
||||
#include "piconfig.h"
|
||||
@@ -284,7 +303,6 @@ bool PIUSB::openDevice() {
|
||||
bool PIUSB::closeDevice() {
|
||||
#ifdef PIP_USB
|
||||
if (hdev == 0) return true;
|
||||
//usb_reset(hdev);
|
||||
usb_release_interface(hdev, intefrace_);
|
||||
usb_close(hdev);
|
||||
hdev = 0;
|
||||
@@ -300,8 +318,11 @@ int PIUSB::readDevice(void * read_to, int max_size) {
|
||||
#ifdef PIP_USB
|
||||
if (isClosed() || ep_read.isNull()) return -1;
|
||||
switch (ep_read.transfer_type) {
|
||||
case Endpoint::Bulk: /*piCoutObj << "bulk read" << max_size;*/ return usb_bulk_read(hdev, ep_read.address, (char * )read_to, max_size, timeout_r); break;
|
||||
case Endpoint::Interrupt: return usb_interrupt_read(hdev, ep_read.address, (char * )read_to, max_size, timeout_r); break;
|
||||
case Endpoint::Bulk:
|
||||
/*piCoutObj << "bulk read" << max_size;*/
|
||||
return usb_bulk_read(hdev, ep_read.address, (char * )read_to, max_size, timeout_r);
|
||||
case Endpoint::Interrupt:
|
||||
return usb_interrupt_read(hdev, ep_read.address, (char * )read_to, max_size, timeout_r);
|
||||
default: break;
|
||||
}
|
||||
return -1;
|
||||
@@ -315,8 +336,11 @@ int PIUSB::writeDevice(const void * data, int max_size) {
|
||||
#ifdef PIP_USB
|
||||
if (isClosed() || ep_write.isNull()) return -1;
|
||||
switch (ep_read.transfer_type) {
|
||||
case Endpoint::Bulk: /*piCoutObj << "bulk write" << max_size;*/ return usb_bulk_write(hdev, ep_write.address, (char * )const_cast<void * >(data), max_size, timeout_w); break;
|
||||
case Endpoint::Interrupt: return usb_interrupt_write(hdev, ep_read.address, (char * )data, max_size, timeout_w); break;
|
||||
case Endpoint::Bulk:
|
||||
/*piCoutObj << "bulk write" << max_size;*/
|
||||
return usb_bulk_write(hdev, ep_write.address, (char * )const_cast<void * >(data), max_size, timeout_w);
|
||||
case Endpoint::Interrupt:
|
||||
return usb_interrupt_write(hdev, ep_read.address, (char * )data, max_size, timeout_w);
|
||||
default: break;
|
||||
}
|
||||
return -1;
|
||||
@@ -329,7 +353,6 @@ int PIUSB::writeDevice(const void * data, int max_size) {
|
||||
int PIUSB::controlWrite(const void * data, int max_size) {
|
||||
#ifdef PIP_USB
|
||||
if (isClosed()) return -1;
|
||||
//return usb_control_msg(hdev, );
|
||||
return -1;
|
||||
#else
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user