Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ir Fix some minor bug.



details:   https://anonhg.NetBSD.org/src/rev/ef60ccd26a1c
branches:  trunk
changeset: 518752:ef60ccd26a1c
user:      augustss <augustss%NetBSD.org@localhost>
date:      Wed Dec 05 04:07:06 2001 +0000

description:
Fix some minor bug.
Add more debugging.

diffstat:

 sys/dev/ir/irframe_tty.c |  52 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 39 insertions(+), 13 deletions(-)

diffs (167 lines):

diff -r 3c3bef2ff4a4 -r ef60ccd26a1c sys/dev/ir/irframe_tty.c
--- a/sys/dev/ir/irframe_tty.c  Wed Dec 05 04:06:32 2001 +0000
+++ b/sys/dev/ir/irframe_tty.c  Wed Dec 05 04:07:06 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irframe_tty.c,v 1.6 2001/12/05 01:13:58 augustss Exp $ */
+/*     $NetBSD: irframe_tty.c,v 1.7 2001/12/05 04:07:06 augustss Exp $ */
 
 /*
  * TODO
@@ -235,9 +235,9 @@
 
        s = spltty();
 
-       DPRINTF(("%s: linesw=%p disc=%d\n", __FUNCTION__, tp->t_linesw,
-                tp->t_linesw->l_no));
-       if (tp->t_linesw->l_no == IRFRAMEDISC) {
+       DPRINTF(("%s: linesw=%p disc=%s\n", __FUNCTION__, tp->t_linesw,
+                tp->t_linesw->l_name));
+       if (strcmp(tp->t_linesw->l_name, "irframe") == 0) { /* XXX */
                sc = (struct irframet_softc *)tp->t_sc;
                DPRINTF(("%s: sc=%p sc_tp=%p\n", __FUNCTION__, sc, sc->sc_tp));
                if (sc != NULL) {
@@ -246,12 +246,12 @@
                }
        }
 
-       printf("%s attached at tty%02d:", sc->sc_irp.sc_dev.dv_xname,
-           minor(tp->t_dev));
        tp->t_sc = irframe_alloc(sizeof (struct irframet_softc),
                        &irframet_methods, tp);
        sc = (struct irframet_softc *)tp->t_sc;
        sc->sc_tp = tp;
+       printf("%s attached at tty%02d\n", sc->sc_irp.sc_dev.dv_xname,
+           minor(tp->t_dev));
 
        DPRINTF(("%s: set sc=%p\n", __FUNCTION__, sc));
 
@@ -360,6 +360,9 @@
 void
 irt_frame(struct irframet_softc *sc, u_char *buf, u_int len)
 {
+       DPRINTF(("%s: nframe=%d framei=%d frameo=%d\n",
+                __FUNCTION__, sc->sc_nframes, sc->sc_framei, sc->sc_frameo));
+
        if (sc->sc_nframes >= MAXFRAMES) {
 #ifdef IRFRAMET_DEBUG
                printf("%s: dropped frame\n", __FUNCTION__);
@@ -397,7 +400,12 @@
 {
        struct irframet_softc *sc = (struct irframet_softc *)tp->t_sc;
 
-       DPRINTF(("%s: tp=%p c=0x%0x\n", __FUNCTION__, tp, c));
+       c &= 0xff;
+
+#if IRFRAMET_DEBUG
+       if (irframetdebug > 1)
+               DPRINTF(("%s: tp=%p c=0x%02x\n", __FUNCTION__, tp, c));
+#endif
 
        if (sc == NULL || tp != (struct tty *)sc->sc_tp)
                return (0);
@@ -407,11 +415,15 @@
 
        switch (c) {
        case SIR_BOF:
+               DPRINTF(("%s: BOF\n", __FUNCTION__));
                sc->sc_framestate = FRAME_INSIDE;
                sc->sc_inchars = 0;
                sc->sc_inFCS = INITFCS;
                break;
        case SIR_EOF:
+               DPRINTF(("%s: EOF state=%d inchars=%d fcs=0x%04x\n",
+                        __FUNCTION__,
+                        sc->sc_framestate, sc->sc_inchars, sc->sc_inFCS));
                if (sc->sc_framestate == FRAME_INSIDE &&
                    sc->sc_inchars >= 4 && sc->sc_inFCS == GOODFCS) {
                        irt_frame(sc, sc->sc_inbuf, sc->sc_inchars - 2);
@@ -423,10 +435,13 @@
                sc->sc_framestate = FRAME_OUTSIDE;
                break;
        case SIR_CE:
+               DPRINTF(("%s: CE\n", __FUNCTION__));
                if (sc->sc_framestate == FRAME_INSIDE)
                        sc->sc_framestate = FRAME_ESCAPE;
                break;
        default:
+               DPRINTF(("%s: c=0x%02x, inchar=%d state=%d\n", __FUNCTION__, c,
+                        sc->sc_inchars, sc->sc_state));
                if (sc->sc_framestate != FRAME_OUTSIDE) {
                        if (sc->sc_framestate == FRAME_ESCAPE) {
                                sc->sc_framestate = FRAME_INSIDE;
@@ -446,9 +461,11 @@
                break;
        }
 
+#if 1
        if (sc->sc_framestate != FRAME_OUTSIDE) {
-               callout_reset(&sc->sc_timeout, hz/100, irt_timeout, sc);
+               callout_reset(&sc->sc_timeout, hz/20, irt_timeout, sc);
        }
+#endif
 
        return (0);
 }
@@ -513,6 +530,9 @@
        DPRINTF(("%s: resid=%d, iovcnt=%d, offset=%ld\n", 
                 __FUNCTION__, uio->uio_resid, uio->uio_iovcnt, 
                 (long)uio->uio_offset));
+       DPRINTF(("%s: nframe=%d framei=%d frameo=%d\n",
+                __FUNCTION__, sc->sc_nframes, sc->sc_framei, sc->sc_frameo));
+
 
        s = splir();    
        while (sc->sc_nframes == 0) {
@@ -538,10 +558,11 @@
                } else {
                        DPRINTF(("%s: moving %d bytes\n", __FUNCTION__,
                                 sc->sc_frames[sc->sc_frameo].len));
-                               error = uiomove(sc->sc_frames[sc->sc_frameo].buf,
+                       error = uiomove(sc->sc_frames[sc->sc_frameo].buf,
                                        sc->sc_frames[sc->sc_frameo].len, uio);
+                       DPRINTF(("%s: error=%d\n", __FUNCTION__, error));
                }
-               sc->sc_frameo++;
+               sc->sc_frameo = (sc->sc_frameo+1) % MAXFRAMES;
                sc->sc_nframes--;
        }
        splx(s);
@@ -602,7 +623,9 @@
        size_t n;
        int error;
 
-       DPRINTF(("%s\n", __FUNCTION__));
+       DPRINTF(("%s: resid=%d, iovcnt=%d, offset=%ld\n", 
+                __FUNCTION__, uio->uio_resid, uio->uio_iovcnt, 
+                (long)uio->uio_offset));
 
        n = uio->uio_resid;
        if (n > MAX_IRDA_FRAME)
@@ -647,6 +670,8 @@
 
        irframetstart(tp);
 
+       DPRINTF(("%s: done\n", __FUNCTION__));
+
        return (error);
 }
 
@@ -669,7 +694,7 @@
                        DPRINTF(("%s: have data\n", __FUNCTION__));
                        revents |= events & (POLLIN | POLLRDNORM);
                } else {
-                       DPRINTF(("%s: recording select", __FUNCTION__));
+                       DPRINTF(("%s: recording select\n", __FUNCTION__));
                        selrecord(p, &sc->sc_rsel);
                }
        }
@@ -686,7 +711,8 @@
        struct termios tt;
        int i;
 
-       DPRINTF(("%s: tp=%p\n", __FUNCTION__, tp));
+       DPRINTF(("%s: tp=%p speed=%d ebofs=%d maxsize=%d\n",
+                __FUNCTION__, tp, p->speed, p->ebofs, p->maxsize));
 
        if (p->speed != sc->sc_speed) {
                switch (p->speed) {



Home | Main Index | Thread Index | Old Index