jacdac-ts
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -7,3 +7,3 @@ import { Packet } from "./packet"; | ||
sendPacketAsync: (p: Packet) => Promise<void>; | ||
disconnectAsync: () => Promise<void>; | ||
disconnectAsync?: () => Promise<void>; | ||
} | ||
@@ -74,3 +74,3 @@ export interface PacketEventEmitter { | ||
sendPacketAsync(p: Packet): Promise<void>; | ||
disconnect(): Promise<void>; | ||
disconnectAsync(): Promise<void>; | ||
/** | ||
@@ -77,0 +77,0 @@ * Gets the current list of known devices on the bus |
@@ -12,2 +12,3 @@ export * from './constants'; | ||
export * from './sensor'; | ||
export * from './logparser'; | ||
export * from './pretty'; |
@@ -12,7 +12,1 @@ import { Packet } from "./packet"; | ||
export declare function printPacket(pkt: Packet, opts?: Options): string; | ||
export interface ParsedFrame { | ||
timestamp: number; | ||
data: Uint8Array; | ||
info?: string; | ||
} | ||
export declare function parseLog(logcontents: string): ParsedFrame[]; |
{ | ||
"name": "jacdac-ts", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -7,5 +7,5 @@ # JACDAC TypeScript | ||
The rest of this page is meant developing the jacdac-ts library. | ||
The rest of this page is for developers of the jacdac-ts library. | ||
## Devevelop setup | ||
## Developer setup | ||
@@ -12,0 +12,0 @@ ### Setup |
@@ -9,3 +9,3 @@ import { Packet } from "./packet"; | ||
sendPacketAsync: (p: Packet) => Promise<void>; | ||
disconnectAsync: () => Promise<void>; | ||
disconnectAsync?: () => Promise<void>; | ||
} | ||
@@ -111,3 +111,3 @@ | ||
disconnect(): Promise<void> { | ||
disconnectAsync(): Promise<void> { | ||
if (this._gcInterval) { | ||
@@ -117,3 +117,4 @@ clearInterval(this._gcInterval); | ||
} | ||
return this.options.disconnectAsync() | ||
return (this.options?.disconnectAsync() || Promise.resolve()) | ||
.then(() => { this.emit("disconnect") }) | ||
@@ -120,0 +121,0 @@ } |
@@ -12,2 +12,3 @@ export * from './constants' | ||
export * from './sensor' | ||
export * from './logparser' | ||
export * from './pretty' |
@@ -225,53 +225,1 @@ import * as U from "./utils" | ||
} | ||
export interface ParsedFrame { | ||
timestamp: number | ||
data: Uint8Array | ||
info?: string | ||
} | ||
export function parseLog(logcontents: string) { | ||
const res: ParsedFrame[] = [] | ||
let frameBytes = [] | ||
let lastTime = 0 | ||
for (let ln of logcontents.split(/\r?\n/)) { | ||
let m = /^JD (\d+) ([0-9a-f]+)/i.exec(ln) | ||
if (m) { | ||
res.push({ | ||
timestamp: parseInt(m[1]), | ||
data: U.fromHex(m[2]) | ||
}) | ||
continue | ||
} | ||
m = /^([\d\.]+),Async Serial,.*(0x[A-F0-9][A-F0-9])/.exec(ln) | ||
if (!m) | ||
continue | ||
const tm = parseFloat(m[1]) | ||
if (lastTime && tm - lastTime > 0.1) { | ||
res.push({ | ||
timestamp: lastTime * 1000, | ||
data: new Uint8Array(frameBytes), | ||
info: "timeout" | ||
}) | ||
frameBytes = [] | ||
lastTime = 0 | ||
} | ||
lastTime = tm | ||
if (ln.indexOf("framing error") > 0) { | ||
if (frameBytes.length > 0) | ||
res.push({ | ||
timestamp: lastTime * 1000, | ||
data: new Uint8Array(frameBytes), | ||
}) | ||
frameBytes = [] | ||
lastTime = 0 | ||
} else { | ||
frameBytes.push(parseInt(m[2])) | ||
} | ||
} | ||
return res | ||
} | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
504274
38
6743