Git Product home page Git Product logo

usb-asio's People

Contributors

diggit avatar miso1289 avatar xjankovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usb-asio's Issues

can't use `boost::bind` as completion token

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)

Segfault (nullptr) access in interface claim

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
  • there has to be overload of interface unclaim which accepts device handle directly (available in claim fcn).
  • avoid calling unclaim when device_handle_ is not valid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.