Author Topic: dos.h  (Read 2063 times)

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
dos.h
« on: 1 August 2002, 07:01 »
I need to find a unix equal of outp() (dos.h). I remember reading it in some source code that was designed for BSD, but I don't know what header it used. Until now I used dos.h, but it only works in DOS and windows 9x.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
dos.h
« Reply #1 on: 1 August 2002, 07:29 »
That appears to be an x86 specific instruction. What do you need the function for? Maybe I can help find a way to do what you need.

I see a few places in a couple of drivers in the Linux kernel where it is defined and used. Don't know if it performs the same thing as the DOS version.  For an example look at a couple of these kernel driver files which are a few places I spotted it:

/usr/src/linux/drivers/net/skfp/h/types.h
/usr/src/linux/drivers/net/skfp/h/skfbi.h

[ July 31, 2002: Message edited by: VoidMain ]

Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
dos.h
« Reply #2 on: 1 August 2002, 08:32 »
I need that function so I could control some electronics.

It's just for an after school experiment to see if  I could do something intresting with my computer and, well, home made elecronic devices   .

Here's a fast example: (if you run it in dos and hook up an oscilloscope to the second hole in your parallel port, you'll see a pattern that looks like this: _-_-_-)

Code: [Select]

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
dos.h
« Reply #3 on: 1 August 2002, 08:39 »
Take a look at this:

http://www.hut.fi/Misc/Electronics/circuits/parallel_output.html

There is a Linux example in it. ioperm() and outb() are your functions.

[ July 31, 2002: Message edited by: VoidMain ]

Someone please remove this account. Thanks...

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
dos.h
« Reply #4 on: 1 August 2002, 10:07 »
I just rewrote your code for x86 Linux:

Code: [Select]

I put the code in a file called "scope.c" and to compile it I use the command:

gcc -lm -O scope.c -o scope

Then you will either have to run it as "root" or set the owner of the program to "root" and set the SUID bit.

Also, in your calculation "u=255*(1+pow(-1,i))/2" you had an "l" (lower case "L") before the plus sign.  I assume that was a typo and should have been a "1" (one) so I changed it. I can think of much easier ways to alternate between 1 and 255 though, and it wouldn't require the math library.     Also, instead of the "delay(1000)" I used "sleep(1)".

I just tested it on my Linux laptop with a multimeter and it works just fine...

[ August 01, 2002: Message edited by: VoidMain ]

Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
dos.h
« Reply #5 on: 1 August 2002, 11:06 »
i used delay because it usually goes below one second.

and most importantly, thanks!  

[ August 01, 2002: Message edited by: TheQuirk ]


voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
dos.h
« Reply #6 on: 1 August 2002, 11:27 »
If you need a function like delay() you might then check out the nanosleep() function.
Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
dos.h
« Reply #7 on: 1 August 2002, 11:42 »
thanks, again. I'm just so used to programming in dos/windows... =\

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
dos.h
« Reply #8 on: 3 August 2002, 10:15 »
You sparked my interest with your parallel port interests.  I too have always wanted to get into building something that I could control from my computer but I have no electronics background. I decided to go pick up a breadboard, a handfull of LEDs, some wire and a DB25 connector.  I built a cable to plug into my parallel port and wire up all the data pins and a ground to the breadboard.  Stuck in 8 LEDs (Red, Green, and Yellow randomly).

Then I took the lptout.c example and an nsleep.c example (using usleep() to get the millisecond resolution) which gave the the necessary programs to include in a simple shell script to control the LEDs.  I made the shell script so you could input the LED sequences interactively or put all of your LED commands in a file and loop through them to make cool christmas light patterns.  My son made the light sequences.  Here's the three pieces of code:

lptout.c:
Code: [Select]

nsleep.c
Code: [Select]

lights:
Code: [Select]

Then:

# gcc -O -o lptout lptout.c
# chmod u+s lptout
$ gcc -o nsleep nsleep.c
$ chmod +x lights

Then to run the lights program interactively:
$ ./lights

If you want to have the script read the value/delay sequences from a file run it like:

$ ./lights lights.txt

Here is the "lights.txt" file my son came up with:

Code: [Select]

Makes a good Christmas light sequence.                        

Thanks for sparking my interest.  Now it's on to more interesting things like building a battle bot and writing a program to control it.. I am into R/C airplanes as well so I am trying to think of a way to use radio and computer control together.. Any ideas?

[ August 06, 2002: Message edited by: VoidMain ]

Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
dos.h
« Reply #9 on: 3 August 2002, 11:42 »
great little program  
how much weight can one of the airplanes carry? maybe you could fit a small enough single board computer to automate various tasks? it would be a rather costly project, though...

By the way, the battle bots website has a TON of information on how to build your own robot, program it, etc.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
dos.h
« Reply #10 on: 3 August 2002, 12:12 »
Well, I was more thinking about just using the transmitter, receiver, and servos to control things other than airplanes or cars. But if I were to use it for a plane I would keep the computer on the ground and program the transmitter or a second transmitter/receiver.  Or for a remote control truck or something (we have a nitro powered 4WD truck as well).  I do have a large airplane with an 80" wingspan and a 44cc gas engine on it (27% of the full size real plane (CAP 232)) but the last time I flew it nearly exploded in midair due to aileron flutter from overspeed at around 100mph+, have it apart repairing it now.

I'll have to check out the battle bot site, thanks for the tip!

P.S. I just added system bell sound to the LED program. It's changes frequency and duration corresponding to the light sequences. I know, I'm a geek...

[ August 03, 2002: Message edited by: VoidMain ]

Someone please remove this account. Thanks...

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
dos.h
« Reply #11 on: 3 August 2002, 16:05 »
Interesting, Im new to programming in C++ and C but i did this once in powerbasic to make a program to copy files to another with an LPT port.
I have an electronic knoledge, im studying the workings of the MicroPorcessor and so on. And so far i know how a CPU works at the electronic level so what the hell.

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
dos.h
« Reply #12 on: 3 August 2002, 21:20 »
You could  easily control the airplane then from your computer. But it's kind of dumb, because you'll just be replicating your remote control. You could always, like I said, automate different functions using your computer.

choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
dos.h
« Reply #13 on: 3 August 2002, 22:18 »
hmmmmm, howabout sticking a video camera on it. i have seen it done on techtv by some 14year useing visual basic. then agian, why doesn't somebody out do the little shit with a real langague like c, c++ or even java.
x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
dos.h
« Reply #14 on: 3 August 2002, 22:21 »
I was thinking about that, but I'm guessing the camera would probably be too heavy or mess something up? Maybe one of those small, cheap netcams will do the trick?