user902691
user902691

Reputation: 1159

Lib usb how to read character from port

I want to write an application that reads data from the USB device and was looking for a library that can make the job easier. I found a library called lib-usb. Unfortunately, it has almost no documentation. Here is what I have tried:

#include <stdio.h>
#include <stdlib.h>
#include <usb.h>

     int main(){
        struct usb_device dev;
        struct usb_device *device;
        usb_dev_handle *handle;
        struct usb_bus bus;

usb_init();
            usb_find_busses();
            int a=usb_find_devices();
        bus=usb_get_buses();
        handle=usb_open(device);

            return 0;
        }

But I can't figure out how to select a port that I want to read from. I would like to save read data as a string. Any advice is appreciated.

Upvotes: 1

Views: 1613

Answers (1)

user149341
user149341

Reputation:

USB doesn't really transfer characters -- it transfers packets. Additionally, your code makes no sense at all; there is some pretty good documentation online at http://libusb.sourceforge.net/api-1.0/, which I recommend that you read.

Upvotes: 2

Related Questions