gordon@news.colorado.edu (GORDON ALLEN R) (02/21/91)
panguyen@vela.acs.oakland.edu (panguyen) writes: >#include <stdio.h> >main() >{ > fopen( "COM1", "r+" ); > fprintf( "CHN %d \r", 3 ); >} >This will cough back at me with the following errors, > Write fault error writing device COM1 > Abort, Retry, Ignore ? You can refer to the following for help with serial communications: The C Toolbox by Hunt, 1986 Supercharging C with Assembly Language by Chesley and Waite, 1987 C Asynch Manager software by Blaise Publ There is another rather large volume on serial communications with C, but I don't remember the name. Briefly, fopen() works for files not devices, as far as I know, in MS-DOS based systems. -- Allen Gordon University of Colorado, Boulder gordon@tramp.colorado.edu gordon_A@cubldr.colorado.edu -- Allen Gordon University of Colorado, Boulder gordon@tramp.colorado.edu gordon_A@cubldr.colorado.edu
steve@taumet.com (Stephen Clamage) (02/21/91)
panguyen@vela.acs.oakland.edu (panguyen) writes: >#include <stdio.h> >main() >{ > fopen( "COM1", "r+" ); > fprintf( "CHN %d \r", 3 ); >} >This will cough back at me with the following errors, > Write fault error writing device COM1 > Abort, Retry, Ignore ? Apart from other help already posted, please note that fprintf() requires a first parameter of type FILE*, usually the result of an fopen() call. So your example at minimum should have looked more like this: FILE *com1 = fopen( "COM1", "r+" ); if( ! com1 ) ... error: can't open COM1 fprintf(com1, "CHN %d \r", 3 ); This is apart from any machine-specific problems there may be with COM1. -- Steve Clamage, TauMetric Corp, steve@taumet.com