From 68ca9cfa70597184cde87427a492c5348c1bb80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Thu, 14 Oct 2021 01:52:19 +0100 Subject: [PATCH] fix: tejo related scripts --- bin/dispense-f56-multi.js | 17 +++++++++-------- bin/dispense-init-f56-multi.js | 18 +++++++++--------- bin/set-tejo-cassettes.js | 4 ++-- tools/led-test.js | 6 +++++- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/bin/dispense-f56-multi.js b/bin/dispense-f56-multi.js index d7c267e2a..85b43a2a9 100644 --- a/bin/dispense-f56-multi.js +++ b/bin/dispense-f56-multi.js @@ -1,5 +1,5 @@ const f56 = require('./multi-cassette/f56-rs232-multi') -const deviceConfig = require('../device-config.json') +const deviceConfig = require('../device_config.json') if (deviceConfig.cryptomatModel !== 'tejo') { console.log('This script can only be run on setup Tejo devices') @@ -32,10 +32,11 @@ for (let i = 3; i < 3 + parseInt(deviceConfig.billDispenser.cassettes); i++) { } f56.create(process.argv[2]) -.then(() => f56.billCount(bills)) -.then(res => console.dir(res)) -.then(() => process.exit(0)) -.catch(e => { - console.log(e) - process.exit(1) -}) + .then(() => f56.initialize('EUR', [5, 10, 20, 50])) + .then(() => f56.billCount(bills)) + .then(res => console.dir(res)) + .then(() => process.exit(0)) + .catch(e => { + console.log(e) + process.exit(1) + }) diff --git a/bin/dispense-init-f56-multi.js b/bin/dispense-init-f56-multi.js index 004282691..ec6dd6385 100644 --- a/bin/dispense-init-f56-multi.js +++ b/bin/dispense-init-f56-multi.js @@ -1,5 +1,5 @@ const f56 = require('./multi-cassette/f56-rs232-multi') -const deviceConfig = require('../device-config.json') +const deviceConfig = require('../device_config.json') if (deviceConfig.cryptomatModel !== 'tejo') { console.log('This script can only be run on setup Tejo devices') @@ -32,11 +32,11 @@ for (let i = 3; i < 3 + parseInt(deviceConfig.billDispenser.cassettes); 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) -}) + .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) + }) diff --git a/bin/set-tejo-cassettes.js b/bin/set-tejo-cassettes.js index 9fb6aa360..52797dcdf 100644 --- a/bin/set-tejo-cassettes.js +++ b/bin/set-tejo-cassettes.js @@ -9,7 +9,7 @@ if (deviceConfig.cryptomatModel !== 'tejo') { process.exit(2) } -if (process.argv.length !== 2) { +if (process.argv.length !== 3) { console.log('Usage: node bin/set-tejo-cassettes.js ') console.log('Ex: node bin/set-tejo-cassettes.js 3') process.exit(2) @@ -22,4 +22,4 @@ if (process.argv[2] > 4 || process.argv[2] < 2) { deviceConfig.billDispenser.cassettes = process.argv[2] -fs.writeFileSync(path.join(__dirname, 'device_config.json'), JSON.stringify(deviceConfig)) +fs.writeFileSync(path.join(process.cwd(), 'device_config.json'), JSON.stringify(deviceConfig, null, 2)) diff --git a/tools/led-test.js b/tools/led-test.js index 9866c61ba..541300d10 100644 --- a/tools/led-test.js +++ b/tools/led-test.js @@ -7,11 +7,15 @@ const ledManager = process.argv[2] === 'gaia' ? : require('../lib/ssuboard/led-manager') +const ledAddresses = process.argv[2] === 'tejo' + ? require('../lib/upboard/tejo/led-addresses') + : null + function emit (subsystem, action) { return () => actionEmitter.emit(subsystem, {action}) } -ledManager.run() +ledManager.run(ledAddresses) .then(emit('brain', 'billValidatorPending')) .then(() => delay(3000)) .then(emit('brain', 'billValidatorAccepting'))