From a1163de83ea633463a79de234b8742ee106531b2 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Sat, 13 Jun 2009 19:17:10 +0000 Subject: [PATCH] - Long events were locking the bluetooth server, as events can be more than 256 counting with the header. - Add debug more information in H2 driver and Command Status event - Change name of port for posting events(former was too long) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31036 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/bluetooth/HCI/btHCI_transport.h | 4 ++-- .../drivers/bluetooth/h2/h2generic/h2transactions.c | 2 ++ .../kernel/drivers/bluetooth/h2/h2generic/h2upper.c | 6 +++--- src/servers/bluetooth/BluetoothServer.cpp | 8 +++++--- src/servers/bluetooth/BluetoothServer.h | 8 ++++---- src/servers/bluetooth/LocalDeviceImpl.cpp | 4 ++-- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/headers/os/bluetooth/HCI/btHCI_transport.h b/headers/os/bluetooth/HCI/btHCI_transport.h index f6962e9829..6960ce31e5 100644 --- a/headers/os/bluetooth/HCI/btHCI_transport.h +++ b/headers/os/bluetooth/HCI/btHCI_transport.h @@ -75,7 +75,7 @@ typedef struct bt_hci_device { #define BT_IOCTLS_OFFSET 3000 enum { - ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, + ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, //12999 GET_STATS, GET_NOTIFICATION_PORT, GET_HCI_ID, @@ -89,7 +89,7 @@ enum { /* Port drivers can use to send information (1 for all for at moment refer to ioctl GET_NOTIFICATION_PORT)*/ -#define BT_USERLAND_PORT_NAME "bluetooth kernel-user Land" +#define BT_USERLAND_PORT_NAME "Kernel-User Event" #define BLUETOOTH_CONNECTION_PORT "bluetooth connection port" #define BLUETOOTH_CONNECTION_SCHED_PORT "bluetooth con sched port" diff --git a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c index e06536e7b3..2cba1946e5 100644 --- a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c +++ b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c @@ -164,6 +164,8 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len) //bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer/slower option status_t error; + debugf("cookie@%p status=%ld len=%ld\n", cookie, status, actual_len); + if (bdev == NULL) return; diff --git a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c index b619af704f..8a9812c4fb 100644 --- a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c +++ b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2upper.c @@ -14,7 +14,7 @@ #include "h2transactions.h" #include "snet_buffer.h" -//#define BT_DEBUG_THIS_MODULE +#define BT_DEBUG_THIS_MODULE #include @@ -93,14 +93,14 @@ post_packet_up(bt_usb_dev* bdev, bt_packet_t type, void* buf) if (type == BT_EVENT) { snet_buffer* snbuf = (snet_buffer*)buf; - flowf("to btDataCore\n"); btCoreData->PostEvent(bdev->ndev, snb_get(snbuf), (size_t)snb_size(snbuf)); snb_park(&bdev->snetBufferRecycleTrash, snbuf); + debugf("to btDataCore len=%d\n", snb_size(snbuf)); } else { net_buffer* nbuf = (net_buffer*) buf; /* No need to free the buffer at allocation is gonna be reused */ - flowf("to net_device\n"); btDevices->receive_data(bdev->ndev, &nbuf); + flowf("to net_device\n"); } return err; diff --git a/src/servers/bluetooth/BluetoothServer.cpp b/src/servers/bluetooth/BluetoothServer.cpp index f061f40096..a47ef3e9b8 100644 --- a/src/servers/bluetooth/BluetoothServer.cpp +++ b/src/servers/bluetooth/BluetoothServer.cpp @@ -32,14 +32,16 @@ DispatchEvent(struct hci_event_header* header, int32 code, size_t size) { // we only handle events if (GET_PORTCODE_TYPE(code)!= BT_EVENT) { - Output::Instance()->Post("Wrong type frame code", BLACKBOARD_GENERAL); + Output::Instance()->Post("Wrong type frame code", BLACKBOARD_KIT); return B_OK; } // fetch the LocalDevice who belongs this event - LocalDeviceImpl* lDeviceImplementation = ((BluetoothServer*)be_app)->LocateLocalDeviceImpl(GET_PORTCODE_HID(code)); + LocalDeviceImpl* lDeviceImplementation = ((BluetoothServer*)be_app)-> + LocateLocalDeviceImpl(GET_PORTCODE_HID(code)); + if (lDeviceImplementation == NULL) { - Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_GENERAL); + Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_KIT); return B_OK; } diff --git a/src/servers/bluetooth/BluetoothServer.h b/src/servers/bluetooth/BluetoothServer.h index 5d4b373ecb..703efe4ed1 100644 --- a/src/servers/bluetooth/BluetoothServer.h +++ b/src/servers/bluetooth/BluetoothServer.h @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BLUETOOTH_SERVER_APP_H #define _BLUETOOTH_SERVER_APP_H @@ -38,7 +35,10 @@ typedef enum { #define BLACKBOARD_LD(X) (BLACKBOARD_END+X-HCI_DEVICE_INDEX_OFFSET) typedef BObjectList LocalDevicesList; -typedef PortListener BluetoothPortListener; +typedef PortListener BluetoothPortListener; class BluetoothServer : public BApplication { diff --git a/src/servers/bluetooth/LocalDeviceImpl.cpp b/src/servers/bluetooth/LocalDeviceImpl.cpp index f7e89961cf..b088ad6aa4 100644 --- a/src/servers/bluetooth/LocalDeviceImpl.cpp +++ b/src/servers/bluetooth/LocalDeviceImpl.cpp @@ -481,8 +481,8 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, BMessage* reques // Handle command complete information request->FindInt16("opcodeExpected", index, &opcodeExpected); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) for %s\n",__FUNCTION__, - event->ncmd,GetCommand(opcodeExpected)); + Output::Instance()->Postf(BLACKBOARD_LD(GetID()),"%s(%d) %x for %s\n",__FUNCTION__, + event->ncmd, event->status, GetCommand(event->opcode)); if (request->IsSourceWaiting() == false) Output::Instance()->Post("Nobody waiting for the event\n", BLACKBOARD_KIT);