printing debug messages to serial only
This commit is contained in:
@@ -120,3 +120,22 @@ pub const Console = struct {
|
||||
while (x < self.fb.width) : (x += 1) dst[x] = src[x];
|
||||
}
|
||||
};
|
||||
|
||||
pub const SerialConsole = struct {
|
||||
/// Serial-only output: goes to the machine-readable log but *not* the framebuffer,
|
||||
/// so debug and test detail stays out of the on-screen console. These are free
|
||||
/// functions, not `Console` methods, because serial has no dependency on the
|
||||
/// framebuffer — they work even before `con` is initialised.
|
||||
pub fn debugWrite(bytes: []const u8) void {
|
||||
arch.serialWrite(bytes);
|
||||
}
|
||||
|
||||
/// Formatted serial-only output, e.g. `debugPrint("x={d}\n", .{x})`. Truncates
|
||||
/// past 256 bytes, like `Console.print`.
|
||||
pub fn debugPrint(comptime fmt: []const u8, args: anytype) void {
|
||||
var buf: [256]u8 = undefined;
|
||||
debugWrite(std.fmt.bufPrint(&buf, fmt, args) catch return);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user