* Re: I have a patch for dosemu-1.0.2.1 to enhance rs232 "break" support
[not found] <20020823021342.K43474@tesla.madscientistroom.org>
@ 2002-08-23 16:04 ` Mark Rejhon
0 siblings, 0 replies; 2+ messages in thread
From: Mark Rejhon @ 2002-08-23 16:04 UTC (permalink / raw)
To: Randy Thelen; +Cc: marky, ag115, linux-msdos
Hi!
Thanks, but I stopped working on DOSEMU years ago -- so I'm going to
forward this to the Linux-MSDOS mailing list:
linux-msdos@vger.kernel.org
Glad you're enjoying the software!
Randy Thelen wrote:
>
> Hi Mark!
>
> My name is Randy Thelen and I've hacked on src/base/serial/ser_ports.c
> for dosemu-1.0.2.1. I've added support for programs that create break
> sequences on the COM ports.
>
> In my particular case, I've been trying to run Parallax's stamp2
> program (see http://www.parallaxinc.com/ ) for the Basic Stamp2.
> The stamp2 programmer sends breaks across the rs232 line to get
> the attention of the Basic Stamp. I trouble shot the problem to
> a few simple changes, and I include those here for you to review
> and possibly apply to other changes being considered for a rev
> of dosemu.
>
> DosEmu is a great program and I've used it for about a year and half.
> I love it! This is the best way I know to express my gratitude!
>
> -- Randy Thelen
diff -urN dosemu-1.0.2.1/src/base/serial/ser_ports.c
dosemu-1.0.2.2/src/base/serial/ser_ports.c
--- dosemu-1.0.2.1/src/base/serial/ser_ports.c 2001-03-11 05:27:25.000000000
-0800
+++ dosemu-1.0.2.2/src/base/serial/ser_ports.c 2002-08-23 09:34:22.000000000
-0700
@@ -33,6 +33,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
+#include <ctype.h>
#include "config.h"
#include "emu.h"
@@ -534,6 +535,34 @@
}
+/*
+ * This function updates the msr and mcr with respect to the hardware.
+ * It is necessary because the hardware can change state out from under
+ * neath us, and some DOS code will sit and spin looking at registers
+ * that are alterable from a remote host.
+ */
+static void
+get_update(int num)
+{
+ int control;
+
+ ioctl(com[num].fd, TIOCMGET, &control);
+
+ if (control & TIOCM_RTS) com[num].MCR |= UART_MCR_RTS;
+ else com[num].MCR &= ~UART_MCR_RTS;
+ if (control & TIOCM_DTR) com[num].MCR |= UART_MCR_DTR;
+ else com[num].MCR &= ~UART_MCR_DTR;
+ if (control & TIOCM_CAR) com[num].MSR |= UART_MSR_DCD;
+ else com[num].MSR &= ~UART_MSR_DCD;
+ if (control & TIOCM_RNG) com[num].MSR |= UART_MSR_RI;
+ else com[num].MSR &= ~UART_MSR_RI;
+ if (control & TIOCM_DSR) com[num].MSR |= UART_MSR_DSR;
+ else com[num].MSR &= ~UART_MSR_DSR;
+ if (control & TIOCM_CTS) com[num].MSR |= UART_MSR_CTS;
+ else com[num].MSR &= ~UART_MSR_CTS;
+}
+
+
/* This function returns the value in the MSR (Modem Status Register)
* and does the expected UART operation whenever the MSR is read.
* [num = port]
@@ -543,6 +572,8 @@
{
int val;
+ get_update(num);
+
val = com[num].MSR; /* Save old MSR value */
com[num].MSR &= UART_MSR_STAT; /* Clear delta bits */
com[num].int_condition &= ~MS_INTR; /* MSI condition satisfied */
@@ -568,6 +599,8 @@
{
static int val;
+ if ((com[num].LSR & 1) == 0) sleep(1);
+
val = com[num].LSR; /* Save old LSR value */
com[num].int_condition &= ~LS_INTR; /* RLSI int condition satisfied */
com[num].LSR &= ~UART_LSR_ERR; /* Clear error bits */
@@ -764,6 +797,10 @@
static void
put_lcr(int num, int val)
{
+ int changed;
+ int control;
+ changed = com[num].LCR ^ val; /* Bitmask of changed bits */
+
com[num].LCR = val; /* Set new LCR value */
if (val & UART_LCR_DLAB) { /* Is Baudrate Divisor Latch set? */
s_printf("SER%d: LCR = 0x%x, DLAB high.\n", num, val);
@@ -779,6 +816,16 @@
com[num].DLAB = 0; /* Baudrate Divisor Latch flag */
ser_termios(num); /* Sets new line settings */
}
+
+ /* Set or Clear Break on serial device only if Break state changed */
+ if (changed & UART_LCR_SBC) {
+ if(s1_printf) s_printf("SER%d: LCR: SBC -> %d\n",num,(val &
UART_LCR_SBC));
+ control = 0; /* UNUSED for TIOCSBRK and TIOCCBRK */
+ if (val & UART_LCR_SBC)
+ ioctl(com[num].fd, TIOCSBRK, &control);
+ else
+ ioctl(com[num].fd, TIOCCBRK, &control);
+ }
}
@@ -831,7 +878,7 @@
com[num].int_enab = (val & UART_MCR_OUT2);
/* Force RTS & DTR reinitialization if the loopback state has changed */
- if (UART_MCR_LOOP) changed |= UART_MCR_RTS | UART_MCR_DTR;
+ if (changed & UART_MCR_LOOP) changed |= UART_MCR_RTS | UART_MCR_DTR;
/* Update DTR setting on serial device only if DTR state changed */
if (changed & UART_MCR_DTR) {
@@ -977,6 +1024,7 @@
break;
case UART_MCR: /* Read from Modem Control Register */
+ get_update(num);
val = com[num].MCR;
if(s2_printf) s_printf("SER%d: Read MCR = 0x%x\n",num,val);
break;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: I have a patch for dosemu-1.0.2.1 to enhance rs232 "break" support
@ 2002-08-23 21:58 Stas Sergeev
0 siblings, 0 replies; 2+ messages in thread
From: Stas Sergeev @ 2002-08-23 21:58 UTC (permalink / raw)
To: linux-msdos; +Cc: Randy Thelen
Hello.
Mark Rejhon wrote:
> Randy Thelen wrote:
>> Hi Mark!
>> My name is Randy Thelen and I've hacked on
>> src/base/serial/ser_ports.c
>> for dosemu-1.0.2.1.
Please consider hacking >=1.1.3.2 as the serial
code was changed a bit.
> + * This function updates the msr and mcr with respect to the hardware.
Are you sure we need this for mcr?
And for msr we have a modstat_engine()...
So please provide some more explanations as
currently I don't see a point (yes, as the
serial code is no longer maintained, you'll
have to provide some more explanations than
expected for makeing a maintainer to understand).
> + if ((com[num].LSR & 1) == 0) sleep(1);
What is this?
> put_lcr(int num, int val)
> {
> + int changed;
I think you don't need "changed" here, "val"
must work.
> + control = 0; /* UNUSED for TIOCSBRK and TIOCCBRK */
> + if (val & UART_LCR_SBC)
> + ioctl(com[num].fd, TIOCSBRK, &control);
Will the ioctl(com[num].fd, TIOCSBRK) work?
I think this ioctl doesn't require an arg at all.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-08-23 21:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-23 21:58 I have a patch for dosemu-1.0.2.1 to enhance rs232 "break" support Stas Sergeev
[not found] <20020823021342.K43474@tesla.madscientistroom.org>
2002-08-23 16:04 ` Mark Rejhon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox