forked from lamassu/lamassu-machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispense-init-f56-multi.js
42 lines (34 loc) · 1.5 KB
/
dispense-init-f56-multi.js
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
const f56 = require('./multi-cassette/f56-rs232-multi')
const deviceConfig = require('../device_config.json')
if (deviceConfig.cryptomatModel !== 'tejo') {
console.log('This script can only be run on setup Tejo devices')
process.exit(2)
}
if (!deviceConfig.billDispenser.cassettes) {
console.log('Number of cassettes is not defined in device_config.json. If you\'re running this on a Tejo machine, consider running \"node bin/set-tejo-cassettes.js <number of cassettes>\"')
process.exit(2)
}
if (process.argv.length < 5) {
console.log('Usage: node bin/dispense-init-f56-multi.js <serial device> <denomination 1> <denomination 2> [<denomination 3> <denomination 4>]')
console.log('Ex: node bin/dispense-init-f56-multi.js /dev/ttyUSB0 5 10')
console.log('Ex: node bin/dispense-init-f56-multi.js /dev/ttyUSB0 5 10 20')
console.log('Ex: node bin/dispense-init-f56-multi.js /dev/ttyUSB0 5 10 20 50')
process.exit(2)
}
if (process.argv.length !== 3 + parseInt(deviceConfig.billDispenser.cassettes)) {
console.log('Number of arguments related to cassette bills do not match the amount of cassettes on the device config!')
process.exit(2)
}
const denominations = []
for (let i = 3; i < 3 + parseInt(deviceConfig.billDispenser.cassettes); i++) {
denominations.push(process.argv[i])
}
f56.create(process.argv[2])
.then(() => f56.initialize('EUR', denominations))
.then(res => console.dir(res))
.then(() => process.exit(0))
.catch(e => {
console.log('DEBUG1')
console.log(e)
process.exit(1)
})