Re: Support for Baud Rates above 250000 baud?

2007-01-10 Thread Corinna Vinschen
On Jan 10 10:18, David le Comte wrote:
> I'm wondering if the most general way of modifying fhandler_serial.cc 
> (and cf[io]speed()?) is to do what SetCommState() is doing, ie,
> if the value that is passed is NOT equivalent to one of the Bn
> "define"s, then assume it is a literal speed and pass that.

Cygwin does this already for 230400 baud.  See fhandler_serial.cc.

> This would mean changing "speed_t" to be an unsigned int (can we
> now assume that is 32bit?) rather than char?, and removing and/or
> changing any parsing that cfset[io]speed() are doing.

No.  This would needlessly break backward compatibility.  The way to
go is to define new Bxxx values in termios.h and support them in
fhandler_serial.cc, which is what Brian already said.
What's left at this point is just http://cygwin.com/acronyms/#SHTDI.
See http://cygwin.com/contrib.html.


Corinna


-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Support for Baud Rates above 250000 baud?

2007-01-09 Thread Morgan Gangwere

what I would do is have say Minicom try and talk at those rates first.
another option is to have a file like "newbaud.h" that looks like
this:


//
// newbaud.h  -high speed baud rate functions
//

#IFNDEF NEWBAUD_H
#DEFINE NEWBAUD_H

int setbaud(int baudrate, int port) {
// this sets the buad rate to baudrate
//...
if(sucess) { return 1}
else {return failure}
//...
}

#ENDIF

where failiure would be used for the FAILIURE MODE. IAGT, it should
never happen, as you should always be able to set the baud rate

On 1/9/07, Brian Dessent <[EMAIL PROTECTED]> wrote:

David le Comte wrote:

> I am running Cygwin on a PC that is running Windows XP.  My Cygwin
> version is "CYGWIN_NT-5.1" and it was downloaded and installed late last

No, it's not.  The output from uname tells us nothing about which
version of Cygwin (or any of the other of dozens of packages you might
have installed), rather it simply means that you are running Windows NT
version 5.1, aka Windows XP.  The current version of Cygwin is 1.5.23-2,
and if you want to include helpful information try attaching the output
of "cygcheck -svr" as requested in the posting instructions.

> Adding entries into termios.h for higher
> baudrates using the convention that B460800 was 0x01006,
> B50 was 0x01007, and B921600 was 0x01008
> caused errors.
>
> #define B230400  0x01004
> #define B256000 0x01005
> /* 3 new entries - as an experiement to see if it works */
> #define B460800  0x01006
> #define B50  0x01007
> #define B921600  0x01008
>
> The calls to cfsetispeed() and cfsetospeed() failed.  Not unsurprising,
> as one could assume that they had been using the original termios.h when
> they were compiled.

This is a Very Bad Idea in general.  You can't just add new defines to a
header file and expect it to work.  The header is an indication of what
a library supports, it is a one-way street.

> 1) Is there a build available for Cygwin (on a Windows platform) that
> has support for higher baud rates?  If so, does anyone know where I
> could find it?

That's kind of an odd question.  Cygwin is open source and of course
people are free to take it and patch it to do whatever they want, so
it's certainly possible that someone has patched their Cygwin to allow
other baud rate settings.  But if they did it would be a separate
project and off-topic for this list, and I'm not aware of any such thing
existing.

Occasionally new features are added to the code which have yet to be
included in released versions, in which case users are directed to try
the new code in the Cygwin snapshots which are provided on cygwin.com,
but in this case that's not an issue as I'm not aware of any recent
changes to this part of the code.

> 2) Assuming there is no such build available, are there plans to add
> support for higher baud rates?  If so, does anyone know when?
>
> 2) Would it be difficult to download the appropriate source files, modify
> them, and make my own Cygwin build?  (The idea of doing this terrifies
> me by the way).  If it is possible, could someone give me some pointers
> on how to do this?

If you read the Win32 API docs for SetCommState()
 and struct DCB:
 you see the
canonical list of #defined baud rates that Win32 supports.  But there's
also this tidbit: "This member can be an actual baud rate value, or one
of the following indexes."

So from this we can see that Win32 supports arbitrary baud rates (with a
certain list of #defined standard ones) whereas the POSIX termios.h /
speed_t API that Cygwin is emulating does not have the capability to set
the rate arbitarily.  Thus, any baud rate can be supported, but the code
has to exist to do the mapping of the symbolic constant.  You can see
this happening in fhandler_serial.cc, which does the actual mapping of
termios to filling the Win32 struct DCB:

   case B110:
 state.BaudRate = CBR_110;
 break;
   case B300:
 state.BaudRate = CBR_300;
 break;
   case B600:
 state.BaudRate = CBR_600;
 break;
   case B1200:
 state.BaudRate = CBR_1200;
 break;
   case B2400:
 state.BaudRate = CBR_2400;
 break;
   case B4800:
 state.BaudRate = CBR_4800;
 break;
   case B9600:
 state.BaudRate = CBR_9600;
 break;
   case B19200:
 state.BaudRate = CBR_19200;
 break;
   case B38400:
 state.BaudRate = CBR_38400;
 break;
   case B57600:
 state.BaudRate = CBR_57600;
 break;
   case B115200:
 state.BaudRate = CBR_115200;
 break;
   case B230400:
 state.BaudRate = 230400 /* CBR_230400 - not defined */;
 break;
   default:
 /* Unsupported baud rate! */
 termios_printf ("Invalid t->c_ospeed %d", t->c_ospeed);
 set_errno (EINVAL);
 return -1;
   }

Thus it appears that it should be easily possible to add a Bx define
for any desired baud rate, as lo

Re: Support for Baud Rates above 250000 baud?

2007-01-09 Thread Brian Dessent
David le Comte wrote:

> I am running Cygwin on a PC that is running Windows XP.  My Cygwin
> version is "CYGWIN_NT-5.1" and it was downloaded and installed late last

No, it's not.  The output from uname tells us nothing about which
version of Cygwin (or any of the other of dozens of packages you might
have installed), rather it simply means that you are running Windows NT
version 5.1, aka Windows XP.  The current version of Cygwin is 1.5.23-2,
and if you want to include helpful information try attaching the output
of "cygcheck -svr" as requested in the posting instructions.

> Adding entries into termios.h for higher
> baudrates using the convention that B460800 was 0x01006,
> B50 was 0x01007, and B921600 was 0x01008
> caused errors.
> 
> #define B230400  0x01004
> #define B256000 0x01005
> /* 3 new entries - as an experiement to see if it works */
> #define B460800  0x01006
> #define B50  0x01007
> #define B921600  0x01008
> 
> The calls to cfsetispeed() and cfsetospeed() failed.  Not unsurprising,
> as one could assume that they had been using the original termios.h when
> they were compiled.

This is a Very Bad Idea in general.  You can't just add new defines to a
header file and expect it to work.  The header is an indication of what
a library supports, it is a one-way street.

> 1) Is there a build available for Cygwin (on a Windows platform) that
> has support for higher baud rates?  If so, does anyone know where I
> could find it?

That's kind of an odd question.  Cygwin is open source and of course
people are free to take it and patch it to do whatever they want, so
it's certainly possible that someone has patched their Cygwin to allow
other baud rate settings.  But if they did it would be a separate
project and off-topic for this list, and I'm not aware of any such thing
existing.

Occasionally new features are added to the code which have yet to be
included in released versions, in which case users are directed to try
the new code in the Cygwin snapshots which are provided on cygwin.com,
but in this case that's not an issue as I'm not aware of any recent
changes to this part of the code.

> 2) Assuming there is no such build available, are there plans to add
> support for higher baud rates?  If so, does anyone know when?
> 
> 2) Would it be difficult to download the appropriate source files, modify
> them, and make my own Cygwin build?  (The idea of doing this terrifies
> me by the way).  If it is possible, could someone give me some pointers
> on how to do this?

If you read the Win32 API docs for SetCommState()
 and struct DCB:
 you see the
canonical list of #defined baud rates that Win32 supports.  But there's
also this tidbit: "This member can be an actual baud rate value, or one
of the following indexes."

So from this we can see that Win32 supports arbitrary baud rates (with a
certain list of #defined standard ones) whereas the POSIX termios.h /
speed_t API that Cygwin is emulating does not have the capability to set
the rate arbitarily.  Thus, any baud rate can be supported, but the code
has to exist to do the mapping of the symbolic constant.  You can see
this happening in fhandler_serial.cc, which does the actual mapping of
termios to filling the Win32 struct DCB:

case B110:
  state.BaudRate = CBR_110;
  break;
case B300:
  state.BaudRate = CBR_300;
  break;
case B600:
  state.BaudRate = CBR_600;
  break;
case B1200:
  state.BaudRate = CBR_1200;
  break;
case B2400:
  state.BaudRate = CBR_2400;
  break;
case B4800:
  state.BaudRate = CBR_4800;
  break;
case B9600:
  state.BaudRate = CBR_9600;
  break;
case B19200:
  state.BaudRate = CBR_19200;
  break;
case B38400:
  state.BaudRate = CBR_38400;
  break;
case B57600:
  state.BaudRate = CBR_57600;
  break;
case B115200:
  state.BaudRate = CBR_115200;
  break;
case B230400:
  state.BaudRate = 230400 /* CBR_230400 - not defined */;
  break;
default:
  /* Unsupported baud rate! */
  termios_printf ("Invalid t->c_ospeed %d", t->c_ospeed);
  set_errno (EINVAL);
  return -1;
}

Thus it appears that it should be easily possible to add a Bx define
for any desired baud rate, as long as you update termios.h and
fhandler_serial.cc to know about it.  So yes, you could just make this
change and rebuild a local cygwin1.dll that supports it.  Building
cygwin1.dll is not much different than any other autoconf-style package
and there are instructions in the Users Guide (or the FAQ, I can't
remember.)  It would be better however to somehow figure out a list of
the missing standard baud rates that are in common use and submit a
patch to add them upstream, rather than just ad hoc adding whatever you
need.

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsub

Support for Baud Rates above 250000 baud?

2007-01-08 Thread David le Comte

Hi,

I am running Cygwin on a PC that is running Windows XP.  My Cygwin
version is "CYGWIN_NT-5.1" and it was downloaded and installed late last
month (Dec 2006).  I have a std serial port capable (according to the device
manager) of speeds to 460800.  I also have a USB connected serial port
capable of 921600 baud.  I would like to run at these speeds.

I have a serial I/O routine that I have mostly written, but it is partly
downloaded from a program that I found on the web.

In the routine where the baud rates are set, we have the following.  
Note the

B230400 entry that I have added.  (Similarly the commented out entries for
460800 and 921600 baud rates)

   case 57600  : local_rate = B57600;  break;
 case 115200 : local_rate = B115200; break;
   /* This 230400 entry is new */
 case 230400 : local_rate = B230400; break;
   /* leave two here for when we have support */
   //  case 460800 : local_rate = B460800; break;
   //  case 921600 : local_rate = B921600; break;
   #endif
   }

   if ((cfsetispeed(&t,local_rate) != -1) &&
   (cfsetospeed(&t,local_rate) != -1))
   {
 if (tcsetattr(rtnval,TCSANOW,&t) == -1)
   rtnval = -1;
   }

Below is a section of termios.h

--  Start Partial List of /usr/include/sys/termios.h -
#define B50 0x1
#define B75 0x2
#define B110 0x3
#define B134 0x4
#define B150 0x5
#define B200 0x6
#define B300 0x7
#define B600 0x8
#define B1200 0x9
#define B1800 0xa
#define B2400 0xb
#define B4800 0xc
#define B9600 0xd
#define B19200 0xe
#define B38400 0xf

#define CSIZE 0x00030
#define CS5 0x0
#define CS6 0x00010
#define CS7 0x00020
#define CS8 0x00030
#define CSTOPB 0x00040
#define CREAD 0x00080
#define PARENB 0x00100
#define PARODD 0x00200
#define HUPCL 0x00400
#define CLOCAL 0x00800
#define CBAUDEX 0x0100f
#define B57600 0x01001
#define B115200 0x01002
#define B128000 0x01003
#define B230400  0x01004
#define B256000 0x01005
--  End Partial List of /usr/include/sys/termios.h -

As expected from termios.h, changing to B230400 works fine.

Adding entries into termios.h for higher
baudrates using the convention that B460800 was 0x01006,
B50 was 0x01007, and B921600 was 0x01008
caused errors. 


#define B230400  0x01004
#define B256000 0x01005
/* 3 new entries - as an experiement to see if it works */
#define B460800  0x01006
#define B50  0x01007
#define B921600  0x01008

The calls to cfsetispeed() and cfsetospeed() failed.  Not unsurprising,
as one could assume that they had been using the original termios.h when
they were compiled.

I thought I'd peruse first this mailing list looking for 460800, B460800,
921600, B921600, max(imum) baud rate, highest baud rate, etc and
got nowhere.

When perusing the web, I did find a few cryptic references to adding support
for such higher speeds in TeraTerm Pro (version 4.24) and in a file called
"defs.c", and to various linux ports for other architectures, but 
nothing that

seemed relevant to Cygwin.

I also found several references to stty not being able to handle baud
rates above 115200.  In my version of Cygwin this is NOT true, setting
the baud rate to 230400 does not give stty any grief.  Not only
does

  stty -F /dev/com[1|3]

report the correct baud rate, but

  stty -F /dev/com[1|3] 230400

works as expected. (NB com1 is my std serial port, and com3 is my USB 
connected port).


Various manual entries for linux, Unix, etc list upper baud rate limits of
57600, 115200 baud, and 460800 baud. (as taken from various sys/termios.h
files).  Man entries for functions such as cfsetispeed() eg just refer 
one to

termios.h for detailed info.

Now for the questions:

1) Is there a build available for Cygwin (on a Windows platform) that
has support for higher baud rates?  If so, does anyone know where I
could find it?

2) Assuming there is no such build available, are there plans to add
support for higher baud rates?  If so, does anyone know when?

2) Would it be difficult to download the appropriate source files, modify
them, and make my own Cygwin build?  (The idea of doing this terrifies
me by the way).  If it is possible, could someone give me some pointers
on how to do this?

regards,

David le Comte



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/