File tree Expand file tree Collapse file tree 5 files changed +12
-15
lines changed
Expand file tree Collapse file tree 5 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616### Fixed
1717
1818- Fixed printing panic backtraces when using ` esp-println ` and ` defmt ` (#496 )
19+ - Fixed defmt parsing when data is read in parts (#503 )
1920
2021### Changed
2122
Original file line number Diff line number Diff line change @@ -99,6 +99,11 @@ pub fn monitor_with(
9999 let stdout = stdout ( ) ;
100100 let mut stdout = ResolvingPrinter :: new ( elf, stdout. lock ( ) ) ;
101101
102+ let mut parser: Box < dyn InputParser > = match log_format {
103+ LogFormat :: Defmt => Box :: new ( parser:: esp_defmt:: EspDefmt :: new ( elf) ) ,
104+ LogFormat :: Serial => Box :: new ( parser:: serial:: Serial ) ,
105+ } ;
106+
102107 let mut buff = [ 0 ; 1024 ] ;
103108 loop {
104109 let read_count = match serial. serial_port_mut ( ) . read ( & mut buff) {
@@ -108,16 +113,7 @@ pub fn monitor_with(
108113 err => err,
109114 } ?;
110115
111- match log_format {
112- LogFormat :: Defmt => {
113- let mut parser = parser:: esp_defmt:: EspDefmt :: new ( elf) ;
114- parser. feed ( & buff[ 0 ..read_count] , & mut stdout) ;
115- }
116- LogFormat :: Serial => {
117- let mut parser = parser:: serial:: Serial ;
118- parser. feed ( & buff[ 0 ..read_count] , & mut stdout) ;
119- }
120- }
116+ parser. feed ( & buff[ 0 ..read_count] , & mut stdout) ;
121117
122118 // Don't forget to flush the writer!
123119 stdout. flush ( ) . ok ( ) ;
Original file line number Diff line number Diff line change @@ -106,11 +106,11 @@ impl EspDefmt {
106106 }
107107 }
108108
109- fn handle_raw ( bytes : & [ u8 ] , out : & mut impl Write ) {
109+ fn handle_raw ( bytes : & [ u8 ] , out : & mut dyn Write ) {
110110 out. write_all ( bytes) . unwrap ( ) ;
111111 }
112112
113- fn handle_defmt ( frame : Frame < ' _ > , out : & mut impl Write ) {
113+ fn handle_defmt ( frame : Frame < ' _ > , out : & mut dyn Write ) {
114114 match frame. level ( ) {
115115 Some ( level) => {
116116 let color = match level {
@@ -142,7 +142,7 @@ impl EspDefmt {
142142}
143143
144144impl InputParser for EspDefmt {
145- fn feed ( & mut self , bytes : & [ u8 ] , out : & mut impl Write ) {
145+ fn feed ( & mut self , bytes : & [ u8 ] , out : & mut dyn Write ) {
146146 let Some ( table) = self . table . as_mut ( ) else {
147147 Self :: handle_raw ( bytes, out) ;
148148 return ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use regex::Regex;
1313use crate :: cli:: monitor:: { line_endings:: normalized, symbols:: Symbols } ;
1414
1515pub trait InputParser {
16- fn feed ( & mut self , bytes : & [ u8 ] , out : & mut impl Write ) ;
16+ fn feed ( & mut self , bytes : & [ u8 ] , out : & mut dyn Write ) ;
1717}
1818
1919// Pattern to much a function address in serial output.
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use crate::cli::monitor::parser::InputParser;
55pub struct Serial ;
66
77impl InputParser for Serial {
8- fn feed ( & mut self , bytes : & [ u8 ] , out : & mut impl Write ) {
8+ fn feed ( & mut self , bytes : & [ u8 ] , out : & mut dyn Write ) {
99 out. write_all ( bytes) . unwrap ( ) ;
1010 }
1111}
You can’t perform that action at this time.
0 commit comments