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

RE: [bluetooth-dev] BCSP part of the stack not endian-friendly ?



Probably you need to do use le16_to_cpu() in the hci_receive_bcsp()
function to get the result in CPU order too.

//Peter

> -----Original Message-----
> From: Alain Paschoud [mailto:alain.paschoud@xxxxxxx.ch]
> Sent: 22 February 2002 17:28
> To: Bluetooth-dev
> Subject: [bluetooth-dev] BCSP part of the stack not endian-friendly ?
> 
> 
> Hi all,
> 
> I send an e-mail some days ago saying that after some 
> commands, the CSR module didn't respond any more. I notice 
> that this happen only on my embedded device, and not if I use 
> the module from the PC.
> After having thought about it, I suspect that the problem is 
> that the embedded device is in big endian...
> 
> An exemple of a command that crashes the module is to read 
> the firmware version (function hci_read_firmware_rev_info()). 
> The record that is sent is composed of several 16 bits long 
> values. And I don't see any management of endian in this function.
> So I tested to put the function cpu_to_le16 (which swap words 
> in case of a bid endian system) before I set every field of 
> the record of type "csr_bccmd". So the part of the function I 
> modified look like that :
> 
>         /* General msg header */
> 	CSR_SET_LAST(msg, 1); /* first and last segment */
> 	CSR_SET_FIRST(msg, 1);
> 	CSR_SET_CH_ID(msg, CSR_CH_ID_BCCMD);
> 
> 	/* BCCMD type */
> 	cmd->type = cpu_to_le16(CSR_MSGTYPE_GETREQ);
> 	cmd->len = cpu_to_le16(5 + 6);
> 	cmd->seq = cpu_to_le16(csr_count++);
> 	cmd->var_id = cpu_to_le16(CSR_CMD_BUILD_ID);
> 	cmd->status = cpu_to_le16(CSR_STATUS_OK); /* always OK 
> in GETREQ */
> 	memset(cmd->payload, 0, 6*sizeof(u16));
> 
> 	tmp = send_cmd_block((u8*) &c_pkt, c_pkt.len + 
> CMD_HDR_LEN + HCI_HDR_LEN, DEFAULT_TIMEOUT);
> 	if (tmp < 0)
> 		return tmp;
> 
> 
> Result : The module doesn't crash any more, but sends I get 
> next thing :
> 
> 
> 
> BT SYS: Reading firmware info in HW module
> HCI: hci_read_firmware_rev_info [CSR] BuildID/ChipVer/ChipRev
> HCI: release_cmd_timer
> BT SYS: hci_receive_bcsp: Not a GETRESP msg
> 
> hci_receive_bcsp (22):
> 0x01 0x00 0x0b 0x00 0x00 0x00 0x19 0x28 0x00 0x00 0xbc 0x00 
> 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
> HCI: release_cmd_timer
> BT SYS: hci_receive_bcsp: Not a GETRESP msg
> 
> hci_receive_bcsp (22):
> 0x01 0x00 0x0b 0x00 0x01 0x00 0x1a 0x28 0x00 0x00 0x01 0x00 
> 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
> HCI: release_cmd_timer
> BT SYS: hci_receive_bcsp: Not a GETRESP msg
> 
> hci_receive_bcsp (22):
> 0x01 0x00 0x0b 0x00 0x02 0x00 0x1b 0x28 0x00 0x00 0x65 0x00 
> 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
> 
> 
> 
> Conclusion : it's now better, the module can respond 
> something and doesn't crash any more. But it doesn't seem to 
> have understood my request.
> 
> Is there something else that I should swap before to send my 
> request ? Does someone already use BCSP with a big endian system ?
> 
> Any comment will be appreciated.
> 
> -- 
> Alain Paschoud                      SMARTDATA SA
> alain.paschoud@xxxxxxx.ch         PSE-A
> http://www.smartdata.ch             1015 Lausanne
> Phone +41-21-693'84'98              
> Fax   +41-27-693'84'91              
> -
> 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