-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: new driver for at86rf2xx radios #2825
Conversation
endif | ||
ifneq (,$(filter ng_at86rf212b,$(USEMODULE))) | ||
USEMODULE += ng_at86rf2xx | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pattern matching: ifneq (,$(filter ng_at86rf2%,$(USEMODULE)))
@haukepetersen, Great job! How do you add each driver "specialities"? By some EDIT: I see you added some |
@Kijewski good point, will fix, thx @bapclenet Actually I am not sure, yet. @thomaseichinger and my initial idea was actually to find a way, so you could run say an |
I see. If we use both transceiver at the same time, we will have two net interfaces,won't we? And then send a message will require to select the interface. Why do we need |
For my network driver interface, I usually have a But for initial merge, I'd say compile-time device selection is fine. |
minor update, now communication between the |
Between two samr21 (AT86RF233), I can transmit packets by short addresses but not with long ones. |
yapp, I have the same behavior here, will look into it today. |
buf[pos++] = (uint8_t)((dev->addr_long) >> 8); | ||
buf[pos++] = (uint8_t)((dev->addr_long) & 0xff); | ||
} | ||
/* unsupported address length */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function doesn't handle broadcast case (hdr->dst_l2addr_len==0 && (hdr->flags & NG_NETIF_HDR_FLAGS_BROADCAST)
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(should also (hdr->flags & NG_NETIF_HDR_FLAGS_MULTICAST)
in the same manner)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is on the TODO list :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a
if (hdr->flags == (NG_NETIF_HDR_FLAGS_BROADCAST | NG_NETIF_HDR_FLAGS_MULTICAST))) {
/* set FCF */
buf[pos++] = 0xff;
buf[pos++] = 0xff;
}
;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one question: is the broadcast address always the short address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 802.15.4 standard only defines the short address (0xffff) as broadcast address, so yes.
The Destination Address field, when present, specifies the address of the intended recipient of the frame. A
value of 0xffff in this field shall represent the broadcast short address, which shall be accepted as a valid
address by all devices currently listening to the channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IETF documents also only speak about 0xffff as broadcast address for IEEE 802.15.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not even sure there is any EUI-64 defined for broadcast. Only thing in that direction I know of is, that the least significant bit of the first byte (0x01
) signifies unicast/multicast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but since IEEE 802.15.4 does not support multicast, this is out of scope ;-))
Is this driver supposed to work with the 212b? |
updated driver, handling of long addresses should work now (tested with 231, 233 and against xbee device). |
The old driver worked with 212b, so this one should work (this is the aim of the driver). |
@kaspar030: handling of broadcast addresses is not implemented, yet. In general the driver is also supposed to work with the |
/* default to compress pan TODO: provide means to specify src PAN*/ | ||
buf[0] |= NG_IEEE802154_FCF_PAN_COMP; | ||
if (hdr->dst_l2addr_len == 2) { | ||
/* default to 2 byte addresses for src and dst */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to take NETCONF_OPT_SRC_LEN
for the length of the source address.
When executing The reason was the uninitialized netif. From where should When calling Will test against linux tomorrow. |
@Jremmert-phytec-iot, which example did youuse to make the ´samr21-xpro´ go to ´isr_hard_fault()´ ? |
@bapclenet, I used the one hauke provided (tests/driver_at86rf2xx) goes to isr_hard_fault. If the mac layer wants to register its kernel_pid int ng_netif_add(kernel_pid_t pid)
{
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
if (ifs[i] == pid) { /* avoid duplicates */
return 0;
}
/* registering fails here because ifs[i] !== KERNEL_PID_UNDEF, although it should be.
* So nothing will be assigned to ifs[i]. In my case it remains at 14578 or so ;).
* When I add a call to the initialization function, the correct MAC kernel_pid (5)
* gets assigned. */
else if (ifs[i] == KERNEL_PID_UNDEF) {
ifs[i] = pid;
for (int j = 0; if_handler[j].add != NULL; j++) {
if_handler[j].add(pid);
}
return 0;
}
}
return -ENOMEM;
} I have no idea why it worked for you without the initialization. Maybe the uninitialized value of ifs[i] was 0 ( KERNEL_PID_UNDEF)? Maybe I have missed something fundamental? |
@jremmert-phytec-iot, I've got the same configuration, and pid is 5 for me. |
@jremmert-phytec-iot it seems that you have another interface registered. Does it work if you set a higher @bapclenet It should work without |
At the very least: |
Ok, it is clear that As test setup I just checked out the latest master, applied this PR and flashed this test application. So, there should not be any other interfaces. Also When setting a breakpoint to
I investigated a bit more. The memory address of ifs[0] is written to 0 in I assume that ifs[0] is initialized after all this, in main thread-context, but is it initialized with 0 then? So, initialize netif once after the startup procedure would solve this problem. |
Check for |
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis complains here
Missed something like
/**
* @brief IEEE 802.14.4 header definitions
* @{
*/
/ * * @} */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ups, must have overlooked that one... fixed.
c9e85c7
to
9390c86
Compare
fixed named issues and rebased and squashed. Travis should now be happy. |
9390c86
to
ca75e5b
Compare
Great! |
Seems Travis is broken once more... |
@haukepetersen please rebase. #2873 fixed the issue. |
ca75e5b
to
4e121e1
Compare
rebased. |
} | ||
} | ||
|
||
size_t ng_at86rf2xx_rx_len(ng_at86rf2xx_t *dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Page 946 of the datasheet (SAM R21) states, that the MSB should be masked for 802.15.4 compliance. Shouldn't this be done here?
On reception, the PHR is returned as the first octet during Frame Buffer read access. While the IEEE 802.15.4-2006 standard declares bit seven of the PHR octet as being reserved, the AT86RF233 preserves this bit upon transmission and reception so it can be used to carry additional information within proprietary networks. Nevertheless, this bit is not considered to be a part of the frame length, so only frames between one and 127 octets are possible. For IEEE 802.15.4 compliant operation bit [7] has to be masked by software.
EDIT: My comment refers to size_t ng_at86rf2xx_rx_len(ng_at86rf2xx_t *dev)
of course. I wasn't aware of how GitHub is displaying line comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That paragraph I have not read before, so you are right that masking the bit is a good idea. As long as we have RIOT devices only (with the same driver), it should not be an issue for now, though. So again: Lets fix this after this PR is merged.
Travis complained about the label need squashing. Let Travis work and this PR should be fine for merging. |
Can't restart. Let's wait until the H&A if something happens, otherwise let's merge it than |
Ok, if the label was the only thing Travis complained about, I say: Let's merge this now! |
Yeah, let's merge it. |
drivers: new driver for at86rf2xx radios
Great! :-) |
if (max_len < sizeof(int16_t)) { | ||
return -EOVERFLOW; | ||
} | ||
*((uint16_t *)val) = NG_AT86RF2XX_MAX_PKT_LENGTH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are returning the full 802.15.4 packet length here without taking care of the 802.15.4 header that also has to be appended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @haukepetersen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bapclenet I opened issue #3086 for that discussion
this PR is the continuation of @thomaseichinger's work started in #2650.
Tested (and working) with theiot-lab_M3
(at86rf321
). With theiot-lab_M3
it should be possible with this PR at the current state to run the new network stack -> happy testing :-)Update: driver should be stable with
iot-lab_M3
andsamr21-xpro
- also tested successfully against the Xbee S1 and validated packets against Wireshark.Receiving also works with thesamr32-xpro
(at86rf233
), here the sending still has problems -> will fix this next week.I heavily restructured the code again -> the goal was to separate the drivers internals from the 'netdev' adaption to a large extend. This is not completely clean -> especially when receiving data there are still some fixed references into
netdev
...Some more known issues:
enabling/disabling of AUTOACK, CSMA, PROMISCUOUS-Mode is missinga lot of doxygen documentation is missingsome doxygen is still wrong (copy/paste)probably more...