public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* serial port programming
@ 2001-03-30 17:16 Tim Holmes
  2001-03-30 17:20 ` Christopher Faylor
  0 siblings, 1 reply; 26+ messages in thread
From: Tim Holmes @ 2001-03-30 17:16 UTC (permalink / raw)
  To: cygwin

Hello,

I'm trying to use cygwin to write an app that communicates via the serial
port.  I'm doing this under Windows NT.  

At one point I need to find out how many bytes are in the incoming
buffer.  The POSIX programming references I've found say to use FIONREAD,
but this is apparently not included in Cywin's termios.

I've found some references to this in the list archives, but wasn't clear
as to what it all meant.  Can I read the number of bytes in the
buffer?  

Thanks for any thoughts on this.

Tim Holmes



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: serial port programming
  2001-03-30 17:16 serial port programming Tim Holmes
@ 2001-03-30 17:20 ` Christopher Faylor
  0 siblings, 0 replies; 26+ messages in thread
From: Christopher Faylor @ 2001-03-30 17:20 UTC (permalink / raw)
  To: cygwin

On Fri, Mar 30, 2001 at 05:16:42PM -0800, Tim Holmes wrote:
>Hello,
>
>I'm trying to use cygwin to write an app that communicates via the serial
>port.  I'm doing this under Windows NT.  
>
>At one point I need to find out how many bytes are in the incoming
>buffer.  The POSIX programming references I've found say to use FIONREAD,
>but this is apparently not included in Cywin's termios.
>
>I've found some references to this in the list archives, but wasn't clear
>as to what it all meant.  Can I read the number of bytes in the
>buffer?  

I don't believe that it is implemented in Cygwin.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Serial port programming
@ 2000-05-29  7:43 El
  0 siblings, 0 replies; 26+ messages in thread
From: El @ 2000-05-29  7:43 UTC (permalink / raw)
  To: cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

Hi Chris !!

I need some Help .. Please..

I work in developed a new program for serial communications in C   for DOS,(FX, Interlink.. etc..) i search in the net for some c   programs or .h libraries, but nothing..

you can help me ?

THAX....

@ndreX
Cali
COL


_________________________________________________________
http://www.latinmail.com .  Gratuito, latino y en español.


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* serial port programming
@ 2000-05-15  9:23 j_s_saini
  0 siblings, 0 replies; 26+ messages in thread
From: j_s_saini @ 2000-05-15  9:23 UTC (permalink / raw)
  To: cygwin

 
 dear friend
         hi! & namaste from india.
         how are you.
 
 i am jagmohan, final yr engg, student ic electronics & comm. . my problem is s programming the serial port  of PC in C.
 you must have solution. please help me also. i need this to complete my final semester project.
 
 thank you,
 bye bye.
> 
> 
> ______________________________________________________
> 123India.com - India's Premier Portal 
> Get your Free Email Account at http://www.123india.com


______________________________________________________
123India.com - India's Premier Portal 
Get your Free Email Account at http://www.123india.com



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  2:32 ` Corinna Vinschen
  1999-08-23  2:50   ` Kim Poulsen
  1999-08-23  8:00   ` Chris Faylor
@ 1999-08-31 23:49   ` Corinna Vinschen
  2 siblings, 0 replies; 26+ messages in thread
From: Corinna Vinschen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Kim Poulsen; +Cc: Cygwin Mailing list

Kim Poulsen wrote:
>   I've got the following problem:
> I need to access the serial ports of my PC through an ANSI C program.
> How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> and fopen("com2", "r") but these only causes a core dump.
> [...]

AFAIK this is a known problem in b20.1. Try to use a newer snapshot.

Corinna


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-22 23:32 Serial " Kim Poulsen
                   ` (4 preceding siblings ...)
  1999-08-31 23:49 ` Kim Poulsen
@ 1999-08-31 23:49 ` Baron Shatturday
  5 siblings, 0 replies; 26+ messages in thread
From: Baron Shatturday @ 1999-08-31 23:49 UTC (permalink / raw)
  To: kpo; +Cc: cygwin

>  I've got the following problem: I need to access the serial ports of
>my PC through an ANSI C program.  How do I do that ?  I have already
>tried using fopen("/dev/com2", "r")

Have you tried using ("/dev/ttyS1", "r")?

Just a thought...


________________________________________________________
NetZero - We believe in a FREE Internet.  Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23 22:35         ` Geoff Appleby
@ 1999-08-31 23:49           ` Geoff Appleby
  0 siblings, 0 replies; 26+ messages in thread
From: Geoff Appleby @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Kim Poulsen; +Cc: cygwin

Why not combine the two?
Use open() to startup, and set the control, then fdopen()
once the configuration is established and you are happy to
just read and write?

Just a thought :)

--Geoff

Kim Poulsen wrote:
> 
> Chris,
> 
> The problem with fopen() is that it returns a FILE* where open() return
> an int.  fopen() is way to advanced for use with serial port I/O as
> the concept of a FILE is meaningless on a serial channel i.e. there is
> no name or path etc. associated with a raw serial stream.  In
> addition read() and write() uses an int file descriptor and not a FILE*.
>   The open(), read(), and write() functions are the most low level
> I/O handling ANSI C can handle.  The f*() functions are all built on
> these functions.  If I use fopen() I have no way of controlling the
> channel characteristics such as baud rate, bits, parity etc. This
> I can do with the int returned from the open() function.
>   If however you should have some running code (the code below _will_
> run) using fopen() I'd sure like to see it for the educational value.
> 
> Thanks for your response.
>   /Kim
> 
> PS:  Why are you posting everything twice ?
> 
> Chris Faylor wrote:
> >
> > On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
> > >Corinna Vinschen wrote:
> > >> Kim Poulsen wrote:
> > >> >   I've got the following problem:
> > >> > I need to access the serial ports of my PC through an ANSI C program.
> > >> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> > >> > and fopen("com2", "r") but these only causes a core dump.
> > >> > [...]
> > >> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
> > >
> > >I have the problem solved.  A a contribution to the mailing list I
> > >submit the solution to the problem below.
> >
> > I'm not sure how this solves your problem.  You aren't using fopen.  That
> > appears to be it.
> >
> > As is so often the case, with these kinds of problems, simply running the
> > program using gdb would have probably provided worlds of information for
> > debugging the problem.
> >
> > If the code sample below is getting you running, then fine.  It is not
> > a generic solution for people who want to use stdio for serial I/O,
> > however.  AFAIK, that does work.
> >
> > -chris
> >
> > >#include <fcntl.h>
> > >#include <termios.h>
> > >#include <stdio.h>
> > >#include <unistd.h>
> > >
> > >#define BAUDRATE B9600
> > >#define MODEMDEVICE "com2"
> > >
> > >main()
> > >{
> > >  int fd,c, n;
> > >  char str[2];
> > >  struct termios options;
> > >
> > >  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
> > >  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
> > >
> > >  options.c_cflag = BAUDRATE;
> > >  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
> > >  options.c_cflag |= CS8;    /* Select 8 data bits */
> > >
> > >  /* Write something */
> > >  n = write(fd, "UART is functional\n\r", 19);
> > >  if (n < 0)
> > >    puts("write() of 19 bytes failed!");
> > >
> > >  /* Make read() return immediately */
> > >  fcntl(fd, F_SETFL, FNDELAY);
> > >
> > >  /* Read something until 'Q' recieved */
> > >  while(str[0] != 'Q') {
> > >    if(read(fd, str, 1) != -1) {
> > >      printf("%s\n", str);
> > >    }
> > >  }
> > >}
> >
> > --
> > Want to unsubscribe from this list?
> > Send a message to cygwin-unsubscribe@sourceware.cygnus.com
> 
> --
>  Kim Poulsen, B.Sc.E.E, System Developer HW
>  Ericsson Telebit A/S     Tel: + 45 86 28 81 76
>  Fabriksvej 11            Fax: + 45 86 28 81 86
>  DK-8260 Viby J           E-mail: info@tbit.dk
>  Denmark                  URL: http://www.tbit.dk/
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com

-- 
                                   (__)
                                   (oo)
                            /-------\/
Geoff Appleby              / |     ||              geoff@topic.com.au
Internet Engineer         *  ||----||             Ph: +61 2 6257 7111
tSA Consulting Group         ^^    ^^            Fax: +61 2 6257 7311

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Serial port programming
  1999-08-22 23:32 Serial " Kim Poulsen
                   ` (3 preceding siblings ...)
       [not found] ` <199908230653.XAA03904@cygnus.com>
@ 1999-08-31 23:49 ` Kim Poulsen
  1999-08-31 23:49 ` Baron Shatturday
  5 siblings, 0 replies; 26+ messages in thread
From: Kim Poulsen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Cygwin Mailing list

Hi there

  I've got the following problem:
I need to access the serial ports of my PC through an ANSI C program.
How do I do that ?  I have already tried using fopen("/dev/com2", "r")
and fopen("com2", "r") but these only causes a core dump.
  So how to avoid core dumping and make me able to set the serial port
stats (parity, stop bits, bits per byte, serial speed) ?
dos.h is not available as far as I can see and therefore inportb() and
outportb() as well...

The FAQ or the mailing list archive has no response on 'serial' or
'port' which is why I ask here now.

Thank you in advance for any answers that might help me clear this up.
  Kim
-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  0:04   ` Kim Poulsen
@ 1999-08-31 23:49     ` Kim Poulsen
  0 siblings, 0 replies; 26+ messages in thread
From: Kim Poulsen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: egcs; +Cc: cygwin

It would seem that I can open the files called /dev/com2, /dev/ttyS1,
and com2 but I cannot read or write (with fopen(..., "rw");) from the
file. Why might that be so?  The program core dumps with an
STATUS_ACCESS_VIOLATION error on the fgetc() or fputc() command.

Baron Shatturday wrote:
> >  I've got the following problem: I need to access the serial ports of
> >my PC through an ANSI C program.  How do I do that ?  I have already
> >tried using fopen("/dev/com2", "r")
> Have you tried using ("/dev/ttyS1", "r")?
> Just a thought...

-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  2:50   ` Kim Poulsen
  1999-08-23  8:03     ` Chris Faylor
@ 1999-08-31 23:49     ` Kim Poulsen
  1 sibling, 0 replies; 26+ messages in thread
From: Kim Poulsen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: egcs; +Cc: Cygwin Mailing list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1821 bytes --]

Corinna Vinschen wrote:
> Kim Poulsen wrote:
> >   I've got the following problem:
> > I need to access the serial ports of my PC through an ANSI C program.
> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> > and fopen("com2", "r") but these only causes a core dump.
> > [...]
> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.

I have the problem solved.  A a contribution to the mailing list I
submit the solution to the problem below.

#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>

#define BAUDRATE B9600
#define MODEMDEVICE "com2"

main()
{
  int fd,c, n;
  char str[2];
  struct termios options;

  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
  if (fd <0) {perror(MODEMDEVICE); exit(-1); }

  options.c_cflag = BAUDRATE;
  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
  options.c_cflag |= CS8;    /* Select 8 data bits */

  /* Write something */
  n = write(fd, "UART is functional\n\r", 19);
  if (n < 0)
    puts("write() of 19 bytes failed!"); 

  /* Make read() return immediately */
  fcntl(fd, F_SETFL, FNDELAY);

  /* Read something until 'Q' recieved */
  while(str[0] != 'Q') {
    if(read(fd, str, 1) != -1) {
      printf("%s\n", str);
    }
  }
}

This code should run as expected.
A good link on the web is this one :
   http://revolution.rebel.net/~mad/serialtutor/

The tip was provided to me by Øistein Aanensen from Norway.  Credits
to him.

Regards
  Kim
-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  8:03     ` Chris Faylor
  1999-08-23 22:31       ` Kim Poulsen
@ 1999-08-31 23:49       ` Chris Faylor
  1 sibling, 0 replies; 26+ messages in thread
From: Chris Faylor @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Kim Poulsen; +Cc: Cygwin Mailing list

On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
>Corinna Vinschen wrote:
>> Kim Poulsen wrote:
>> >   I've got the following problem:
>> > I need to access the serial ports of my PC through an ANSI C program.
>> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
>> > and fopen("com2", "r") but these only causes a core dump.
>> > [...]
>> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
>
>I have the problem solved.  A a contribution to the mailing list I
>submit the solution to the problem below.

I'm not sure how this solves your problem.  You aren't using fopen.  That
appears to be it.

As is so often the case, with these kinds of problems, simply running the
program using gdb would have probably provided worlds of information for
debugging the problem.

If the code sample below is getting you running, then fine.  It is not
a generic solution for people who want to use stdio for serial I/O,
however.  AFAIK, that does work.

-chris

>#include <fcntl.h>
>#include <termios.h>
>#include <stdio.h>
>#include <unistd.h>
>
>#define BAUDRATE B9600
>#define MODEMDEVICE "com2"
>
>main()
>{
>  int fd,c, n;
>  char str[2];
>  struct termios options;
>
>  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
>  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
>
>  options.c_cflag = BAUDRATE;
>  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
>  options.c_cflag |= CS8;    /* Select 8 data bits */
>
>  /* Write something */
>  n = write(fd, "UART is functional\n\r", 19);
>  if (n < 0)
>    puts("write() of 19 bytes failed!"); 
>
>  /* Make read() return immediately */
>  fcntl(fd, F_SETFL, FNDELAY);
>
>  /* Read something until 'Q' recieved */
>  while(str[0] != 'Q') {
>    if(read(fd, str, 1) != -1) {
>      printf("%s\n", str);
>    }
>  }
>}

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23 22:31       ` Kim Poulsen
  1999-08-23 22:35         ` Geoff Appleby
  1999-08-24  9:17         ` Chris Faylor
@ 1999-08-31 23:49         ` Kim Poulsen
  2 siblings, 0 replies; 26+ messages in thread
From: Kim Poulsen @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

Chris,

The problem with fopen() is that it returns a FILE* where open() return
an int.  fopen() is way to advanced for use with serial port I/O as
the concept of a FILE is meaningless on a serial channel i.e. there is
no name or path etc. associated with a raw serial stream.  In
addition read() and write() uses an int file descriptor and not a FILE*.
  The open(), read(), and write() functions are the most low level
I/O handling ANSI C can handle.  The f*() functions are all built on
these functions.  If I use fopen() I have no way of controlling the
channel characteristics such as baud rate, bits, parity etc. This
I can do with the int returned from the open() function.
  If however you should have some running code (the code below _will_
run) using fopen() I'd sure like to see it for the educational value.

Thanks for your response.
  /Kim

PS:  Why are you posting everything twice ?

Chris Faylor wrote:
> 
> On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
> >Corinna Vinschen wrote:
> >> Kim Poulsen wrote:
> >> >   I've got the following problem:
> >> > I need to access the serial ports of my PC through an ANSI C program.
> >> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> >> > and fopen("com2", "r") but these only causes a core dump.
> >> > [...]
> >> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
> >
> >I have the problem solved.  A a contribution to the mailing list I
> >submit the solution to the problem below.
> 
> I'm not sure how this solves your problem.  You aren't using fopen.  That
> appears to be it.
> 
> As is so often the case, with these kinds of problems, simply running the
> program using gdb would have probably provided worlds of information for
> debugging the problem.
> 
> If the code sample below is getting you running, then fine.  It is not
> a generic solution for people who want to use stdio for serial I/O,
> however.  AFAIK, that does work.
> 
> -chris
> 
> >#include <fcntl.h>
> >#include <termios.h>
> >#include <stdio.h>
> >#include <unistd.h>
> >
> >#define BAUDRATE B9600
> >#define MODEMDEVICE "com2"
> >
> >main()
> >{
> >  int fd,c, n;
> >  char str[2];
> >  struct termios options;
> >
> >  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
> >  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
> >
> >  options.c_cflag = BAUDRATE;
> >  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
> >  options.c_cflag |= CS8;    /* Select 8 data bits */
> >
> >  /* Write something */
> >  n = write(fd, "UART is functional\n\r", 19);
> >  if (n < 0)
> >    puts("write() of 19 bytes failed!");
> >
> >  /* Make read() return immediately */
> >  fcntl(fd, F_SETFL, FNDELAY);
> >
> >  /* Read something until 'Q' recieved */
> >  while(str[0] != 'Q') {
> >    if(read(fd, str, 1) != -1) {
> >      printf("%s\n", str);
> >    }
> >  }
> >}
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com

-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  7:59   ` Chris Faylor
@ 1999-08-31 23:49     ` Chris Faylor
  0 siblings, 0 replies; 26+ messages in thread
From: Chris Faylor @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Baron Shatturday; +Cc: kpo, cygwin

On Sun, Aug 22, 1999 at 11:53:20PM -0700, Baron Shatturday wrote:
>
>>  I've got the following problem: I need to access the serial ports of
>>my PC through an ANSI C program.  How do I do that ?  I have already
>>tried using fopen("/dev/com2", "r")
>
>Have you tried using ("/dev/ttyS1", "r")?
>
>Just a thought...

Nope.  You're thinking about linux, it seems.

Cygwin uses /dev/com1, /dev/com2, etc.

-chris

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  8:00   ` Chris Faylor
@ 1999-08-31 23:49     ` Chris Faylor
  0 siblings, 0 replies; 26+ messages in thread
From: Chris Faylor @ 1999-08-31 23:49 UTC (permalink / raw)
  To: Corinna Vinschen; +Cc: Kim Poulsen, Cygwin Mailing list

On Mon, Aug 23, 1999 at 11:27:23AM +0200, Corinna Vinschen wrote:
>Kim Poulsen wrote:
>>   I've got the following problem:
>> I need to access the serial ports of my PC through an ANSI C program.
>> How do I do that ?  I have already tried using fopen("/dev/com2", "r")
>> and fopen("com2", "r") but these only causes a core dump.
>> [...]
>
>AFAIK this is a known problem in b20.1. Try to use a newer snapshot.

AFAICT, opening serial ports was not a problem with B20.1.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-24  9:17         ` Chris Faylor
@ 1999-08-31 23:49           ` Chris Faylor
  0 siblings, 0 replies; 26+ messages in thread
From: Chris Faylor @ 1999-08-31 23:49 UTC (permalink / raw)
  To: cygwin

On Tue, Aug 24, 1999 at 07:29:23AM +0200, Kim Poulsen wrote:
>The problem with fopen() is that it returns a FILE* where open() return
>an int.  fopen() is way to advanced for use with serial port I/O as
>the concept of a FILE is meaningless on a serial channel i.e. there is
>no name or path etc. associated with a raw serial stream.  In
>addition read() and write() uses an int file descriptor and not a FILE*.
>  The open(), read(), and write() functions are the most low level
>I/O handling ANSI C can handle.  The f*() functions are all built on
>these functions.  If I use fopen() I have no way of controlling the
>channel characteristics such as baud rate, bits, parity etc. This
>I can do with the int returned from the open() function.
>  If however you should have some running code (the code below _will_
>run) using fopen() I'd sure like to see it for the educational value.

fileno(), q.v.

>Thanks for your response.
>
>PS:  Why are you posting everything twice ?

You are on the mailing list and in the Cc line.  It's common to receive
two copies in this case.

cgf

>Chris Faylor wrote:
>> 
>> On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
>> >Corinna Vinschen wrote:
>> >> Kim Poulsen wrote:
>> >> >   I've got the following problem:
>> >> > I need to access the serial ports of my PC through an ANSI C program.
>> >> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
>> >> > and fopen("com2", "r") but these only causes a core dump.
>> >> > [...]
>> >> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
>> >
>> >I have the problem solved.  A a contribution to the mailing list I
>> >submit the solution to the problem below.
>> 
>> I'm not sure how this solves your problem.  You aren't using fopen.  That
>> appears to be it.
>> 
>> As is so often the case, with these kinds of problems, simply running the
>> program using gdb would have probably provided worlds of information for
>> debugging the problem.
>> 
>> If the code sample below is getting you running, then fine.  It is not
>> a generic solution for people who want to use stdio for serial I/O,
>> however.  AFAIK, that does work.
>> 
>> -chris
>> 
>> >#include <fcntl.h>
>> >#include <termios.h>
>> >#include <stdio.h>
>> >#include <unistd.h>
>> >
>> >#define BAUDRATE B9600
>> >#define MODEMDEVICE "com2"
>> >
>> >main()
>> >{
>> >  int fd,c, n;
>> >  char str[2];
>> >  struct termios options;
>> >
>> >  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
>> >  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
>> >
>> >  options.c_cflag = BAUDRATE;
>> >  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
>> >  options.c_cflag |= CS8;    /* Select 8 data bits */
>> >
>> >  /* Write something */
>> >  n = write(fd, "UART is functional\n\r", 19);
>> >  if (n < 0)
>> >    puts("write() of 19 bytes failed!");
>> >
>> >  /* Make read() return immediately */
>> >  fcntl(fd, F_SETFL, FNDELAY);
>> >
>> >  /* Read something until 'Q' recieved */
>> >  while(str[0] != 'Q') {
>> >    if(read(fd, str, 1) != -1) {
>> >      printf("%s\n", str);
>> >    }
>> >  }
>> >}

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23 22:31       ` Kim Poulsen
  1999-08-23 22:35         ` Geoff Appleby
@ 1999-08-24  9:17         ` Chris Faylor
  1999-08-31 23:49           ` Chris Faylor
  1999-08-31 23:49         ` Kim Poulsen
  2 siblings, 1 reply; 26+ messages in thread
From: Chris Faylor @ 1999-08-24  9:17 UTC (permalink / raw)
  To: cygwin

On Tue, Aug 24, 1999 at 07:29:23AM +0200, Kim Poulsen wrote:
>The problem with fopen() is that it returns a FILE* where open() return
>an int.  fopen() is way to advanced for use with serial port I/O as
>the concept of a FILE is meaningless on a serial channel i.e. there is
>no name or path etc. associated with a raw serial stream.  In
>addition read() and write() uses an int file descriptor and not a FILE*.
>  The open(), read(), and write() functions are the most low level
>I/O handling ANSI C can handle.  The f*() functions are all built on
>these functions.  If I use fopen() I have no way of controlling the
>channel characteristics such as baud rate, bits, parity etc. This
>I can do with the int returned from the open() function.
>  If however you should have some running code (the code below _will_
>run) using fopen() I'd sure like to see it for the educational value.

fileno(), q.v.

>Thanks for your response.
>
>PS:  Why are you posting everything twice ?

You are on the mailing list and in the Cc line.  It's common to receive
two copies in this case.

cgf

>Chris Faylor wrote:
>> 
>> On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
>> >Corinna Vinschen wrote:
>> >> Kim Poulsen wrote:
>> >> >   I've got the following problem:
>> >> > I need to access the serial ports of my PC through an ANSI C program.
>> >> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
>> >> > and fopen("com2", "r") but these only causes a core dump.
>> >> > [...]
>> >> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
>> >
>> >I have the problem solved.  A a contribution to the mailing list I
>> >submit the solution to the problem below.
>> 
>> I'm not sure how this solves your problem.  You aren't using fopen.  That
>> appears to be it.
>> 
>> As is so often the case, with these kinds of problems, simply running the
>> program using gdb would have probably provided worlds of information for
>> debugging the problem.
>> 
>> If the code sample below is getting you running, then fine.  It is not
>> a generic solution for people who want to use stdio for serial I/O,
>> however.  AFAIK, that does work.
>> 
>> -chris
>> 
>> >#include <fcntl.h>
>> >#include <termios.h>
>> >#include <stdio.h>
>> >#include <unistd.h>
>> >
>> >#define BAUDRATE B9600
>> >#define MODEMDEVICE "com2"
>> >
>> >main()
>> >{
>> >  int fd,c, n;
>> >  char str[2];
>> >  struct termios options;
>> >
>> >  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
>> >  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
>> >
>> >  options.c_cflag = BAUDRATE;
>> >  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
>> >  options.c_cflag |= CS8;    /* Select 8 data bits */
>> >
>> >  /* Write something */
>> >  n = write(fd, "UART is functional\n\r", 19);
>> >  if (n < 0)
>> >    puts("write() of 19 bytes failed!");
>> >
>> >  /* Make read() return immediately */
>> >  fcntl(fd, F_SETFL, FNDELAY);
>> >
>> >  /* Read something until 'Q' recieved */
>> >  while(str[0] != 'Q') {
>> >    if(read(fd, str, 1) != -1) {
>> >      printf("%s\n", str);
>> >    }
>> >  }
>> >}

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23 22:31       ` Kim Poulsen
@ 1999-08-23 22:35         ` Geoff Appleby
  1999-08-31 23:49           ` Geoff Appleby
  1999-08-24  9:17         ` Chris Faylor
  1999-08-31 23:49         ` Kim Poulsen
  2 siblings, 1 reply; 26+ messages in thread
From: Geoff Appleby @ 1999-08-23 22:35 UTC (permalink / raw)
  To: Kim Poulsen; +Cc: cygwin

Why not combine the two?
Use open() to startup, and set the control, then fdopen()
once the configuration is established and you are happy to
just read and write?

Just a thought :)

--Geoff

Kim Poulsen wrote:
> 
> Chris,
> 
> The problem with fopen() is that it returns a FILE* where open() return
> an int.  fopen() is way to advanced for use with serial port I/O as
> the concept of a FILE is meaningless on a serial channel i.e. there is
> no name or path etc. associated with a raw serial stream.  In
> addition read() and write() uses an int file descriptor and not a FILE*.
>   The open(), read(), and write() functions are the most low level
> I/O handling ANSI C can handle.  The f*() functions are all built on
> these functions.  If I use fopen() I have no way of controlling the
> channel characteristics such as baud rate, bits, parity etc. This
> I can do with the int returned from the open() function.
>   If however you should have some running code (the code below _will_
> run) using fopen() I'd sure like to see it for the educational value.
> 
> Thanks for your response.
>   /Kim
> 
> PS:  Why are you posting everything twice ?
> 
> Chris Faylor wrote:
> >
> > On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
> > >Corinna Vinschen wrote:
> > >> Kim Poulsen wrote:
> > >> >   I've got the following problem:
> > >> > I need to access the serial ports of my PC through an ANSI C program.
> > >> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> > >> > and fopen("com2", "r") but these only causes a core dump.
> > >> > [...]
> > >> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
> > >
> > >I have the problem solved.  A a contribution to the mailing list I
> > >submit the solution to the problem below.
> >
> > I'm not sure how this solves your problem.  You aren't using fopen.  That
> > appears to be it.
> >
> > As is so often the case, with these kinds of problems, simply running the
> > program using gdb would have probably provided worlds of information for
> > debugging the problem.
> >
> > If the code sample below is getting you running, then fine.  It is not
> > a generic solution for people who want to use stdio for serial I/O,
> > however.  AFAIK, that does work.
> >
> > -chris
> >
> > >#include <fcntl.h>
> > >#include <termios.h>
> > >#include <stdio.h>
> > >#include <unistd.h>
> > >
> > >#define BAUDRATE B9600
> > >#define MODEMDEVICE "com2"
> > >
> > >main()
> > >{
> > >  int fd,c, n;
> > >  char str[2];
> > >  struct termios options;
> > >
> > >  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
> > >  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
> > >
> > >  options.c_cflag = BAUDRATE;
> > >  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
> > >  options.c_cflag |= CS8;    /* Select 8 data bits */
> > >
> > >  /* Write something */
> > >  n = write(fd, "UART is functional\n\r", 19);
> > >  if (n < 0)
> > >    puts("write() of 19 bytes failed!");
> > >
> > >  /* Make read() return immediately */
> > >  fcntl(fd, F_SETFL, FNDELAY);
> > >
> > >  /* Read something until 'Q' recieved */
> > >  while(str[0] != 'Q') {
> > >    if(read(fd, str, 1) != -1) {
> > >      printf("%s\n", str);
> > >    }
> > >  }
> > >}
> >
> > --
> > Want to unsubscribe from this list?
> > Send a message to cygwin-unsubscribe@sourceware.cygnus.com
> 
> --
>  Kim Poulsen, B.Sc.E.E, System Developer HW
>  Ericsson Telebit A/S     Tel: + 45 86 28 81 76
>  Fabriksvej 11            Fax: + 45 86 28 81 86
>  DK-8260 Viby J           E-mail: info@tbit.dk
>  Denmark                  URL: http://www.tbit.dk/
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com

-- 
                                   (__)
                                   (oo)
                            /-------\/
Geoff Appleby              / |     ||              geoff@topic.com.au
Internet Engineer         *  ||----||             Ph: +61 2 6257 7111
tSA Consulting Group         ^^    ^^            Fax: +61 2 6257 7311

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  8:03     ` Chris Faylor
@ 1999-08-23 22:31       ` Kim Poulsen
  1999-08-23 22:35         ` Geoff Appleby
                           ` (2 more replies)
  1999-08-31 23:49       ` Chris Faylor
  1 sibling, 3 replies; 26+ messages in thread
From: Kim Poulsen @ 1999-08-23 22:31 UTC (permalink / raw)
  To: cygwin

Chris,

The problem with fopen() is that it returns a FILE* where open() return
an int.  fopen() is way to advanced for use with serial port I/O as
the concept of a FILE is meaningless on a serial channel i.e. there is
no name or path etc. associated with a raw serial stream.  In
addition read() and write() uses an int file descriptor and not a FILE*.
  The open(), read(), and write() functions are the most low level
I/O handling ANSI C can handle.  The f*() functions are all built on
these functions.  If I use fopen() I have no way of controlling the
channel characteristics such as baud rate, bits, parity etc. This
I can do with the int returned from the open() function.
  If however you should have some running code (the code below _will_
run) using fopen() I'd sure like to see it for the educational value.

Thanks for your response.
  /Kim

PS:  Why are you posting everything twice ?

Chris Faylor wrote:
> 
> On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
> >Corinna Vinschen wrote:
> >> Kim Poulsen wrote:
> >> >   I've got the following problem:
> >> > I need to access the serial ports of my PC through an ANSI C program.
> >> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> >> > and fopen("com2", "r") but these only causes a core dump.
> >> > [...]
> >> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
> >
> >I have the problem solved.  A a contribution to the mailing list I
> >submit the solution to the problem below.
> 
> I'm not sure how this solves your problem.  You aren't using fopen.  That
> appears to be it.
> 
> As is so often the case, with these kinds of problems, simply running the
> program using gdb would have probably provided worlds of information for
> debugging the problem.
> 
> If the code sample below is getting you running, then fine.  It is not
> a generic solution for people who want to use stdio for serial I/O,
> however.  AFAIK, that does work.
> 
> -chris
> 
> >#include <fcntl.h>
> >#include <termios.h>
> >#include <stdio.h>
> >#include <unistd.h>
> >
> >#define BAUDRATE B9600
> >#define MODEMDEVICE "com2"
> >
> >main()
> >{
> >  int fd,c, n;
> >  char str[2];
> >  struct termios options;
> >
> >  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
> >  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
> >
> >  options.c_cflag = BAUDRATE;
> >  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
> >  options.c_cflag |= CS8;    /* Select 8 data bits */
> >
> >  /* Write something */
> >  n = write(fd, "UART is functional\n\r", 19);
> >  if (n < 0)
> >    puts("write() of 19 bytes failed!");
> >
> >  /* Make read() return immediately */
> >  fcntl(fd, F_SETFL, FNDELAY);
> >
> >  /* Read something until 'Q' recieved */
> >  while(str[0] != 'Q') {
> >    if(read(fd, str, 1) != -1) {
> >      printf("%s\n", str);
> >    }
> >  }
> >}
> 
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe@sourceware.cygnus.com

-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  2:50   ` Kim Poulsen
@ 1999-08-23  8:03     ` Chris Faylor
  1999-08-23 22:31       ` Kim Poulsen
  1999-08-31 23:49       ` Chris Faylor
  1999-08-31 23:49     ` Kim Poulsen
  1 sibling, 2 replies; 26+ messages in thread
From: Chris Faylor @ 1999-08-23  8:03 UTC (permalink / raw)
  To: Kim Poulsen; +Cc: Cygwin Mailing list

On Mon, Aug 23, 1999 at 11:49:37AM +0200, Kim Poulsen wrote:
>Corinna Vinschen wrote:
>> Kim Poulsen wrote:
>> >   I've got the following problem:
>> > I need to access the serial ports of my PC through an ANSI C program.
>> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
>> > and fopen("com2", "r") but these only causes a core dump.
>> > [...]
>> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.
>
>I have the problem solved.  A a contribution to the mailing list I
>submit the solution to the problem below.

I'm not sure how this solves your problem.  You aren't using fopen.  That
appears to be it.

As is so often the case, with these kinds of problems, simply running the
program using gdb would have probably provided worlds of information for
debugging the problem.

If the code sample below is getting you running, then fine.  It is not
a generic solution for people who want to use stdio for serial I/O,
however.  AFAIK, that does work.

-chris

>#include <fcntl.h>
>#include <termios.h>
>#include <stdio.h>
>#include <unistd.h>
>
>#define BAUDRATE B9600
>#define MODEMDEVICE "com2"
>
>main()
>{
>  int fd,c, n;
>  char str[2];
>  struct termios options;
>
>  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
>  if (fd <0) {perror(MODEMDEVICE); exit(-1); }
>
>  options.c_cflag = BAUDRATE;
>  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
>  options.c_cflag |= CS8;    /* Select 8 data bits */
>
>  /* Write something */
>  n = write(fd, "UART is functional\n\r", 19);
>  if (n < 0)
>    puts("write() of 19 bytes failed!"); 
>
>  /* Make read() return immediately */
>  fcntl(fd, F_SETFL, FNDELAY);
>
>  /* Read something until 'Q' recieved */
>  while(str[0] != 'Q') {
>    if(read(fd, str, 1) != -1) {
>      printf("%s\n", str);
>    }
>  }
>}

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  2:32 ` Corinna Vinschen
  1999-08-23  2:50   ` Kim Poulsen
@ 1999-08-23  8:00   ` Chris Faylor
  1999-08-31 23:49     ` Chris Faylor
  1999-08-31 23:49   ` Corinna Vinschen
  2 siblings, 1 reply; 26+ messages in thread
From: Chris Faylor @ 1999-08-23  8:00 UTC (permalink / raw)
  To: Corinna Vinschen; +Cc: Kim Poulsen, Cygwin Mailing list

On Mon, Aug 23, 1999 at 11:27:23AM +0200, Corinna Vinschen wrote:
>Kim Poulsen wrote:
>>   I've got the following problem:
>> I need to access the serial ports of my PC through an ANSI C program.
>> How do I do that ?  I have already tried using fopen("/dev/com2", "r")
>> and fopen("com2", "r") but these only causes a core dump.
>> [...]
>
>AFAIK this is a known problem in b20.1. Try to use a newer snapshot.

AFAICT, opening serial ports was not a problem with B20.1.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
       [not found] ` <199908230653.XAA03904@cygnus.com>
@ 1999-08-23  7:59   ` Chris Faylor
  1999-08-31 23:49     ` Chris Faylor
  0 siblings, 1 reply; 26+ messages in thread
From: Chris Faylor @ 1999-08-23  7:59 UTC (permalink / raw)
  To: Baron Shatturday; +Cc: kpo, cygwin

On Sun, Aug 22, 1999 at 11:53:20PM -0700, Baron Shatturday wrote:
>
>>  I've got the following problem: I need to access the serial ports of
>>my PC through an ANSI C program.  How do I do that ?  I have already
>>tried using fopen("/dev/com2", "r")
>
>Have you tried using ("/dev/ttyS1", "r")?
>
>Just a thought...

Nope.  You're thinking about linux, it seems.

Cygwin uses /dev/com1, /dev/com2, etc.

-chris

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-23  2:32 ` Corinna Vinschen
@ 1999-08-23  2:50   ` Kim Poulsen
  1999-08-23  8:03     ` Chris Faylor
  1999-08-31 23:49     ` Kim Poulsen
  1999-08-23  8:00   ` Chris Faylor
  1999-08-31 23:49   ` Corinna Vinschen
  2 siblings, 2 replies; 26+ messages in thread
From: Kim Poulsen @ 1999-08-23  2:50 UTC (permalink / raw)
  To: egcs; +Cc: Cygwin Mailing list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1821 bytes --]

Corinna Vinschen wrote:
> Kim Poulsen wrote:
> >   I've got the following problem:
> > I need to access the serial ports of my PC through an ANSI C program.
> > How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> > and fopen("com2", "r") but these only causes a core dump.
> > [...]
> AFAIK this is a known problem in b20.1. Try to use a newer snapshot.

I have the problem solved.  A a contribution to the mailing list I
submit the solution to the problem below.

#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>

#define BAUDRATE B9600
#define MODEMDEVICE "com2"

main()
{
  int fd,c, n;
  char str[2];
  struct termios options;

  fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );
  if (fd <0) {perror(MODEMDEVICE); exit(-1); }

  options.c_cflag = BAUDRATE;
  options.c_cflag &= ~CSIZE; /* Mask the character size bits */
  options.c_cflag |= CS8;    /* Select 8 data bits */

  /* Write something */
  n = write(fd, "UART is functional\n\r", 19);
  if (n < 0)
    puts("write() of 19 bytes failed!"); 

  /* Make read() return immediately */
  fcntl(fd, F_SETFL, FNDELAY);

  /* Read something until 'Q' recieved */
  while(str[0] != 'Q') {
    if(read(fd, str, 1) != -1) {
      printf("%s\n", str);
    }
  }
}

This code should run as expected.
A good link on the web is this one :
   http://revolution.rebel.net/~mad/serialtutor/

The tip was provided to me by Øistein Aanensen from Norway.  Credits
to him.

Regards
  Kim
-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-22 23:32 Serial " Kim Poulsen
  1999-08-22 23:52 ` Baron Shatturday
       [not found] ` <199908230653.IAA17307@mailhostnew.tbit.dk>
@ 1999-08-23  2:32 ` Corinna Vinschen
  1999-08-23  2:50   ` Kim Poulsen
                     ` (2 more replies)
       [not found] ` <199908230653.XAA03904@cygnus.com>
                   ` (2 subsequent siblings)
  5 siblings, 3 replies; 26+ messages in thread
From: Corinna Vinschen @ 1999-08-23  2:32 UTC (permalink / raw)
  To: Kim Poulsen; +Cc: Cygwin Mailing list

Kim Poulsen wrote:
>   I've got the following problem:
> I need to access the serial ports of my PC through an ANSI C program.
> How do I do that ?  I have already tried using fopen("/dev/com2", "r")
> and fopen("com2", "r") but these only causes a core dump.
> [...]

AFAIK this is a known problem in b20.1. Try to use a newer snapshot.

Corinna


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
       [not found] ` <199908230653.IAA17307@mailhostnew.tbit.dk>
@ 1999-08-23  0:04   ` Kim Poulsen
  1999-08-31 23:49     ` Kim Poulsen
  0 siblings, 1 reply; 26+ messages in thread
From: Kim Poulsen @ 1999-08-23  0:04 UTC (permalink / raw)
  To: egcs; +Cc: cygwin

It would seem that I can open the files called /dev/com2, /dev/ttyS1,
and com2 but I cannot read or write (with fopen(..., "rw");) from the
file. Why might that be so?  The program core dumps with an
STATUS_ACCESS_VIOLATION error on the fgetc() or fputc() command.

Baron Shatturday wrote:
> >  I've got the following problem: I need to access the serial ports of
> >my PC through an ANSI C program.  How do I do that ?  I have already
> >tried using fopen("/dev/com2", "r")
> Have you tried using ("/dev/ttyS1", "r")?
> Just a thought...

-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: Serial port programming
  1999-08-22 23:32 Serial " Kim Poulsen
@ 1999-08-22 23:52 ` Baron Shatturday
       [not found] ` <199908230653.IAA17307@mailhostnew.tbit.dk>
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 26+ messages in thread
From: Baron Shatturday @ 1999-08-22 23:52 UTC (permalink / raw)
  To: kpo; +Cc: cygwin

>  I've got the following problem: I need to access the serial ports of
>my PC through an ANSI C program.  How do I do that ?  I have already
>tried using fopen("/dev/com2", "r")

Have you tried using ("/dev/ttyS1", "r")?

Just a thought...


________________________________________________________
NetZero - We believe in a FREE Internet.  Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Serial port programming
@ 1999-08-22 23:32 Kim Poulsen
  1999-08-22 23:52 ` Baron Shatturday
                   ` (5 more replies)
  0 siblings, 6 replies; 26+ messages in thread
From: Kim Poulsen @ 1999-08-22 23:32 UTC (permalink / raw)
  To: Cygwin Mailing list

Hi there

  I've got the following problem:
I need to access the serial ports of my PC through an ANSI C program.
How do I do that ?  I have already tried using fopen("/dev/com2", "r")
and fopen("com2", "r") but these only causes a core dump.
  So how to avoid core dumping and make me able to set the serial port
stats (parity, stop bits, bits per byte, serial speed) ?
dos.h is not available as far as I can see and therefore inportb() and
outportb() as well...

The FAQ or the mailing list archive has no response on 'serial' or
'port' which is why I ask here now.

Thank you in advance for any answers that might help me clear this up.
  Kim
-- 
 Kim Poulsen, B.Sc.E.E, System Developer HW
 Ericsson Telebit A/S     Tel: + 45 86 28 81 76
 Fabriksvej 11            Fax: + 45 86 28 81 86
 DK-8260 Viby J           E-mail: info@tbit.dk
 Denmark                  URL: http://www.tbit.dk/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2001-03-30 17:20 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-30 17:16 serial port programming Tim Holmes
2001-03-30 17:20 ` Christopher Faylor
  -- strict thread matches above, loose matches on Subject: below --
2000-05-29  7:43 Serial " El
2000-05-15  9:23 serial " j_s_saini
1999-08-22 23:32 Serial " Kim Poulsen
1999-08-22 23:52 ` Baron Shatturday
     [not found] ` <199908230653.IAA17307@mailhostnew.tbit.dk>
1999-08-23  0:04   ` Kim Poulsen
1999-08-31 23:49     ` Kim Poulsen
1999-08-23  2:32 ` Corinna Vinschen
1999-08-23  2:50   ` Kim Poulsen
1999-08-23  8:03     ` Chris Faylor
1999-08-23 22:31       ` Kim Poulsen
1999-08-23 22:35         ` Geoff Appleby
1999-08-31 23:49           ` Geoff Appleby
1999-08-24  9:17         ` Chris Faylor
1999-08-31 23:49           ` Chris Faylor
1999-08-31 23:49         ` Kim Poulsen
1999-08-31 23:49       ` Chris Faylor
1999-08-31 23:49     ` Kim Poulsen
1999-08-23  8:00   ` Chris Faylor
1999-08-31 23:49     ` Chris Faylor
1999-08-31 23:49   ` Corinna Vinschen
     [not found] ` <199908230653.XAA03904@cygnus.com>
1999-08-23  7:59   ` Chris Faylor
1999-08-31 23:49     ` Chris Faylor
1999-08-31 23:49 ` Kim Poulsen
1999-08-31 23:49 ` Baron Shatturday

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).