Tag: 亲子

我如何保持subprocess在Node JS中运行和父进程通信?

我在我的树莓派上使用了一个用Node JS编写的blynk客户端,它连接并authentication了blynk服务器。 我有另一个进程,我想运行扫描BLE信号的同时保持连接到服务器和轮询button按下。 我让他们都在同一时间执行,但通信只有当我改变虚拟引脚“V0”的状态。 我是新的Node JS,也许我误解,但是,为什么一旦subprocess进行身份validation,它会停止我的父进程,并不会执行父进程的输出,除非我改变状态“V0” //Parent Process var Bleacon = require('./index'); var uuid = '3247ff7d3f0d4b2c9df61189398eb85e'; var arr = []; var ledPin = 17; var math = require('mathjs'); var child_process=require('child_process'); const child = child_process.fork("doorlock.js"); console.log("child scanning…"); Bleacon.startScanning(uuid); Beacon() function Beacon() { Bleacon.on('discover', function(bleacon) { if (bleacon.uuid == uuid) { console.log("uuid matches"); if (bleacon.proximity == 'immediate') […]