Bekijk de volledige versie : USB programming
Blackbirdrozd
12-01-2011, 07:59
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.
Just like on ordinary linux 2.4.37. You can find many articles in internet. Simplest way - use libusb 1.0 library.
Blackbirdrozd
12-01-2011, 11:28
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.
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.
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:D
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:
#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:p
Blackbirdrozd
12-01-2011, 14:15
Yes, libusb is the way to go:D
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:
#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:p
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...)
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?:D
Blackbirdrozd
12-01-2011, 21:10
anyway, maybe some pictures when you're finished?:D
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... :o
Get router :o
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 ;) ).