-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.js
More file actions
executable file
·49 lines (42 loc) · 1.55 KB
/
Copy pathexamples.js
File metadata and controls
executable file
·49 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const hextape = require('.');
// Generate Signetics
const buf1 = Buffer.from([
0x04, 0x55, 0xB0, 0x24, 0xFF, 0xF0, 0x1F, 0x05, 0x04, 0x00,
]);
console.log(hextape.signetics.buildRecord(null, 0x0500, buf1));
// Parse Signetics
const rec2 = ':05000A3C0455B024FFF01F05040030';
console.log(hextape.signetics.parseRecord(rec2));
// Generate Intel
const buf3 = Buffer.from([
0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x20, 0x67, 0x61, 0x70,
]);
console.log(hextape.intel.buildRecord(0x00, 0x0010, buf3));
// Parse Intel
const rec4 = ':0B0010006164647265737320676170A7';
console.log(hextape.intel.parseRecord(rec4));
// Generate Motorola
const buf5 = Buffer.from([
0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77,
0x6F, 0x72, 0x6C, 0x64, 0x2E, 0x0A, 0x00,
]);
console.log(hextape.motorola.buildRecord(1, 0x0038, buf5));
// Parse Motorola
const rec6 = 'S111003848656C6C6F20776F726C642E0A0042';
console.log(hextape.motorola.parseRecord(rec6));
// Stream a file to each format, for testing/comparison
// srec_cat LICENSE -binary -o LICENSE.sr.hex -intel
// srec_cat LICENSE -binary -o LICENSE.sr.s19 -motorola
// srec_cat LICENSE -binary -o LICENSE.sr.shx -signetics
fs.createReadStream('LICENSE')
.pipe(new hextape.intel.HexStream())
.pipe(fs.createWriteStream('LICENSE.ht.hex'));
fs.createReadStream('LICENSE')
.pipe(new hextape.motorola.HexStream())
.pipe(fs.createWriteStream('LICENSE.ht.s19'));
fs.createReadStream('LICENSE')
.pipe(new hextape.signetics.HexStream())
.pipe(fs.createWriteStream('LICENSE.ht.shx'));