Thread: Question on Ports

  1. #1
    Registered User immeraufdemhund's Avatar
    Join Date
    Dec 2002
    Posts
    12

    Question on Ports

    I've been working on a program now for a little bit. I want to be able to have the computer output something via the Parallel port. I have a little tester on my computer to tell me what is on and what is off. (windows seems to keep everything on, or so i think) I've been reading some tutorials that tell me how to do this, but I have been unable to get a program that either compiles, or works. It's like if i can get it to compile, i can't get it to output to the lpt port. I'd like to be able to make this for dos, but windows will work. Eventually i'll do it in linux, but I dont have a linux box up yet.
    Last edited by immeraufdemhund; 12-14-2002 at 03:29 PM.
    Was kostet Europe, ich kaufe es!

  2. #2
    Registered User immeraufdemhund's Avatar
    Join Date
    Dec 2002
    Posts
    12
    ok, thanx i was unaware of those two things. I currently am using Miracle C, but i'm not going to use that much longer because of it's lack of libraries. I'm using win 2000, but i'd like to make it DOS. I have that test hooked up, and this is the code i'm using.

    ack...ps how do i do the code stuff, so that you guys can see it without download.. preaty print....never mind....RTFM
    -=-=-=-=-=-=-=-=-test.c=-=-=-=-=-=-
    Code:
    #include <stdlib.h>
    #include <system.h>
    
    int main()
    {
      outp(0x00000278,7);
      outp(0x00000279,7);
      outp(0x0000027A,7);
      outp(0x0000027B,7);
      outp(0x0000027C,7);
      outp(0x0000027D,7);
      outp(0x0000027E,7);
      outp(0x0000027F,7);
      return(0);
    }
    Last edited by immeraufdemhund; 12-14-2002 at 08:03 PM.
    Was kostet Europe, ich kaufe es!

  3. #3
    Registered User immeraufdemhund's Avatar
    Join Date
    Dec 2002
    Posts
    12
    what os should i run to use that, or something similar. The end product is going to run on DOS.
    Was kostet Europe, ich kaufe es!

  4. #4
    Registered User immeraufdemhund's Avatar
    Join Date
    Dec 2002
    Posts
    12
    Cuase I dont ahve a Dos Compiler. I just have that Mircal C, i'm downloading right now the Borland C++ compiler. I have cygwin with gcc. That and the biggest thing is i'm not so sure as to how to do this. I kinda know what i'm doing, but then again, not really. C is kinda new to me. I've only done simple things in the past... ie convert F to C, do some weird math. Nothing "hard". I figured that since i kinda knew what i was doing, i could just jump in head first. Guess i'm finding out other wise...oh well just keep plugging away i guess i should
    Was kostet Europe, ich kaufe es!

  5. #5
    Registered User immeraufdemhund's Avatar
    Join Date
    Dec 2002
    Posts
    12
    well i got redhat 8 today and put it on this computer. It runs good. I put this code in it and it works.
    Code:
    #include <stdlib.h>
    #include <unistd.h>
    #include <asm/io.h>
    
    #define BASE 0x278  //this is what my computer uses for lpt1
    
    int main()
    {
      ioperm(BASE,3,1);
      outb(0,BASE);
      outb(0,BASE+1);
      outb(0,BASE+2);
      outb(0,BASE+3);
      ioperm(BASE,3,0);
      exit(0);
    }
    before i figured out you have to be administrator to run this i tried it and I got a segmentation fault. so i su'd over and now it works. I'm curious though as to how many BASE+n's i can do. I have 3 their, but i don tthink all of them work, i'd test individual but getch() doesn't work. thoughts?
    Was kostet Europe, ich kaufe es!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  2. Easy question about ports
    By Jaguar in forum Tech Board
    Replies: 4
    Last Post: 09-20-2003, 11:41 AM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM