hello all

i tried to run this code on fedora machine. but it 
gives me the error. when it calls write function with 
portname=/dev/parport0 

Write failed with: Invalid argument

and the following error when portname=/dev/lp0

Write failed with: Resource temporarily unavailable

what is the reason for that. i have ECP configuration 
for the port in my BIOS. 

is there any problem with some coniguration or
driver??

please help

thanks in advance



#include <time.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/signal.h>
#include <linux/lp.h>

extern int errno;

int main( int argc, char **argv )
{
        char *filename, input[5];
        int fd;

        errno = 0;

        if( argc < 2 ) {
                printf("Usage:  a.out /dev/portname\n");
                exit(1);
        }

        printf("Trying to open %s\n", argv[1] );

        fd = open( argv[1] , O_RDWR | O_NONBLOCK );
        if( fd < 0 ) {
                fprintf( stderr, "Open failed with: " );
                goto fail;
        }
        
        if ( write( fd, "hello\n", sizeof( "hello\n" ) ) < 0 
) {
                fprintf( stderr, "Write failed with: " );
                goto fail;
        }

        if ( read( fd, input, 5 ) < 0 ) {
                fprintf( stderr, "Write failed with: " );
                goto fail;
        }

        close( fd );
        exit(0);
fail:
        fprintf( stderr,  strerror( errno ) );
        fprintf( stderr,  "\n" );
        close( fd );
        exit(1);
}

=====
Arundeep Singh,
M.Tech (IS), IIIT Allahabad, 
U.P, India. 
ph: 09415262466, 09417066713
http://www.i-cognition.com

Don't take life seriously, as you can't come out of it alive.

__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com

_______________________________________________
ilugd mailinglist -- [EMAIL PROTECTED]
http://frodo.hserus.net/mailman/listinfo/ilugd
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/[EMAIL PROTECTED]/

Reply via email to