-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.mjs
48 lines (43 loc) · 1.39 KB
/
test.mjs
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
import umxxcParser from './lib/mjs/index.js'
console.log('=== esm test ===')
const messageUnderTest = Buffer.from(
'0d4c01e40019000000790017004a0000000000020000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400030007000000020000000a00000000018600010001000300000790000215d4',
'hex'
)
console.log(umxxcParser.parse(messageUnderTest))
/*
should output this:
{
model: 'UM34C',
voltage: 4.84,
current: 25,
power: 121,
temperature: { celsius: 23, fahrenheit: 74 },
selectedGroup: 0,
groups: [
{ acummulatedCurrent: 2, acummulatedPower: 10 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 },
{ acummulatedCurrent: 0, acummulatedPower: 0 }
],
usbDataPlus: 0.04,
usbDataMinus: 0.03,
chargingMode: 7,
accumulatedCurrent: 2,
accumulatedPower: 10,
thresholdCurrent: 0,
accumulatedTime: 390,
connected: 1,
screenTimeout: 1,
screenBrightness: 3,
resistance: 193.6,
screenMode: 2,
unknown: <Buffer 15 d4>
}
*/