Results 1 to 8 of 8

Thread: USB programming

  1. #1

    USB programming

    Hello,

    I want to ask what are possibilities of USB programming in Oleg 1.9.2.7-d firmware? Which library to use? What I need to download? Is it possible to cross-compile it on Linux PC (or just compile it on virtual Open-WRT) and then upload it to router?

    I'm going to make a LCD display (with ATMega168) for my WL-500gPv2 router and I want to send information from firmware to my ATMega over USB.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2006
    Location
    Russia, Moscow
    Posts
    3,640
    Just like on ordinary linux 2.4.37. You can find many articles in internet. Simplest way - use libusb 1.0 library.

  3. #3
    Quote Originally Posted by lly View Post
    Just like on ordinary linux 2.4.37. You can find many articles in internet. Simplest way - use libusb 1.0 library.
    Thanks.

    I wasn't just sure if libusb is available for Oleg firmware.

  4. #4
    Join Date
    Feb 2007
    Location
    Moscow, Russia
    Posts
    3,805
    e.g. this project: http://www.harbaum.org/till/lcd2usb/index.shtml doesn't require driver at all. To say more exactly the driver is built into the software ( lcdproc or lcd4linux ) lcd4linux is available in optware, lcdproc can be built natively.

  5. #5
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by lly View Post
    Just like on ordinary linux 2.4.37. You can find many articles in internet. Simplest way - use libusb 1.0 library.
    Yes, libusb is the way to go
    Last time I tried with the optware compiler on the router it didn't work tho... maybe it's also because the webcam driver claimed the xbox360 controller I was attempting to read out.
    Maybe you have better luck with the crosscompiler

    quick example:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <libusb.h>
    
    int Send(libusb_device_handle *h, unsigned char data[], unsigned char endpoint)
    {
        int transferred, r;
        r = libusb_interrupt_transfer(h, endpoint, data, sizeof data, &transferred, 0);
        return r;
    }
    
    int Init(void)
    {
        libusb_device_handle *Controller;
        libusb_init(NULL);
        Controller = libusb_open_device_with_vid_pid(NULL, 0x045e, 0x028e);
    }
    With the init function you start the libusb and open the first (unclaimed) device with a specific vid and pid.

    Depending on the AVR configuration you can also read data from a specific usb endpoint when the buffer (data) is empty (or needs to be filled).

    usb on avr can be a little messy btw
    at least, it's not my favourite thing to do

  6. #6
    Quote Originally Posted by wpte View Post
    Yes, libusb is the way to go
    Last time I tried with the optware compiler on the router it didn't work tho... maybe it's also because the webcam driver claimed the xbox360 controller I was attempting to read out.
    Maybe you have better luck with the crosscompiler

    quick example:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <libusb.h>
    
    int Send(libusb_device_handle *h, unsigned char data[], unsigned char endpoint)
    {
        int transferred, r;
        r = libusb_interrupt_transfer(h, endpoint, data, sizeof data, &transferred, 0);
        return r;
    }
    
    int Init(void)
    {
        libusb_device_handle *Controller;
        libusb_init(NULL);
        Controller = libusb_open_device_with_vid_pid(NULL, 0x045e, 0x028e);
    }
    With the init function you start the libusb and open the first (unclaimed) device with a specific vid and pid.

    Depending on the AVR configuration you can also read data from a specific usb endpoint when the buffer (data) is empty (or needs to be filled).

    usb on avr can be a little messy btw
    at least, it's not my favourite thing to do
    Thanks for help. I've got some experience with my AVR and Windows libusb-0.1 library so I hope it won't be so hard to compile one simple USB data sending program. (never say never...)
    Last edited by Blackbirdrozd; 12-01-2011 at 16:22.

  7. #7
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by Blackbirdrozd View Post
    Thanks for help. I've got some experience with my AVR and Windows libusb-0.1 library so I hope it won't be so hard to compile one simple USB data sending program. (never say never...)
    Shouldn't be too difficult then
    I only tried .net libusb out once, which was slightly different in initiating, sending and receiving

    anyway, maybe some pictures when you're finished?

  8. #8
    Quote Originally Posted by wpte View Post
    anyway, maybe some pictures when you're finished?
    I will definitly post pictures. It will be outside module for now (I'm going to buy a new router and I don't want to uncover it bcs of warranty).

    But I don't have router yet...

    • Get router
    • Buy parts for board
    • Make testing breadboard
    • Programm AVR - AvrX + USB data reading process
    • Make USB data sending program and test it on PC
    • Compile code for/at router firmware
    • Test everything
    • Make final PCB


    I hope it will be done in two weeks (buy everything, code and also I'm student and these days we have exams, so school is priority ).

Similar Threads

  1. linuxrc bug? - WL-500g not booting from usb drive with hub
    By daniel632 in forum WL-500g Custom Development
    Replies: 5
    Last Post: 14-03-2012, 16:28
  2. Unstable boot from USB
    By Tamadite in forum WL-500g Q&A
    Replies: 6
    Last Post: 20-08-2008, 16:19
  3. 7.09 + USB + hotplug
    By oilinki in forum WL-700g Q&A
    Replies: 0
    Last Post: 18-11-2007, 13:51

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •