Nonstandard baud rates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good day!

I don't much like this patch, but it does provide support for
nonstandard baud rates, at least on systems with <linux/serial.h>
(I didn't know where else to find serial_struct), and it might make Wine
serial comms more accessible for new users.

I couldn't think of a good way for it to clean up after itself, so it
doesn't; it is easy enough for a reasonably intelligent human to do with
setserial.  OTOH, it is easy for a reasonably intelligent human to get
nonstandard baud rates using setserial...Maybe I should say I didn't
find a good place to keep track of the flags and custom_divisor as they
were before I changed them.  I trust I will get a suggestion or two on
that and can improve it.

I think WARN is too weak, as things are now, with warn off by default
(for good reason), but it's not a fixme nor an err.  Almost, I wanted to
raise a messagebox, but I don't think a messagebox belongs here or
anywhere else.

I guess you know (I had to find out the hard way :-) you have to run
autoheader.

Anyway, this is Asbestos I can do for now.  Comments, suggestions, or
improvements welcome.  A copy is attached in case your mailer folds the
inline one.

Lawson

ChangeLog:
	configure.ac, dlls/kernel/comm.c:
	Lawson Whitney <lawson_whitney@juno..com>
	Support for nunstandard baud rate in SetCommState.

diff -ur was/configure.ac is/configure.ac
--- was/configure.ac	Sat Feb 16 23:36:08 2002
+++ is/configure.ac	Sat Feb 16 23:39:39 2002
@@ -885,6 +885,7 @@
 	linux/cdrom.h \
 	linux/input.h \
 	linux/joystick.h \
+	linux/serial.h \
 	linux/ucdrom.h \
 	net/if.h \
 	netdb.h \
diff -ur was/dlls/kernel/comm.c is/dlls/kernel/comm.c
--- was/dlls/kernel/comm.c	Wed Dec 26 22:14:09 2001
+++ is/dlls/kernel/comm.c	Sun Feb 17 21:08:38 2002
@@ -68,6 +68,10 @@

 #include "debugtools.h"

+#ifdef HAVE_LINUX_SERIAL_H
+#include <linux/serial.h>
+#endif
+
 DEFAULT_DEBUG_CHANNEL(comm);

 #if !defined(TIOCINQ) && defined(FIONREAD)
@@ -911,6 +915,29 @@
 			break;		
 #endif
        	        default:
+#if defined (HAVE_LINUX_SERIAL_H) && defined (TIOCSSERIAL)
+			{   struct serial_struct nuts;
+			    int arby;
+			    ioctl(fd, TIOCGSERIAL, &nuts);
+			    nuts.custom_divisor = nuts.baud_base / lpdcb->BaudRate;
+			    if (!(nuts.custom_divisor)) nuts.custom_divisor = 1;
+			    arby = nuts.baud_base / nuts.custom_divisor;
+			    nuts.flags &= ~ASYNC_SPD_MASK;
+			    nuts.flags |= ASYNC_SPD_CUST;
+			    WARN("You (or a program acting at your behest)\
+ have specified\n a non-standard baud rate %ld.  Wine will set the\
+ rate to %d,\n which is as close as we can get by our present understanding\
+ of your\n hardware. I hope you know what you are doing.  Any disruption\
+ Wine\n has caused to your linux system can be undone with setserial \n\
+ (see man setserial). If you have incapacitated a Hayes type modem,\n\
+ reset it and it will probably recover.\n", lpdcb->BaudRate, arby);
+  			    ioctl(fd, TIOCSSERIAL, &nuts);
+			    port.c_cflag |= B38400;
+ 			}
+ 			break;
+#endif    /* Don't have linux/serial.h or lack TIOCSSERIAL */
+ 			
+			
                         COMM_SetCommError(handle,IE_BAUDRATE);
 			close( fd );
 			ERR("baudrate %ld\n",lpdcb->BaudRate);

diff -ur was/configure.ac is/configure.ac
--- was/configure.ac	Sat Feb 16 23:36:08 2002
+++ is/configure.ac	Sat Feb 16 23:39:39 2002
@@ -885,6 +885,7 @@
 	linux/cdrom.h \
 	linux/input.h \
 	linux/joystick.h \
+	linux/serial.h \
 	linux/ucdrom.h \
 	net/if.h \
 	netdb.h \
diff -ur was/dlls/kernel/comm.c is/dlls/kernel/comm.c
--- was/dlls/kernel/comm.c	Wed Dec 26 22:14:09 2001
+++ is/dlls/kernel/comm.c	Sun Feb 17 21:08:38 2002
@@ -68,6 +68,10 @@
 
 #include "debugtools.h"
 
+#ifdef HAVE_LINUX_SERIAL_H
+#include <linux/serial.h>
+#endif
+
 DEFAULT_DEBUG_CHANNEL(comm);
 
 #if !defined(TIOCINQ) && defined(FIONREAD)
@@ -911,6 +915,29 @@
 			break;		
 #endif
        	        default:
+#if defined (HAVE_LINUX_SERIAL_H) && defined (TIOCSSERIAL)
+			{   struct serial_struct nuts;
+			    int arby;
+			    ioctl(fd, TIOCGSERIAL, &nuts);
+			    nuts.custom_divisor = nuts.baud_base / lpdcb->BaudRate;
+			    if (!(nuts.custom_divisor)) nuts.custom_divisor = 1;
+			    arby = nuts.baud_base / nuts.custom_divisor;
+			    nuts.flags &= ~ASYNC_SPD_MASK;
+			    nuts.flags |= ASYNC_SPD_CUST;
+			    WARN("You (or a program acting at your behest)\
+ have specified\n a non-standard baud rate %ld.  Wine will set the\
+ rate to %d,\n which is as close as we can get by our present understanding\
+ of your\n hardware. I hope you know what you are doing.  Any disruption\
+ Wine\n has caused to your linux system can be undone with setserial \n\
+ (see man setserial). If you have incapacitated a Hayes type modem,\n\
+ reset it and it will probably recover.\n", lpdcb->BaudRate, arby);
+  			    ioctl(fd, TIOCSSERIAL, &nuts);
+			    port.c_cflag |= B38400;
+ 			}
+ 			break;
+#endif    /* Don't have linux/serial.h or lack TIOCSSERIAL */
+ 			
+			   
                         COMM_SetCommError(handle,IE_BAUDRATE);
 			close( fd );
 			ERR("baudrate %ld\n",lpdcb->BaudRate);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux