has anyone a solution how to setz port pins HIGH and LOW with "WahTeng WT-001" USB -> LPT Konverter with ASUS WL-500g Premium?
Florian
Hi MoD,
the source and makefile you refer to is for kernel series 2.6.
I can help you if you want tro compile for that kernel version.
But you could also just read the readme file.
If you want to (cross)compile for the asus i can't help you.
Martin
has anyone a solution how to setz port pins HIGH and LOW with "WahTeng WT-001" USB -> LPT Konverter with ASUS WL-500g Premium?
Florian
can you guys tell me where can i buy an usb -> lpt adapter with MOSCHIP MSC7715 Chip?
Greets
Florian
Thx for themyport example code. I compiled it an run it on latest supported oleg firmware for asus wl-500g.
Now my problem is to find out on how could i set the 8 datapins on LPT to high / low. i find out to set one port to high with setting
parport_write_data(100, base);
and set the same port to low with
parport_write_data(112, base);
but how could i set the other 7 data pins?
Greets
Florian
Hi Florian,
you can set/clear the data lines this way:
(with bitnum from 0 to 7)
void set_pin(unsigned char bitnum)
{
unsigned char port_val, port_mask = 0x01;
port_val = parport_read_data(base); // read the portlines to port_val
port_val |= (port_mask << bitnum); // set the bit in port_val
parport_write_data(port_val, base); // write back port_val
}
void clear_pin(unsigned char bitnumber)
{
unsigned char port_val, port_mask =0x01;
port_val = parport_read_data(base); // read the portlines to port_val
port_val &= ~(mask << bitnum); // clear the bit in port_val to 1
parport_write_data(port_val, base); // write back port_val
}
Or the same in one line:
Set portline:
parport_write_data(parport_read_data(base)|=(0x1<< bitnum),base);
Clear portline:
parport_write_data(parport_read_data(base)&= ~(0x1<<bitnum),base);
Martin
ok thanks i will try it later and give a report.
now i have inserted your functions but i don't know how to use them.
when i try the following nothing happens:Code:void set_pin(unsigned char bitnum, unsigned char* base) { unsigned char port_val, port_mask = 0x01; port_val = parport_read_data(base); // read the portlines to port_val port_val |= (port_mask << bitnum); // set the bit in port_val parport_write_data(port_val, base); // write back port_val } void clear_pin(unsigned char bitnum, unsigned char* base) { unsigned char port_val, port_mask =0x01; port_val = parport_read_data(base); // read the portlines to port_val port_val &= ~(port_mask << bitnum); // clear the bit in port_val to 1 parport_write_data(port_val, base); // write back port_val }
what i've been doing wrong?Code:unsigned char bitnum=2; // 0 to 7 right? set_pin(bitnum,base); printf("Pin ON\n"); usleep(5000);
sorry for my stupid question but i'm not so fit in c.
Hi Florian,
make sure that you have initialized the pointer "base" ( base = oleg_fn() ) before you use it.
Check your programm for the correct use of pointers and dereferenced pointers.
Martin
hm i think thats all right. Here's my main function. Its nearly the same like in your myport source. the rest of the code is the same too.
is the following the problem: unsigned char bitnum='3'; ??
Code:int main(int argc, char *argv[]) { int i; unsigned char *base=NULL; base = oleg_fn(); if(base==NULL) return 1; unsigned char bitnum='3'; set_pin(bitnum,base); printf("Pin ON\n"); usleep(5000); printf("Fertig\n"); return 0; }
Hi Florian,
Change the expression "unsigned char bitnum='3';" to "unsigned char bitnum=3;" and your program should work as expected.
Martin
ok thx it works but i wonder why only port 4 and 6 works as well. maybe i try first to connect 8 LEDS to parallel port insted of my radio Power jack remote.