Reputation: 95
I'm trying to open a connection to a camera from a raspberry pi 2 over usb. I'm able to detect the camera but when I try to open a connection using
libusb_open_device_with_vid_pid(null, vendor id, product id);
But I receive a segmentation fault. I've narrowed it down and that line of code is what causes the segmentation fault.
void opendevice(){
libusb_device_handle* dev;
struct libusb_device_descriptor* desc;
int err;
dev = libusb_open_device_with_vid_pid(NULL,0x2a0b,0x00f8);
if (dev == NULL){
printf("device not found\n");
}
else {
err = libusb_claim_interface(dev, 0);
}
}
The message from the pi opened over putty on my computer is.
Segmentation fault
Any ideas as to what I am doing wrong?
Upvotes: 0
Views: 1119
Reputation: 2505
You are getting NULL
for dev
, and using it anyway. You could add a return statement after the printf()
, or an else
before the libusb_claim_interface()
.
Upvotes: 1