Skip to content

Commit 6baa38b

Browse files
committed
use new APIs from #2225
1 parent e50fd19 commit 6baa38b

File tree

3 files changed

+45
-48
lines changed

3 files changed

+45
-48
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

drv/psc-seq-server/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ drv-stm32xx-sys-api = { path = "../../drv/stm32xx-sys-api", features = ["family-
1010
drv-i2c-api = { path ="../../drv/i2c-api", features = ["component-id"] }
1111
drv-i2c-devices.path = "../../drv/i2c-devices"
1212
task-jefe-api.path = "../../task/jefe-api"
13-
task-packrat-api.path = "../../task/packrat-api"
13+
task-packrat-api = { path = "../../task/packrat-api", features = ["serde"] }
1414
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }
1515
ringbuf = { path = "../../lib/ringbuf", features = ["counters"] }
1616
counters = { path = "../../lib/counters" }
1717
static-cell = { path = "../../lib/static-cell" }
1818
serde.workspace = true
19-
minicbor.workspace = true
20-
minicbor-serde.workspace = true
2119

2220
[build-dependencies]
2321
idol.workspace = true

drv/psc-seq-server/src/main.rs

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,21 @@ enum Trace {
250250
psu: Slot,
251251
err: mwocp68::Error,
252252
},
253-
EreportSentOff {
253+
EreportSent {
254254
now: u64,
255255
#[count(children)]
256256
psu: Slot,
257257
class: ereport::Class,
258258
len: usize,
259259
},
260+
EreportLost {
261+
now: u64,
262+
#[count(children)]
263+
psu: Slot,
264+
class: ereport::Class,
265+
len: usize,
266+
err: task_packrat_api::EreportWriteError,
267+
},
260268
EreportTooBig {
261269
now: u64,
262270
#[count(children)]
@@ -671,7 +679,41 @@ fn main() -> ! {
671679
}
672680
}
673681
if let Some(ereport) = step.ereport {
674-
ereport.deliver(&packrat, now, ereport_buf);
682+
match packrat.serialize_ereport(&ereport, &mut ereport_buf[..])
683+
{
684+
Ok(len) => ringbuf_entry!(
685+
__TRACE,
686+
Trace::EreportSent {
687+
now,
688+
psu: ereport.psu_slot,
689+
len,
690+
class: ereport.class,
691+
}
692+
),
693+
Err(task_packrat_api::EreportSerializeError::Packrat {
694+
err,
695+
len,
696+
}) => ringbuf_entry!(
697+
__TRACE,
698+
Trace::EreportLost {
699+
now,
700+
psu: ereport.psu_slot,
701+
len,
702+
class: ereport.class,
703+
err,
704+
}
705+
),
706+
Err(
707+
task_packrat_api::EreportSerializeError::Serialize(_),
708+
) => ringbuf_entry!(
709+
__TRACE,
710+
Trace::EreportTooBig {
711+
now,
712+
psu: ereport.psu_slot,
713+
class: ereport.class,
714+
}
715+
),
716+
}
675717
}
676718
}
677719

@@ -1153,47 +1195,6 @@ mod ereport {
11531195
pub(super) pmbus_status: Option<PmbusStatus>,
11541196
}
11551197

1156-
impl Ereport {
1157-
#[inline(never)]
1158-
pub(super) fn deliver(
1159-
&self,
1160-
packrat: &Packrat,
1161-
now: u64,
1162-
buf: &mut [u8],
1163-
) {
1164-
let writer = minicbor::encode::write::Cursor::new(buf);
1165-
let mut s = minicbor_serde::Serializer::new(writer);
1166-
match self.serialize(&mut s) {
1167-
Ok(_) => {
1168-
let writer = s.into_encoder().into_writer();
1169-
let len = writer.position();
1170-
let buf = writer.into_inner();
1171-
packrat.deliver_ereport(&buf[..len]);
1172-
ringbuf_entry!(
1173-
__TRACE,
1174-
Trace::EreportSentOff {
1175-
now,
1176-
psu: self.psu_slot,
1177-
class: self.class,
1178-
len,
1179-
}
1180-
);
1181-
}
1182-
Err(_) => {
1183-
// XXX(eliza): ereport didn't fit in buffer...what do
1184-
ringbuf_entry!(
1185-
__TRACE,
1186-
Trace::EreportTooBig {
1187-
now,
1188-
psu: self.psu_slot,
1189-
class: self.class
1190-
}
1191-
);
1192-
}
1193-
}
1194-
}
1195-
}
1196-
11971198
#[derive(Copy, Clone, Default, Serialize)]
11981199
pub(super) struct PmbusStatus {
11991200
pub(super) word: Option<u16>,

0 commit comments

Comments
 (0)