I am looking for this for about two weeks with no answer (how to control the LPT of that f***ing thing).
No answers yet.
Hello,
I'd like to connect some I2C thermometer chip to parallel port of WL500g, but so far I've no idea about low-level control of specific LPT pins in WL500g. Is there some example code to toggle and read ASUS parallel port pins?
I am looking for this for about two weeks with no answer (how to control the LPT of that f***ing thing).
No answers yet.
Just use generic parallel port ioctls, that's it. But remember to remove lp.o module first.
Oleg, would You (or somebody else) please compile _simple_ LPT ioctl binary program, that can be called with additional parameters from command line?Originally Posted by Oleg
Something like:
lptioctl port_no bit_no value
and:
lptioctl port_no bit_no
(where return value = bit state)
Then it will be quite easy (at least for me) to write simple shell script for I2C or anything else.
Yes, that would be more than helpful. I would like to see the source also.
My idea about that is something like this
./lptioctl (portnumber) send (number)
./lptioctl (portnumber) read
=> returns a byte
this is where i got:
[quote]
#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#define base 0xBF800010
static void parport_write_data(unsigned char d) {
unsigned char *io = (unsigned char *) base;
*io = d;
}
static unsigned char parport_read_data() {
unsigned char *io = (unsigned char *) base;
return *io;
}
static unsigned char parport_read_status()
{
unsigned char *io = (unsigned char *) base;
return *(io+1);
}
static int LPTInit()
{
check_mem_region(base, 3)
}
static void parport_splink_unregister_port()
{
release_mem_region(base, 3);
}
int main()
{
if (LPTInit())
{
int i;
for (i=0;i<10000;i++) {
parport_write_data(254);
usleep(10000);
parport_write_data(1);
usleep(10000);
}
}
}
[quote]
i'm compiling it with
This thing should blink some data pins on the lpt port, right? But it doesn't. It just gives me a nice Segmentation Fault.mipsel-uclibc-gcc -o p.c
I removed all the lpt stuff from the firmware (modules, lpd and l910...) (in fact it's a 10gig hdd partition)
What i've done wrong?
Use iopl(3) to get an access.
In fact you will probably need to mmap this memory first to get an access to it.
please give me an example.
Check this code for the general mmap code sample:
http://wl500g.info/attachment.php?attachmentid=171
Most likely you will need to change 0xBF800010 to 0x1F800010; mmap 0x1F800000 (aligned), then access +0x10.
lost myself there
Code:void *map; unsigned char *base; int fd = open("/dev/mem", O_RDWR); if (fd < 0) { perror("/dev/mem"); return 1; } map = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x1f800000); if (map == NULL) { perror("mmap"); return 1; } printf("Device memory mapped ok\n"); base = ((unsigned char *)map) + 0x10;
No positive results yet.
I looked at parport_splink.c file and i extracted from there the things i thought are used for writing to the port. However, that's without mmap and things like that. But that doesn't work also. I believe that the compile command-line is not right also. Any ideas?
Oleg, your code only maps the memory, right? Then i have to writeb() at base? Or do i need to do more complex things?
There is a similar thread on Q&A where someone apparently did a module for controlling the LPT. I think i'll wait for his reply because it states that the module works.
In the end, it sounds that it's really rocket science to blink those d**n data lines.
no, just compile as usual. no writeb is needed.
can you post a complete example (.c) which blinks the data lines with a 1 sec interval? And which command should i use to compile it?
That would be more than helpful
ps: with this wl500g i realised that embedded programming is not that easy as x86
Any idea? Anyone?