Skip to content

Commit b5329af

Browse files
committed
Recieves with long delay and lacks cb
1 parent 0172e2f commit b5329af

File tree

7 files changed

+16
-20
lines changed

7 files changed

+16
-20
lines changed

lfc/core/src/main/kotlin/org/lflang/generator/uc/UcNetworkChannel.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,15 @@ class UcCoapUdpIpChannel(
398398
class UcS4NocChannel(
399399
src: UcS4NocEndpoint,
400400
dest: UcS4NocEndpoint,
401-
serverLhs: Boolean = true,
402-
) : UcNetworkChannel(S4NOC, src, dest, serverLhs) {
401+
) : UcNetworkChannel(S4NOC, src, dest, false) {
403402
private val srcS4Noc = src
404403
private val destS4Noc = dest
405404

406405
override fun generateChannelCtorSrc() =
407-
"S4NOCPollChannel_ctor(&self->channel, ${if (serverLhs) srcS4Noc.core else destS4Noc.core});"
406+
"S4NOCPollChannel_ctor(&self->channel, ${srcS4Noc.core});"
408407

409408
override fun generateChannelCtorDest() =
410-
"S4NOCPollChannel_ctor(&self->channel, ${if (serverLhs) srcS4Noc.core else destS4Noc.core});"
409+
"S4NOCPollChannel_ctor(&self->channel, ${destS4Noc.core});"
411410

412411
override val codeType: String
413412
get() = "S4NOCPollChannel"

make/patmos/patmos.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ CFLAGS += -Wall -Wextra
3434
CFLAGS += -DPLATFORM_PATMOS
3535
CFLAGS += -DNETWORK_CHANNEL_S4NOC
3636
CFLAGS += -DSCHEDULER_DYNAMIC
37-
CFLAGS += -DFEDERATED
37+
CFLAGS += -DFEDERATED
38+
CFLAGS += -DLF_LOG_LEVEL_ALL=LF_LOG_LEVEL_DEBUG

src/platform/patmos/patmos.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <stdbool.h>
44
#include <string.h>
55
#include <reactor-uc/environment.h>
6+
#include "reactor-uc/logging.h"
67

78
#include <machine/rtc.h>
89
#include <machine/exceptions.h>
@@ -20,21 +21,13 @@ instant_t PlatformPatmos_get_physical_time(Platform *super) {
2021

2122
lf_ret_t PlatformPatmos_wait_until_interruptible(Platform *super, instant_t wakeup_time) {
2223
PlatformPatmos *self = (PlatformPatmos *)super;
23-
self->async_event = false;
2424

2525
instant_t now = super->get_physical_time(super);
2626

2727
// Do busy sleep
2828
do {
2929
now = super->get_physical_time(super);
30-
} while ((now < wakeup_time) && !self->async_event);
31-
32-
if (self->async_event) {
33-
self->async_event = false;
34-
return LF_ERR;
35-
} else {
36-
return LF_OK;
37-
}
30+
} while (now < wakeup_time);
3831

3932
interval_t sleep_duration = wakeup_time - super->get_physical_time(super);
4033
if (sleep_duration < 0) {
@@ -96,6 +89,7 @@ void Platform_ctor(Platform *super) {
9689
super->wait_until_interruptible = PlatformPatmos_wait_until_interruptible;
9790
super->notify = PlatformPatmos_notify;
9891
self->num_nested_critical_sections = 0;
92+
LF_DEBUG(PLATFORM, "PlatformPatmos initialized");
9993
}
10094

10195
Platform *Platform_new(void) {

src/platform/patmos/s4noc_channel.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ static lf_ret_t S4NOCPollChannel_send_blocking(NetworkChannel *untyped_self, con
4545
*((int *)self->write_buffer) = message_size;
4646
S4NOC_CHANNEL_DEBUG("S4NOCPollChannel_send_blocking: message size: ((%d)).", message_size);
4747
int total_size = message_size + 4;
48+
S4NOC_CHANNEL_DEBUG("Total size to send: ((%d))", total_size);
49+
4850
*s4noc_dest = self->destination_core;
4951
int bytes_send = 0;
5052
while (bytes_send < total_size) {
@@ -62,7 +64,7 @@ static void S4NOCPollChannel_register_receive_callback(NetworkChannel *untyped_s
6264
void (*receive_callback)(FederatedConnectionBundle *conn,
6365
const FederateMessage *msg),
6466
FederatedConnectionBundle *conn) {
65-
// S4NOC_CHANNEL_INFO("Register receive callback at %p", receive_callback);
67+
S4NOC_CHANNEL_INFO("Register receive callback at %p", receive_callback);
6668
S4NOCPollChannel *self = (S4NOCPollChannel *)untyped_self;
6769

6870
self->receive_callback = receive_callback;
@@ -98,15 +100,16 @@ void S4NOCPollChannel_poll(NetworkChannel *untyped_self) {
98100
receive_channel->receive_buffer + 4, // skip the 4-byte size header
99101
expected_message_size // only the message payload
100102
);
103+
// bytes_left = ((bytes_left / 4)+1) * 4;
101104
// S4NOC_CHANNEL_DEBUG("Bytes Left after attempted to deserialize: %d", bytes_left);
102105

103106
if (bytes_left >= 0) {
104107
receive_channel->receive_buffer_index = bytes_left;
105108
if (receive_channel->receive_callback != NULL) {
106-
// S4NOC_CHANNEL_DEBUG("calling user callback at %p!", receive_channel->receive_callback);
109+
S4NOC_CHANNEL_DEBUG("calling user callback at %p!", receive_channel->receive_callback);
107110
receive_channel->receive_callback(self->federated_connection, &receive_channel->output);
108111
} else {
109-
// S4NOC_CHANNEL_WARN("No receive callback registered, dropping message");
112+
S4NOC_CHANNEL_WARN("No receive callback registered, dropping message");
110113
}
111114
}
112115
}

src/schedulers/dynamic/scheduler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ void Scheduler_run(Scheduler *untyped_self) {
298298
}
299299

300300
if (env->poll_network_channels) {
301+
LF_DEBUG(SCHED, "Polling network channels");
301302
env->poll_network_channels(env);
302303
}
303304

test/platform/patmos/s4noc_channel_test/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ BUILD_DIR = $(CURDIR)/build
99
# Source files
1010
SOURCES += $(SRC_DIR)/$(APP).c
1111

12-
CFLAGS += -DLF_LOG_LEVEL_ALL=LF_LOG_LEVEL_DEBUG
13-
1412
# Output binary
1513
OUTPUT = $(BUILD_DIR)/$(APP).elf
1614
all : $(OUTPUT)

test/platform/patmos/s4noc_channel_test/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define MESSAGE_CONNECTION_ID 42
99
#define SOURCE_CORE 1
1010
#define DESTINATION_CORE 2
11-
#define MAX_TRIES 10
11+
#define MAX_TRIES 20
1212

1313
Reactor parent;
1414
FederatedEnvironment fed_env;

0 commit comments

Comments
 (0)