Miod,

I spent a few hours today debugging different loops and timings, some
interesting results:

When I got the SV 125 device working yesterday, I did not change the
ltries variable in the loops, but instead I increased the value sent
into the DELAY() function from 1000 to 3000.  However, if no keyboard
was present, it would still wait 15 seconds (which was your point this
morning), which is way too long for serial users.

Today I changed the value sent to DELAY() back to 1000 in the loops,
and increased the ltries variable from 1000 to 3000 (and added printout
of its value after each while loop).  The first two loops (the one that
waits for the SKEY_STATE_RESET state and the one that waits for the
SKEY_STATE_GETKEY state) always complete within the 1000 tries.  If a
delay is not in place before the SKEY_CMD_LAYOUT is sent, the SV 125
must not respond properly, because the third loop does not get anything
other then -1 in 1000 tries.  The biggest indicator of this was that if
I had the printf() for the ltries inside the condition that executes
the break, it delayed the execution long enough for the keyboard to
always work.  If I stored the ltries value in a temporary variable and
printed out all three of them after the loops, then the keyboard would
not be recognized.

After all of that, I added a 3000 microsecond delay right before the
SKBD_CMD_LAYOUT request because I assumed that the reason it worked
yesterday was due to the longer delay (as opposed to the number of
tries).  That worked, the SV 125 converter works correctly with that
modification.

The best part about that is if no keyboard is present, it will not
increase the time it takes to boot (even if it did it would be .003 of
a second * 5 for total of .015 of a second), but works with the SV 125.

Again, I am not sure if this is something that anyone other then me
would want, so if anyone is interested I included a unified diff output
at the bottom of this message.

Thanks for everyone's help.

Regards,

Mike.

--- comkbd_ebus.c.orig  Sat Mar 12 23:49:38 2011
+++ comkbd_ebus.c Sun Mar 13 19:22:21 2011
@@ -483,6 +483,7 @@
      if (ltries == 0)
         continue;

+      DELAY(3000);

      /* Send layout request */
      comkbd_putc(sc, SKBD_CMD_LAYOUT);

Reply via email to