Skip to content

Instantly share code, notes, and snippets.

@uucidl
Created January 22, 2018 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uucidl/7f88d675ffa7184b345d46d020fcaa6e to your computer and use it in GitHub Desktop.
Save uucidl/7f88d675ffa7184b345d46d020fcaa6e to your computer and use it in GitHub Desktop.
little program to use if you're canoscan lide30 scanner says "device not configured"
#!/usr/bin/env bash
export C_INCLUDE_PATH=/usr/local/include/libusb-1.0
export LIBRARY_PATH=/usr/local/lib
(O=canoscan ; cc canoscan_unit.c -o "${O}" -lusb-1.0 && printf "PROGRAM\t%s\n" "${O}")
// I used this little program when my canoscan lide30 scanner would say "device not configured"
// when using sane-backends on Macos.
//
// The symptom (device not configured) would show up when running `sane-find-scanner -v -v` (you need
// the two -v flag to show the verbose diagnostic.
//
// To compile and use, install libusb (which should already have been installed if like me you
// installed the sane-backends using brew) and compile via canoscan_build.sh
#include <libusb.h>
#include <stdio.h>
#include <stdlib.h>
#define UU_LIBUSB_GUARD(x) for (int err = x; err != 0; exit(1)) { \
printf("unexpected libusb error: %s\n", libusb_strerror(err)); \
}
libusb_device_handle* uu_find_canoscan_device(libusb_context* ctx)
{
return libusb_open_device_with_vid_pid(ctx, 0x04a9, 0x220e);
}
int main(int argc, char** argv)
{
printf("Remember you can set the LIBUSB_DEBUG environment variable to turn debugging on.\n");
int rc = 0;
libusb_context* ctx;
UU_LIBUSB_GUARD(libusb_init(&ctx));
libusb_device_handle* canoscan = uu_find_canoscan_device(ctx);
if (!canoscan) {
printf("Could not find canoscan lide30 device\n");
rc = 1;
goto done;
}
printf("Opened Canoscan LiDE 30 device\n");
UU_LIBUSB_GUARD(libusb_set_configuration(canoscan, 1)); // This is forcefully activating the configuration
done_with_device:
libusb_close(canoscan);
done:
libusb_exit(ctx);
return rc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment