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

RE: [bluetooth-dev] Can anybody help to explain the following code?




In function hci_init() :

	/* Initiate the hci inbuffers */
	for (i = 0; i < NBR_OF_HCI_INBUFFERS; i++) {
		hci_ctrl.hci_in_buf[i].buf_ptr = hci_ctrl.hci_in_buf[i].buf;
		hci_ctrl.hci_in_buf[i].count = 0;
		hci_ctrl.hci_in_buf[i].l2cap_len = 0;
		hci_ctrl.hci_in_buf[i].empty = TRUE;
		hci_ctrl.hci_in_buf[i].nbr_of_hci_pkt = 0;
	}

brgds
Mattias

> -----Original Message-----
> From: Liu Xiao Guo (ENO) [mailto:xiaoguo.liu@xxxxxxx.se]
> Sent: den 5 juli 2001 09:59
> To: bluetooth-dev@xxxxxxx.com
> Subject: [bluetooth-dev] Can anybody help to explain the 
> following code?
> 
> 
> 
> Hi,
> 
> In HCI.c file, Axis stack has the following code (inside function
> "hci_receive_data(u8* data, u32 count)"):
> 
> void hci_receive_data(u8* data, u32 count)
> {
> 	case WAIT_FOR_ACL_HDR:
> 		.....
> 		if (pb_flag == L2CAP_FRAME_START) {
> 			D_REC(__FUNCTION__ ": New frame\n");
> 			in_buf = get_free_inbuffer();
> 			if (in_buf) {
> 				in_buf->nbr_of_hci_pkt = 1;
> 				in_buf->hci_hdl = hci_hdl;
> 			}
> 
> 		case WAIT_FOR_ACL_DATA:
> 			D_STATE(__FUNCTION__ ": WAIT_FOR_ACL_DATA\n");
> 		....
> 			c = MIN(count, data_len - tmp_pos);
> 			if (in_buf) {
> 				memcpy(in_buf->buf_ptr, buf, c);
> 				in_buf->buf_ptr += c;
> 				in_buf->count += c;
> 				D_REC(__FUNCTION__ ": in_buf->count =
> %d\n",in_buf->count);
> 			}		
> }
> 
> If my understanding is correct, "in_buf->buf_ptr" is not 
> initialized before
> it is used for the FISRT ACL packet!!!!! I have looked at the 
> code, and it
> is initialized only inside "hci_clear_buffer" function, which 
> is called
> within function "l2cap_receive_data". Actually function 
> "l2cap_receive_data"
> is called after the "in_buf->buf_ptr" is used!!!!
> 
> regards,
> 
> XiaoGuo
> -
> To unsubscribe from this list: send the line "unsubscribe 
> bluetooth-dev" in
> the body of a message to majordomo@xxxxxxx.com
> 
-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com