Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
#include <stdio.h> /*This include will allow you to do port i/o operations. For libc5 you will need to include the asm/io.h file for the port i/o functions and the unistd.h file for the i/o permissions*/#include <sys/io.h>/*this defines the paraport variable as the memory address of the parallel port, you can find out this address using the dmesg command, there will be a line somewhere in the output with the base and range of each ports memory addresses. */#DEFINE paraport 0x0378int main() {/*This opens the port for use by the application. If you don't do this, you're application won't have permissions to access the port, and you're likely to get a seg fault. The first arg is the port base, the second num is the number of bytes you want to be allowed to work with, and the last number is 1 or 0 for on or off. You don't need to worry about the ports address range, it will all be sorted out from the base you provide*/ioperm(paraport, 1, 1);/*Here we output a full byte to the port, which turns all the data pins to high*/outb(255, paraport);sleep(5); /* 5 second sleep*/outb(0, paraport); /*Turn the data pins to low*/exit(1); /*Quit this mofo*/}
I learned via trial by fire (I seem to do that a lot). Few references were useful to me, but reading through the files in /etc/ and reading general articles on how Linux works helps a bit.
For a Linux robotic project take a look at OAP. Also the book Linux Robotics is worth reading, although the code is in Java, which I think is good since is platform independant, so you can use the same program in Windows or any flavour of Linux. I am also considering Linux as a robot OS, but since I have almost no experience with it, I can't decide which distro should I use. I have a 1GB CF card for this, so a full distro might not be possible. I will eighter buy a 8GB or 16GB CF card or a laptop HDD to house a dual boot XP and whatever Linux I'll end up with. I have tryed Gentoo, but it will not install on my hardware, also Ubuntu and Xubuntu. The problem is the VIA EPIA motherboard I guess, probably drivers have to be downloaded but I don't know how. For the moment I am going to use a 40GB regular HDD to see what I can do with it and how much power it uses. I can give you the link for the Java code from the Linux Robotics book if you want to take a look at it.