-
Notifications
You must be signed in to change notification settings - Fork 0
/
decider.js
30 lines (18 loc) · 1.01 KB
/
decider.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
const spawn = require('child_process').spawn;
const decider = spawn('python', [`${__dirname}/which-device.py`] );
decider.on('close', code => {
console.log(code);
if(code === 200){
console.log(`Code 200. EnviroPHAT presumed connected`);
const enviroMode = spawn('node', [`${__dirname}/enviro.js`]);
enviroMode.stdout.on('data', (data) => {console.log('stdout:', data.toString('utf8')); });
enviroMode.stderr.on('data', (data) => {console.log('stderr:', data.toString('utf8')); });
enviroMode.on('close', (code) => { console.log(`EnviroPHAT program closed with code ${code}`) });
} else if(code === 100){
console.log(`Code 100. InkyPHAT presumed connected`);
const inkyMode = spawn('node', [`${__dirname}/inky.js`]);
inkyMode.stdout.on('data', (data) => { console.log('stdout:', data.toString('utf8')) });
inkyMode.stderr.on('data', (data) => { console.log('stderr:', data.toString('utf8')) });
inkyMode.on('close', (code) => { console.log(`InkyPHAT program closed with code ${code}`) });
}
});