From d2778d820e37365e40e6e6bba9a7dd0889d40168 Mon Sep 17 00:00:00 2001 From: Gavin-Niederman Date: Sun, 17 Dec 2023 20:40:46 -0800 Subject: [PATCH] feat: panic messages printed to pros terminal --- pros/src/vexos_env.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pros/src/vexos_env.rs b/pros/src/vexos_env.rs index 66ceb1e5..c567b93d 100644 --- a/pros/src/vexos_env.rs +++ b/pros/src/vexos_env.rs @@ -1,3 +1,5 @@ +use alloc::format; + use crate::println; use core::{ alloc::{GlobalAlloc, Layout}, @@ -7,6 +9,10 @@ use core::{ #[panic_handler] pub fn panic(_info: &PanicInfo) -> ! { println!("Panicked! {_info}"); + let panic_message = alloc::ffi::CString::new(format!("Panicked! {}", _info)).unwrap(); + unsafe { + pros_sys::puts(panic_message.as_ptr()); + } let panicking_task = crate::task::current(); // Make sure we eat up every cycle to stop execution panicking_task.set_priority(crate::task::TaskPriority::High);