move diagnostics out of routing
This commit is contained in:
Родитель
6de5f97676
Коммит
948abfe4c2
|
@ -0,0 +1,31 @@
|
|||
namespace jacdac {
|
||||
/**
|
||||
* Gets the internal diagnostics data from the JACDAC transport layer
|
||||
*/
|
||||
export function diagnostics(): jacdac.JDDiagnostics {
|
||||
return new jacdac.JDDiagnostics(jacdac.__physGetDiagnostics());
|
||||
}
|
||||
|
||||
export class JDDiagnostics {
|
||||
busState: number;
|
||||
busLoError: number;
|
||||
busUartError: number;
|
||||
busTimeoutError: number;
|
||||
packetsSent: number;
|
||||
packetsReceived: number;
|
||||
packetsDropped: number;
|
||||
|
||||
constructor(buf: Buffer) {
|
||||
if (!buf) return;
|
||||
[
|
||||
this.busState,
|
||||
this.busLoError,
|
||||
this.busUartError,
|
||||
this.busTimeoutError,
|
||||
this.packetsSent,
|
||||
this.packetsReceived,
|
||||
this.packetsDropped
|
||||
] = jdunpack<number[]>(buf, "u32 u32 u32 u32 u32 u32 u32")
|
||||
}
|
||||
}
|
||||
}
|
1
pxt.json
1
pxt.json
|
@ -28,6 +28,7 @@
|
|||
"service.ts",
|
||||
"pipes.ts",
|
||||
"actuator.ts",
|
||||
"diagnostics.ts",
|
||||
"ns.ts",
|
||||
"system/constants.ts",
|
||||
"base/constants.ts",
|
||||
|
|
28
routing.ts
28
routing.ts
|
@ -879,32 +879,4 @@ namespace jacdac {
|
|||
});
|
||||
loggerHost.start()
|
||||
}
|
||||
|
||||
export function diagnostics(): jacdac.JDDiagnostics {
|
||||
return new jacdac.JDDiagnostics(jacdac.__physGetDiagnostics());
|
||||
}
|
||||
|
||||
export class JDDiagnostics {
|
||||
bus_state: number;
|
||||
bus_lo_error: number;
|
||||
bus_uart_error: number;
|
||||
bus_timeout_error: number;
|
||||
packets_sent: number;
|
||||
packets_received: number;
|
||||
packets_dropped: number;
|
||||
|
||||
constructor(buf: Buffer) {
|
||||
if (!buf) return;
|
||||
|
||||
[
|
||||
this.bus_state,
|
||||
this.bus_lo_error,
|
||||
this.bus_uart_error,
|
||||
this.bus_timeout_error,
|
||||
this.packets_sent,
|
||||
this.packets_received,
|
||||
this.packets_dropped
|
||||
] = pins.unpackBuffer("7I", buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче