Page 3 of 3 FirstFirst 123
Results 31 to 41 of 41

Thread: LPT thermometer

  1. #31

    MOSCHIP module compile

    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

  2. #32
    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

  3. #33

    where to buy?

    can you guys tell me where can i buy an usb -> lpt adapter with MOSCHIP MSC7715 Chip?

    Greets
    Florian

  4. #34
    Quote Originally Posted by martins View Post
    Hello,

    with this example code you can directly access the printer port pins.
    You must have the toolchan installed to compile.
    Compile with ./build.sh

    If someone knows how to avoid static linking, please let me know.

    Martin

    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

  5. #35

    Set/Clear one single portpin

    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

  6. #36
    ok thanks i will try it later and give a report.

  7. #37
    now i have inserted your functions but i don't know how to use them.

    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
    }
    when i try the following nothing happens:

    Code:
       unsigned char bitnum=2; // 0 to 7 right?
       set_pin(bitnum,base);
       printf("Pin ON\n");
       usleep(5000);
    what i've been doing wrong?
    sorry for my stupid question but i'm not so fit in c.

  8. #38

    "base" has to point to the memory maped parallel port

    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

  9. #39
    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;
    }

  10. #40

    myport

    Hi Florian,

    Change the expression "unsigned char bitnum='3';" to "unsigned char bitnum=3;" and your program should work as expected.

    Martin

  11. #41
    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.

Page 3 of 3 FirstFirst 123

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
  •