Skip to contentSkip to conversation

btohs,btohl, ...

Bluez-devel # Björn Specht # 2 participants 7 messages Feb 9, 2005 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi all,

I implemented a client server over bluetooth and I was wondering if I need the Little Endian, Big Endien conversion functions btohs,btohl,htobs,htobl?

Do I need to convert every single byte? which is received or sent over my sock_stream socket? If yes, should it look like this for the receiving case: btohs(buf[0]).... an so on for every byte?

Thanks in advance
Björn

maintainer
#1 lore raw

Hi Bjoern,

if you sign emails that go to a mailing list. Make sure that your key is available on a public keyserver. Yours is not.

Quoted 1 line

I implemented a client server over bluetooth and I was wondering if I need the Little Endian, Big Endien conversion functions btohs,btohl,htobs,htobl?

if both sides are of the same endianess then not, but it is a good programming style to always use them.

Quoted 2 lines

Do I need to convert every single byte? which is received or sent over my sock_stream socket? If yes, should it look like this for the receiving case: btohs(buf[0]).... an so on for every byte?

For what do you wanna swap a byte and with what? There is nothing to swap. Think about it ;)

Regards

Marcel

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw

Hi Marcel,

sorry for my signing. I read that sometimes a different order is used withi= n a byte as well and not only between bytes.=20
Okay that makes it easier.
But if this is not the case:
When I send a 32bit integer for example, do I have to worry about the order=
of the bytes when I send or receive them?=20

Bj=F6rn

Quoted 6 lines · On Wed, 09 Feb 2005 14:19:31 +0100 Marcel Holtmann <[email protected]> wrote:

Hi Bjoern,
=20
if you sign emails that go to a mailing list. Make sure that your key is available on a public keyserver. Yours is not.
=20

Quoted 1 line

I implemented a client server over bluetooth and I was wondering if I n=

eed the Little Endian, Big Endien conversion functions btohs,btohl,htobs,ht= obl?

Quoted 5 lines

=20
if both sides are of the same endianess then not, but it is a good programming style to always use them.
=20

Quoted 1 line

Do I need to convert every single byte? which is received or sent over =

my sock_stream socket?

Quoted 1 line
Quoted 1 line

If yes, should it look like this for the receiving case: btohs(buf[0]).=

... an so on for every byte?

Quoted 13 lines

=20
For what do you wanna swap a byte and with what? There is nothing to swap. Think about it ;)
=20
Regards
=20
Marcel
=20
=20
=20
=20
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide

Quoted 8 lines

Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
=20

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#3 lore raw

Hi Bjoern,

Quoted 1 line

sorry for my signing. I read that sometimes a different order is used within a byte as well and not only between bytes.

I don't know of any architecture that stores the bits of its bytes in a different order and where this is visible to for the user. However such a platform might exists.

Quoted 1 line

Okay that makes it easier.

You mean big endian communicates with little endian or vice versa?

Quoted 2 lines

But if this is not the case:
When I send a 32bit integer for example, do I have to worry about the order of the bytes when I send or receive them?

If you have a byte stream (a character array) then you don't need to worry, because they are stored in a endianless format (bytewise). If you use datatypes like uint16_t and uint32_t and send them to the stream or copy them into an array then you should convert them to the same endian encoding.

Regards

Marcel

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw

Thanks Marcel,

You're the man!

Bj=F6rn

Quoted 3 lines · On Wed, 09 Feb 2005 14:57:10 +0100 Marcel Holtmann <[email protected]> wrote:

Hi Bjoern,
=20

Quoted 1 line

sorry for my signing. I read that sometimes a different order is used w=

ithin a byte as well and not only between bytes.=20

Quoted 11 lines

=20
I don't know of any architecture that stores the bits of its bytes in a different order and where this is visible to for the user. However such a platform might exists.
=20

Quoted 1 line

Okay that makes it easier.

=20
You mean big endian communicates with little endian or vice versa? =20

Quoted 2 lines

But if this is not the case:
When I send a 32bit integer for example, do I have to worry about the o=

rder of the bytes when I send or receive them?=20

Quoted 16 lines

=20
If you have a byte stream (a character array) then you don't need to worry, because they are stored in a endianless format (bytewise). If you use datatypes like uint16_t and uint32_t and send them to the stream or copy them into an array then you should convert them to the same endian encoding.
=20
Regards
=20
Marcel
=20
=20
=20
=20
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide

Quoted 8 lines

Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
=20

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#5 lore raw

Re: [Bluez-devel] omtu, imtu

In reply to Marcel Holtmann

Hi Marcel,

can you also tell me what omtu and imtu are for? I know the Maximum Transfe= r Unit, but what exactly do these 2? I have set them to 672 and 0 like in t= he rctest.c file.

Is 672 the maximum? It would just be nice to know the maximum data per fram= e, for a good header to data proportion.

Thanks again=20
Bj=F6rn

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#6 lore raw

Re: [Bluez-devel] omtu, imtu

Hi Bjoern,

Quoted 1 line

can you also tell me what omtu and imtu are for? I know the Maximum Transfer Unit, but what exactly do these 2? I have set them to 672 and 0 like in the rctest.c file.

what about reading the L2CAP part of the Bluetooth specification. It is all there, but in short (i)ncoming MTU and (o)utgoing MTU.

Quoted 1 line

Is 672 the maximum? It would just be nice to know the maximum data per frame, for a good header to data proportion.

The maximal value is 65535. The header/payload is not important for the throughput. Only matching it to the baseband packet types helps.

Regards

Marcel

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel