|
From: Gordon M. <gm...@us...> - 2001-03-13 19:30:37
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
hci.c 1.126 1.127=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
--Changed the way we handle trashed UART data. Instead of going into the WA=
IT_FOR_TIMEOUT state (which we never seem to leave) we now just drop the bu=
ffer and ttry to resync on the start of the next one. This seems to work ok=
. When I see us discard a byte in the running log I can reset my Ericssons =
on the fly and the stack will sync back up with the byte stream.
The diff of the modified file(s):
--- hci.c 2001/03/12 16:02:57 1.126
+++ hci.c 2001/03/13 19:32:37 1.127
@@ -367,34 +367,26 @@
case WAIT_FOR_PACKET_TYPE:
D_STATE(__FUNCTION__", WAIT_FOR_PACKET_TYPE\n");
tmp_pos =3D 0;
- if (*buf =3D=3D EVENT_PKT) {
- state =3D WAIT_FOR_EVENT_TYPE;
- buf +=3D 1;
- count -=3D 1;
- } else if (*buf =3D=3D ACL_PKT) {
- state =3D WAIT_FOR_ACL_HDR;
- buf +=3D 1;
- count -=3D 1;
- } else if (*buf =3D=3D SCO_PKT) {
- state =3D WAIT_FOR_SCO_HDR;
+ switch(*buf) {
+ case EVENT_PKT: state =3D WAIT_FOR_EVENT_TYPE; break;
+ case ACL_PKT: state =3D WAIT_FOR_ACL_HDR; break;
+ case SCO_PKT: state =3D WAIT_FOR_SCO_HDR; break;
+ default:
+ D_ERR(__FUNCTION__ ": discarding %d bytes\n",
+ count);
+ /* An unrecognized HCI header type is usually a
+ * sign of a problem with the lower level=20
+ * driver. For example, if the UART drops some
+ * bytes due to high interrupt latency. In this
+ * case we'll try to resync by just dropping=20
+ * this buffer and trying again at the start of
+ * the next one.
+ * --gmcnutt
+ */
+ return;
+ }
buf +=3D 1;
count -=3D 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) {=20=20
- DSYS(__FUNCTION__", Resetting state machine and trying to resync\n");
- syncing =3D 0;
- buf =3D data;
- count =3D tmp_data_len;
- state =3D WAIT_FOR_PACKET_TYPE;
- } else {
- state =3D WAIT_FOR_TIMEOUT;
- count =3D 0;
- }
- }=20=20
break;
=20
/* If it is an event packet we wait for the next byte
|