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

[bluetooth-dev] Problem: user stack + data transfer



Hi all,

I'm having some problems working with the stack (latest cvs). Most of
them are probably conceptual, so any advice is appreciated.

Kernel 2.2.16, Sigma toolkits

1. Kernel mode vs. user mode
If I want to use usermode functions like bt_write_top and
bt_receive_top in a program of my own, how do I do it? When I run
btduser, I cannot run the programs in the experimental catalog (btinq,
bttest etc).

2. I have written a simple client-server pipe. The server sits waiting
on a bt_waitnewconnections(..). When a connection is established, I
open("/dev/ttyBT0", 0_RDWR | 0_NOCTTY). In a while-loop, I use read(..)
to read data into a buffer, and then fwrite(..) to stdout.

The client connects using bt_connect(..). When a connection is
established, I open("/dev/ttyBT0", 0_RDWR | 0_NOCTTY). In a while-loop,
I use write(..) to write data from a buffer to the opened tty. When
there is no more data to send, I sleep for a few seconds and then do a
bt_disconnect(bt_cfd, con_id).

The data gets across ok if it is ASCII characters but not for binaries.
I'm quite sure ASCII nulls cause the receiving buffer to not fill up
completely. Any advice on how to fix this would be appreciated, but it
is not the main problem.

The main problem is that when I disconnect the client, the kernel debug
always says there are 4 commands in queue, and requires the btdm to be
shutdown, the /var/run/btd.pid to be removed, and a hardware reset :(.
I've attached the kernel log tail. Any suggestions? Should I be using
ppp (no clue how) instead of reading/writing? Disconnect in a different
way?

Any help appreciated, running out of time (thesis work).

Kind regards,

Per



Aug  9 10:31:49 pixel08 kernel:
Aug  9 10:31:49 pixel08 kernel: process_event (5):
Aug  9 10:31:49 pixel08 kernel: 0x01 0x01 0x00 0x05 0x00 
Aug  9 10:31:49 pixel08 kernel: HCI: process_event: NUMBER_OF_COMPLETED_PACKETS
Aug  9 10:31:49 pixel08 kernel: HCI: update_ncp: acl_num before: 3
Aug  9 10:31:49 pixel08 kernel: HCI: update_ncp: acl_num after: 8
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_ioctl: BTDISCONNECT
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_disconnect: Disconnecting line 0 (ONLY RFCOMM)
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: l2cap_send_data:  (8):
Aug  9 10:31:58 pixel08 kernel: 0x04 0x00 0x42 0x00 0x0b 0x53 0x01 0xb8 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: send_acl_packet:  (13):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x42 0x00 0x0b 0x53 0x01 0xb8 
Aug  9 10:31:58 pixel08 kernel: BT DATA <--|X|     13
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: <--|X| (13):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x42 0x00 0x0b 0x53 0x01 0xb8 
Aug  9 10:31:58 pixel08 kernel: BT DATA -->|X|      9
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: -->|X| (9):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x40 0x00 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data:  (9):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x40 0x00 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data: hci-9
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: New frame
Aug  9 10:31:58 pixel08 kernel: HCI: get_free_inbuffer: inbuffer 0 was free
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: in_buf->count = 4
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: Copied 4 bytes into inbuffer
Aug  9 10:31:58 pixel08 kernel: BT DATA -->|X|      4
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: -->|X| (4):
Aug  9 10:31:58 pixel08 kernel: 0x0b 0x73 0x01 0x92 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data:  (4):
Aug  9 10:31:58 pixel08 kernel: 0x0b 0x73 0x01 0x92 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data: hci-4
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: in_buf->count = 8
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: Copied 4 bytes into inbuffer
Aug  9 10:31:58 pixel08 kernel: HCI: process_acl_data: in_buf->count:8, in_buf->l2cap_len:0
Aug  9 10:31:58 pixel08 kernel:     L2CAP l2cap_receive_data: got 8 bytes on hci_handle : 1
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: l2cap_receive_data:  (8):
Aug  9 10:31:58 pixel08 kernel: 0x04 0x00 0x40 0x00 0x0b 0x73 0x01 0x92 
Aug  9 10:31:58 pixel08 kernel:     L2CAP l2cap_receive_data: New frame len:4 cid:64
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: process_frame:  (4):
Aug  9 10:31:58 pixel08 kernel: 0x0b 0x73 0x01 0x92 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: rfcomm_receive_data: rfcomm_receive_data: (4):
Aug  9 10:31:58 pixel08 kernel: 0x0b 0x73 0x01 0x92 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: l2cap_send_data:  (8):
Aug  9 10:31:58 pixel08 kernel: 0x04 0x00 0x42 0x00 0x03 0x53 0x01 0xfd 
Aug  9 10:31:58 pixel08 kernel: HCI: hci_clear_buffer
Aug  9 10:31:58 pixel08 kernel: HCI: get_inbuffer: Found inbuffer for hci_hdl 1 d0059534
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: send_acl_packet:  (13):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x42 0x00 0x03 0x53 0x01 0xfd 
Aug  9 10:31:58 pixel08 kernel: BT DATA <--|X|     13
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: <--|X| (13):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x42 0x00 0x03 0x53 0x01 0xfd 
Aug  9 10:31:58 pixel08 kernel: BT DATA -->|X|     13
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: -->|X| (13):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x40 0x00 0x03 0x73 0x01 0xd7 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data:  (13):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x08 0x00 0x04 0x00 0x40 0x00 0x03 0x73 0x01 0xd7 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data: hci-13
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: New frame
Aug  9 10:31:58 pixel08 kernel: HCI: get_free_inbuffer: inbuffer 0 was free
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: in_buf->count = 8
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: Copied 8 bytes into inbuffer
Aug  9 10:31:58 pixel08 kernel: HCI: process_acl_data: in_buf->count:8, in_buf->l2cap_len:0
Aug  9 10:31:58 pixel08 kernel:     L2CAP l2cap_receive_data: got 8 bytes on hci_handle : 1
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: l2cap_receive_data:  (8):
Aug  9 10:31:58 pixel08 kernel: 0x04 0x00 0x40 0x00 0x03 0x73 0x01 0xd7 
Aug  9 10:31:58 pixel08 kernel:     L2CAP l2cap_receive_data: New frame len:4 cid:64
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: process_frame:  (4):
Aug  9 10:31:58 pixel08 kernel: 0x03 0x73 0x01 0xd7 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: rfcomm_receive_data: rfcomm_receive_data: (4):
Aug  9 10:31:58 pixel08 kernel: 0x03 0x73 0x01 0xd7 
Aug  9 10:31:58 pixel08 kernel: BT SYS: rfcomm_receive_data: RFCOMM disconnected ctrl ch (local) on line [0]
Aug  9 10:31:58 pixel08 kernel: HCI: hci_clear_buffer
Aug  9 10:31:58 pixel08 kernel: HCI: get_inbuffer: Found inbuffer for hci_hdl 1 d0059534
Aug  9 10:31:58 pixel08 kernel: l2ca_disconnect_req, sleep on wq 0xcb7701c4
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: send_acl_packet:  (17):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x0c 0x00 0x08 0x00 0x01 0x00 0x06 0x03 0x04 0x00 0x42 0x00 0x40 
Aug  9 10:31:58 pixel08 kernel: 0x00 
Aug  9 10:31:58 pixel08 kernel: BT DATA <--|X|     17
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: <--|X| (17):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x0c 0x00 0x08 0x00 0x01 0x00 0x06 0x03 0x04 0x00 0x42 0x00 0x40 
Aug  9 10:31:58 pixel08 kernel: 0x00 
Aug  9 10:31:58 pixel08 kernel: BT DATA -->|X|      8
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: -->|X| (8):
Aug  9 10:31:58 pixel08 kernel: 0x04 0x13 0x05 0x01 0x01 0x00 0x05 0x00 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data:  (8):
Aug  9 10:31:58 pixel08 kernel: 0x04 0x13 0x05 0x01 0x01 0x00 0x05 0x00 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data: hci-8
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: process_event (5):
Aug  9 10:31:58 pixel08 kernel: 0x01 0x01 0x00 0x05 0x00 
Aug  9 10:31:58 pixel08 kernel: HCI: process_event: NUMBER_OF_COMPLETED_PACKETS
Aug  9 10:31:58 pixel08 kernel: HCI: update_ncp: acl_num before: 5
Aug  9 10:31:58 pixel08 kernel: HCI: update_ncp: acl_num after: 10
Aug  9 10:31:58 pixel08 kernel: BT DATA -->|X|     17
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: -->|X| (17):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x0c 0x00 0x08 0x00 0x01 0x00 0x07 0x03 0x04 0x00 0x42 0x00 0x40 
Aug  9 10:31:58 pixel08 kernel: 0x00 
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data:  (17):
Aug  9 10:31:58 pixel08 kernel: 0x02 0x01 0x20 0x0c 0x00 0x08 0x00 0x01 0x00 0x07 0x03 0x04 0x00 0x42 0x00 0x40 
Aug  9 10:31:58 pixel08 kernel: 0x00 
Aug  9 10:31:58 pixel08 kernel: hci_receive_data: hci-17
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: New frame
Aug  9 10:31:58 pixel08 kernel: HCI: get_free_inbuffer: inbuffer 0 was free
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: in_buf->count = 12
Aug  9 10:31:58 pixel08 kernel: HCI: hci_receive_data: Copied 12 bytes into inbuffer
Aug  9 10:31:58 pixel08 kernel: HCI: process_acl_data: in_buf->count:12, in_buf->l2cap_len:0
Aug  9 10:31:58 pixel08 kernel:     L2CAP l2cap_receive_data: got 12 bytes on hci_handle : 1
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: l2cap_receive_data:  (12):
Aug  9 10:31:58 pixel08 kernel: 0x08 0x00 0x01 0x00 0x07 0x03 0x04 0x00 0x42 0x00 0x40 0x00 
Aug  9 10:31:58 pixel08 kernel:     L2CAP l2cap_receive_data: New frame len:8 cid:1
Aug  9 10:31:58 pixel08 kernel:     L2CAP l2cap_receive_data: Signal data !
Aug  9 10:31:58 pixel08 kernel:     L2CAP signal_handler: received 8 bytes
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: signal_handler: data (8):
Aug  9 10:31:58 pixel08 kernel: 0x07 0x03 0x04 0x00 0x42 0x00 0x40 0x00 
Aug  9 10:31:58 pixel08 kernel:     L2CAP signal_handler: Single command
Aug  9 10:31:58 pixel08 kernel:     L2CAP signal_handler: got packet (4 bytes) with ID : 3
Aug  9 10:31:58 pixel08 kernel: 
Aug  9 10:31:58 pixel08 kernel: process_response: disconnect response (4):
Aug  9 10:31:58 pixel08 kernel: 0x42 0x00 0x40 0x00 
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_disconnect_ind : RFCOMM dlci : 0
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_unregister_rfcomm : line 0
Aug  9 10:31:58 pixel08 kernel: BT (driver) Upper tty still open...
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_hangupline : hanging up line 0
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_disconnect_cfm : psm 3, status 0
Aug  9 10:31:58 pixel08 kernel: BT SYS: l2cap channel (64,66) [RFCOMM] disconnected
Aug  9 10:31:58 pixel08 kernel: l2cap disc rsp, wake up wq 0xcb7701c4
Aug  9 10:31:58 pixel08 kernel: HCI: hci_clear_buffer
Aug  9 10:31:58 pixel08 kernel: HCI: get_inbuffer: Found inbuffer for hci_hdl 1 d0059534
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_flush_buffer, ignored
Aug  9 10:31:58 pixel08 kernel: BT (driver) bt_hangup on line 0 (nothing done) pid 0 (swapper)
Aug  9 10:31:58 pixel08 kernel: l2ca_disconnect_req, woke up !
Aug  9 10:31:58 pixel08 kernel: BT SYS: l2ca_disconnect_req : (C) no more l2cap cons
Aug  9 10:31:58 pixel08 kernel: BT SYS: Shutdown baseband
Aug  9 10:31:58 pixel08 kernel: HCI: disconnect
Aug  9 10:31:58 pixel08 kernel: HCI: start_cmd_timer
Aug  9 10:31:58 pixel08 kernel: HCI: insert_cmd
Aug  9 10:31:58 pixel08 kernel: HCI: send_cmd_queue: start: Num_HCI_Command_Packets=0
Aug  9 10:31:58 pixel08 kernel: HCI: send_cmd_queue: end : 4 cmds left in queue
Aug  9 10:32:00 pixel08 kernel: cmd_timeout: Timeout when waiting for command response
Aug  9 10:32:00 pixel08 kernel: BT (driver) bt_close on line 7
Aug  9 10:32:00 pixel08 kernel: BT (driver) Unregistering tty on line 7
Aug  9 10:32:00 pixel08 kernel: BT (driver) bt_close on line 0
Aug  9 10:32:00 pixel08 kernel: BT (driver) Unregistering tty on line 0