(input: string | Buffer)
| 265 | } |
| 266 | |
| 267 | public writeBinary(input: string | Buffer) { |
| 268 | const data: Buffer = Buffer.from(input); |
| 269 | const timestamp = this.hrTimer.createDateTimestamp(); |
| 270 | for (const chr of data) { |
| 271 | this.buffer[this.bytesRead] = chr; |
| 272 | this.bytesRead = this.bytesRead + 1; |
| 273 | if (this.bytesRead === this.bytesNeeded) { |
| 274 | let chars = ''; |
| 275 | for (const byte of this.buffer) { |
| 276 | if (byte <= 32 || (byte >= 127 && byte <= 159)) { |
| 277 | chars += '.'; |
| 278 | } else { |
| 279 | chars += String.fromCharCode(byte); |
| 280 | } |
| 281 | } |
| 282 | const blah = this.buffer.toString(); |
| 283 | const hexvalue = padLeft(this.buffer.toString('hex'), 8, '0'); |
| 284 | const decodedValue = parseEncoded(this.buffer, this.encoding); |
| 285 | const decodedStr = padLeft(`${decodedValue}`, 12); |
| 286 | const scaledValue = padLeft(`${decodedValue * this.scale}`, 12); |
| 287 | |
| 288 | this.ptyTerm.write(`${timestamp} ${chars} 0x${hexvalue} - ${decodedStr} - ${scaledValue}\n`); |
| 289 | this.bytesRead = 0; |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | } |
no test coverage detected