-
Notifications
You must be signed in to change notification settings - Fork 1
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
LFC federated RIOT fixes #192
Changes from 68 commits
0584253
6b51697
55b308a
a8973e8
cfda3bd
2c38b98
68e8d11
60ceeea
2704dbd
5ba1392
a8bc451
ead4a67
ddbed66
aec7438
d0b4e22
8efd065
c049c73
991264a
43874dd
3689883
9eb722d
d5e95fe
9b63d84
2f9c0f4
03a428c
c7dde4f
f910e5e
841549f
d3173cf
dd61844
42fc1ad
9fee19b
97bb16a
d56ce51
e2176a2
7b49934
6b5e91d
9e79137
8d51127
b906004
ef9f980
05d7d87
42166cd
7d43526
b11b5b8
c3d1d74
66c6cc9
2b7fb24
c9e949f
fac8be9
07c23a9
f2b95fa
d87c6a4
1ff975f
90f63c5
1098b34
7c59706
2f2d634
012e8b3
f10ed77
d3717ce
bc2d9a4
81fbc1b
6ea9cad
000794e
e314279
823b923
56c2996
64b6bd4
1d10fd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
make all |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
REMOTE_ADDRESS=fe80::8cc3:33ff:febb:1b3 make all -C ./sender | ||
REMOTE_ADDRESS=fe80::8cc3:33ff:febb:1b3 make all -C ./receiver | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
REACTOR_UC_PATH ?= $(CURDIR)/../../../ | ||
|
||
# The name of the LF application inside "./src" to build/run/flash etc. | ||
LF_MAIN ?= CoapFederatedLF | ||
FEDERATION ?= r1 | ||
|
||
# Execute the LF compiler if build target is "all" | ||
ifeq ($(firstword $(MAKECMDGOALS)),all) | ||
_ := $(shell $(REACTOR_UC_PATH)/lfc/bin/lfc-dev src/$(LF_MAIN).lf) | ||
endif | ||
|
||
# ---- RIOT specific configuration ---- | ||
# This has to be the absolute path to the RIOT base directory: | ||
RIOTBASE ?= $(CURDIR)/../../../../RIOT | ||
|
||
# If no BOARD is found in the environment, use this default: | ||
BOARD ?= native | ||
|
||
# Comment this out to disable code in RIOT that does safety checking | ||
# which is not needed in a production environment but helps in the | ||
# development process: | ||
DEVELHELP ?= 1 | ||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 1 | ||
|
||
# Enable reactor-uc features | ||
CFLAGS += -DNETWORK_CHANNEL_COAP_RIOT | ||
|
||
# Configure CoAP retransmission timeout | ||
CFLAGS += -DCONFIG_GCOAP_NO_RETRANS_BACKOFF=1 | ||
CFLAGS += -DCONFIG_COAP_ACK_TIMEOUT_MS=400 | ||
CFLAGS += -DCONFIG_COAP_MAX_RETRANSMIT=4 | ||
|
||
include $(REACTOR_UC_PATH)/make/riot/riot-lfc.mk |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
FEDERATION=r1 make all | ||
FEDERATION=r2 make all |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
target uC { | ||
platform: RIOT, | ||
timeout: 1sec | ||
} | ||
|
||
reactor Src(id: int = 0) { | ||
output out: int | ||
reaction(startup) -> out{= | ||
printf("Hello from Src!\n"); | ||
lf_set(out, self->id); | ||
=} | ||
} | ||
|
||
reactor Dst { | ||
input in: int | ||
state check: bool = false | ||
reaction(startup) {= | ||
printf("Hello from Dst!\n"); | ||
=} | ||
reaction(in) {= | ||
printf("Received %d from Src\n", in->value); | ||
validate(in->value == 42); | ||
self->check = true; | ||
env->request_shutdown(env); | ||
=} | ||
|
||
reaction(shutdown) {= | ||
validate(self->check); | ||
=} | ||
} | ||
|
||
federated reactor { | ||
@interface_coap(name="if1", address="fe80::44e5:1bff:fee4:dac8") | ||
r1 = new Src(id=42) | ||
|
||
@interface_coap(name="if1", address="fe80::8cc3:33ff:febb:1b3") | ||
r2 = new Dst() | ||
|
||
@link(left="if1", right="if1") | ||
r1.out -> r2.in | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
make all |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
make all |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,7 +206,7 @@ abstract class UcNetworkChannel( | |
COAP_UDP_IP -> { | ||
val srcEp = (srcIf as UcCoapUdpIpInterface).createEndpoint() | ||
val destEp = (destIf as UcCoapUdpIpInterface).createEndpoint() | ||
channel = UcCoapUdpIpChannel(srcEp, destEp, serverLhs) | ||
channel = UcCoapUdpIpChannel(srcEp, destEp) | ||
} | ||
|
||
CUSTOM -> { | ||
|
@@ -242,17 +242,24 @@ class UcTcpIpChannel( | |
class UcCoapUdpIpChannel( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this homogeneous enough that one code-generator class works potentially for all platforms? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will find out when we add support for native and Zephyr |
||
src: UcCoapUdpIpEndpoint, | ||
dest: UcCoapUdpIpEndpoint, | ||
serverLhs: Boolean = true, | ||
) : UcNetworkChannel(COAP_UDP_IP, src, dest, serverLhs) { | ||
private val srcAddr = src.ipAddress.address | ||
private val destAddr = dest.ipAddress.address | ||
// TODO: In CoAP every node is a server and a client => default server to false for now | ||
) : UcNetworkChannel(COAP_UDP_IP, src, dest, false) { | ||
private val srcAddr = src | ||
private val destAddr = dest | ||
|
||
private fun getIpProtocolFamily(ip: IPAddress): String { | ||
return when (ip) { | ||
is IPAddress.IPv4 -> "AF_INET" | ||
is IPAddress.IPv6 -> "AF_INET6" | ||
else -> throw IllegalArgumentException("Unknown IP address type") | ||
} | ||
} | ||
|
||
override fun generateChannelCtorSrc() = | ||
"CoapUdpIpChannel_ctor(&self->channel, \"${if (serverLhs) srcAddr else destAddr}\", AF_INET, ${serverLhs});" | ||
"CoapUdpIpChannel_ctor(&self->channel, \"${destAddr.ipAddress.address}\", ${getIpProtocolFamily(destAddr.ipAddress)});" | ||
|
||
override fun generateChannelCtorDest() = | ||
"CoapUdpIpChannel_ctor(&self->channel, \"${if (serverLhs) srcAddr else destAddr}\" AF_INET, ${!serverLhs});" | ||
|
||
"CoapUdpIpChannel_ctor(&self->channel, \"${srcAddr.ipAddress.address}\", ${getIpProtocolFamily(srcAddr.ipAddress)});" | ||
|
||
override val codeType: String | ||
get() = "CoapUdpIpChannel" | ||
|
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 decided to add
build.sh
files to all riot examples, because a simplemake all
does not always work. Especially if you also want to build both federations.Instead of making the
runAll.sh
file complicated with different commands per project I let it run build.sh in each folder it can find. This will also prevent the bug that thecoap_federated
example wasn't build in the CI because I forgot to add it tobuildAll.sh
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.
Sounds reasonable. We must find a good way to build federated programs. Your current proposal, with a single Makefile, works now. But I think in the future we want independent projects for each federate because there might several difference between the boards, and their configuration.
Two questions:
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.
Ah sorry github showed me this comment at the bottom and I replied in the main thread and not directly to this comment