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

[bluetooth-dev] resyncing



Hi,

I've been looking at how HCI tries to resync when it gets some bad data
from below.
Currently it puts itself into the WAIT_FOR_TIMEOUT state where it
remains forever.
In kernel mode this requires you to unload/reload the module to recover.

I've pasted a proposed change to hci_receive_data below.
This could affect a lot of people so I'm not just slamming it into CVS.
Any developers have an opinion?

Note that these changes still leave open the possibility of resyncing in
the wrong place.
But they shouldn't be any worse than what we currently have.

Thanks,
--gmcnutt

----------------------------------------------------------
  case WAIT_FOR_PACKET_TYPE:
   D_STATE(__FUNCTION__", WAIT_FOR_PACKET_TYPE\n");
   tmp_pos = 0;
#if GMCNUTT_CHANGE
   switch(*buf) {
   case EVENT_PKT: state = WAIT_FOR_EVENT_TYPE; break;
   case ACL_PKT: state = WAIT_FOR_ACL_HDR; break;
   case SCO_PKT: state = WAIT_FOR_SCO_HDR; break;
   default:
    /* Since we can't identify the packet type we're
       out of synch with the byte stream. Either the
       UART dropped some bytes or its baud rate is
       wrong.
       --gmcnutt */
#ifdef CONFIG_BLUETOOTH_RESYNC_ON_BYTE
    /* In this case we'll continue examing each byte
       of the current buffer, trying to find the
       start of an HCI packet.
       --gmcnutt */
#else
    /* In the default case we'll discard the whole
       buffer and try to resync on the start of the
       next buffer.
       --gmcnutt */
    return;
#endif /* CONFIG_BLUETOOTH_RESYNC_ON_BYTE */
    printk("0x%x ", *buf);
   }
   buf++;
   count--;
#else /* GMCNUTT_CHANGE */
   if (*buf == EVENT_PKT) {
    state = WAIT_FOR_EVENT_TYPE;
    buf += 1;
    count -= 1;
   } else if (*buf == ACL_PKT) {
    state = WAIT_FOR_ACL_HDR;
    buf += 1;
    count -= 1;
   } else if (*buf == SCO_PKT) {
    state = WAIT_FOR_SCO_HDR;
    buf += 1;
    count -= 1;
   } else {
    D_ERR(__FUNCTION__", Bad UART baud rate or trashed data on the
uart\n");
    D_ERR(__FUNCTION__", Try reducing uart speed or change IRQ setting
(PC)\n");

    if (syncing) {
     DSYS(__FUNCTION__", Resetting state machine and trying to
resync\n");
     syncing = 0;
     buf = data;
     count = tmp_data_len;
     state = WAIT_FOR_PACKET_TYPE;
    } else {
     state = WAIT_FOR_TIMEOUT;
     count = 0;
    }
   }
#endif /* else GMCNUTT_CHANGE */


-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com