miso1289 / usb-asio Goto Github PK
View Code? Open in Web Editor NEWLibusb wrapper for Asio
License: MIT License
Libusb wrapper for Asio
License: MIT License
Hi,
I am trying to pass std::bind as completion token to async bulk read.
My inspiration is this boost example.
As I am total asio noob, I am quite lost. Do you know what could be the issue?
class Pump : public boost::enable_shared_from_this<Pump> {
public:
std::array<std::byte, 512> buffer {};
void start() {
boost::asio::async_read(
source,
boost::asio::buffer(buffer),
boost::bind(
&Pump::handle_read, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
)
);
}
private:
Pump(std::deque<std::byte> &sink, usb_asio::usb_in_bulk_transfer &source, const unsigned int id) :
sink(sink),
source(source),
id(id)
{}
void handle_read(boost::system::error_code error_code, std::size_t bytes_read) {
assert(error_code);
if (bytes_read) {
sink.insert(sink.end(), buffer.begin(), buffer.begin()+bytes_read);
}
start();
}
std::deque<std::byte> &sink;
usb_asio::usb_in_bulk_transfer &source;
unsigned int id {};
};
[error.txt](https://github.com/MiSo1289/usb-asio/files/10483346/error.txt)
Hi,
first of all, thank you for all your work... díky :)
I am trying to use your asio wrapper of libusb and I am struggling a little bit. It's all blowing up in interface claiming. There is uninitialized data access resulting in null pointer de-reference.
My code is just slightly modified example from readme.
Constructing interface object calls claim
.
claim
itself calls unclaim
at first.
unclaim
calls ::libusb_release_interface
which takes device handler as argument.
Device handle pointer is obtained by calling device_handle
, which returns device_handle_
, but this data member is not set yet. That happens at the end of claim
fcn.
Unless I am using it wrong, there is several ways to fix this:
device_handle_
has to be set before calling unclaim
unclaim
which accepts device handle directly (available in claim fcn).unclaim
when device_handle_
is not validA declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.