Skip to content

Commit

Permalink
adding more diag possibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciscoLlobet committed Feb 25, 2024
1 parent cdac376 commit a9e153f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
20 changes: 19 additions & 1 deletion src/connection.zig
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ fn run(self: *@This()) noreturn {
//Ignore
}

var waiting_count: usize = 0;
if (res > 0) {
if (read_set_ptr) |read_set| {
for (&self.connections) |*conn| {
Expand All @@ -253,12 +254,29 @@ fn run(self: *@This()) noreturn {
conn.sd = -1;
conn.rx_wait_deadline_ms = 0;
conn.rx_signal.give() catch unreachable;
} else {
waiting_count += 1;
}
}
}
}
} else if (res == 0) {
if (read_set_ptr) |_| {
for (&self.connections) |*conn| {
if (conn.sd >= 0) {
waiting_count += 1;
}
}
}

// self.task.delayTask(10);
} else {
self.task.delayTask(10);
// Error
@breakpoint();
}

if (waiting_count > 0) {
self.task.delayTask(100);
}
} else {
// no deadlines
Expand Down
7 changes: 5 additions & 2 deletions src/user.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ ntpSyncTime: u32,
/// User Statemachine state
state: state,

timerWatermark: usize,

const ntpUri = "ntp://1.de.pool.ntp.org:123";

fn myTimerFunction(self: *@This()) void {
self.timerWatermark = freertos.Task.initFromCurrentTask().getStackHighWaterMark();
self.task.notify(@intFromEnum(notificationValues.user_timer), .eSetBits) catch {};
}

Expand Down Expand Up @@ -201,7 +204,7 @@ fn myUserTaskFunction(self: *@This()) noreturn {
self.state = .working;
} else if (notificationValues.isNotification(val, notificationValues.user_timer)) {
leds.yellow.toggle();
_ = c.printf("UserTimer: %d\r\n", self.task.getStackHighWaterMark());
_ = c.printf("UserTimer: %d, Timer: %d\r\n", self.task.getStackHighWaterMark(), self.timerWatermark);
self.state = .working;
}
}
Expand Down Expand Up @@ -230,4 +233,4 @@ pub fn create(self: *@This()) void {
self.ntpSyncTime = 0;
}

pub var user_task: @This() = .{ .timer = undefined, .state = undefined, .task = undefined, .ntpTimer = undefined, .ntpSyncTime = 0 };
pub var user_task: @This() = .{ .timer = undefined, .state = undefined, .task = undefined, .ntpTimer = undefined, .ntpSyncTime = 0, .timerWatermark = 0 };

0 comments on commit a9e153f

Please sign in to comment.