Page 1 of 3 123 LastLast
Results 1 to 15 of 41

Thread: LPT thermometer

  1. #1

    Question LPT thermometer

    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?

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

  3. #3
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    Just use generic parallel port ioctls, that's it. But remember to remove lp.o module first.

  4. #4
    Quote Originally Posted by Oleg
    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?

    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.

  5. #5
    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

  6. #6
    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
    mipsel-uclibc-gcc -o p.c
    This thing should blink some data pins on the lpt port, right? But it doesn't. It just gives me a nice Segmentation Fault.
    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?

  7. #7
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    Use iopl(3) to get an access.
    In fact you will probably need to mmap this memory first to get an access to it.

  8. #8
    please give me an example.

  9. #9
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    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.

  10. #10
    lost myself there

  11. #11
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    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;

  12. #12
    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.

  13. #13
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    no, just compile as usual. no writeb is needed.

  14. #14
    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

  15. #15
    Any idea? Anyone?

Page 1 of 3 123 LastLast

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
  •