I think you are confusing byte ordering with bit ordering, the IEEE
802.15.4 frame format uses little-endian _byte_ ordering, so the least
significant byte comes first. But inside each byte, the least
significant bit has number 0, the most significant bit has number 7.
Therefore, a byte where only bit number 4 is set (written 1 << 4 in
C), is equal to 0x10.

/Joakim

On Wed, Nov 27, 2019 at 2:16 PM Aboodi Ahed Hussein Ali
<abo...@student.usm.my> wrote:
>
> Thank you, Joakim, but I don't think it is correct.
>
> Starting from 0, bit No. 3 of the IEEE802154_FCF_VERS_V1 (Hex 0x10 or binary: 
> 0001 0000) have the value 1, thus 0 to 3 represent 8 to 11 on buf[1]. 
> therefor, the bit No. 3, in 0x10, is set on bit No. 11 of the FCF.
>
> Not sure if the below illustration will be on a layout.
> ---buf[0]         buf[1]
> 0000 0000   0000 0000       <-- FCF
> ------------- 0001 0000       <-- IEEE802154_FCF_VERS_V1
>
> This means that the Frame version is not really set probably or this file 
> "RIOT/sys/net/link_layer/ieee802154/ieee802154.c" follows a different FCF 
> format!!
>
> Am I correct or did I misunderstand that?
>
> Ahed
> ________________________________
> From: Aboodi Ahed Hussein Ali
> Sent: Wednesday, November 27, 2019 5:58 AM
> To: RIOT OS developers list <devel@riot-os.org>
> Subject: IEEEE 802.15.4 FCF Format in 
> "RIOT/sys/net/link_layer/ieee802154/ieee802154.c"
>
> Hi all,
>
> I am having a hard time understanding how the "ieee802154_set_frame_hdr" 
> function, found in this link, sets the Frame Control Field (FCF) for 802.15.4 
> frame header.
> Following the IEEE 802.15.4 FCF format, frame version should be at the 
> 12-13th bit of the 2-byte FCF, while in the function code, the frame version 
> was set at the 11th bit. Does it uses different FCF format or am I missing 
> something?
>
> This is the first part of the function:
>
> size_t ieee802154_set_frame_hdr(uint8_t *buf, const uint8_t *src, size_t 
> src_len,
>                                 const uint8_t *dst, size_t dst_len,
>                                 le_uint16_t src_pan, le_uint16_t dst_pan,
>                                 uint8_t flags, uint8_t seq)
> {
>     int pos = 3;    /* 0-1: FCS, 2: seq */
>     uint8_t type = (flags & IEEE802154_FCF_TYPE_MASK);
>
>     buf[0] = flags;
>     buf[1] = IEEE802154_FCF_VERS_V1;          // IEEE802154_FCF_VERS_V1 is 
> defined as 0x10
>
>     if (((src_len != 0) && (src == NULL)) ||
>         ((dst_len != 0) && (dst == NULL))) {
>         return 0;
>     }
> ...
> ...
>
> The first two bytes of the *buf represent the FCF. I would appreciate it if 
> someone explains or provides the FCF format that RIOT-OS uses.
>
> Thank you,
> Ahed
>
> _______________________________________________
> devel mailing list
> devel@riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel
_______________________________________________
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel

Reply via email to