/*************************************************************************** * Copyright (C) 2006 by Jordi Binefa * * binefa at etpclot dot fje dot edu * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include /* #include */ #include #define PORTADDRESS 0x378 /* Enter Your Port Address Here */ #define DATA PORTADDRESS+0 #define STATUS PORTADDRESS+1 #define CONTROL PORTADDRESS+2 #define BYTE unsigned char int main(int argc, char *argv[]) { BYTE mask = 0x01; // OpenPortTalk(); if(ioperm(DATA,3,1)) { perror("Donant permisos"); exit(1); } /* Dono permisos d'ús al port paraŀlel */ system("chmod 666 /dev/parport0"); while(mask){ printf("mask = 0x%X\n",mask); //outportb(DATA,mask); outb(mask,DATA); if(mask < 0x10) //outportb(CONTROL,mask); outb(mask,CONTROL); getchar(); mask <<= 1; } printf("\n_outp(DATA,0xFF)"); printf("\n_outp(CONTROL,0x04)\n"); //outportb(DATA,0xFF); outb(0xFF,DATA); //outportb(CONTROL,0x04); outb(0x04,CONTROL); getchar(); printf("\n_outp(DATA,0x00)"); printf("\n_outp(CONTROL,0x0B)\n"); //outportb(DATA,0x00); outb(0x00,DATA); //outportb(CONTROL,~0xF4); outb((unsigned char)~0xF4,CONTROL); // ClosePortTalk(); if(ioperm(DATA,3,0)) { perror("Treient permisos"); exit(1); } return EXIT_SUCCESS; }