From 75f7fbd67a0809c6d8d29c873801ac157d95d5ac Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 2 Jul 2019 16:04:06 +0200 Subject: [PATCH] Don't perform reads on the serial plugin when refreshing --- .../backend/http/static/js/plugins/sensors/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platypush/backend/http/static/js/plugins/sensors/index.js b/platypush/backend/http/static/js/plugins/sensors/index.js index 6c56d567b..07db0c2b0 100644 --- a/platypush/backend/http/static/js/plugins/sensors/index.js +++ b/platypush/backend/http/static/js/plugins/sensors/index.js @@ -35,6 +35,13 @@ Vue.component('sensors', { const promises = this.config.plugins.map(plugin => { return new Promise((resolve, reject) => { + if (plugin === 'serial') { + // Don't refresh reads over the serial port, + // as it might mess up any data transfer already in progress + resolve(); + return; + } + request(plugin + '.get_measurement').then(metrics => { resolve(metrics); }); @@ -42,6 +49,9 @@ Vue.component('sensors', { }); Vue.set(this, 'metrics', (await Promise.all(promises)).reduce((obj, metrics) => { + if (!metrics) + return; + for (const [name, value] of Object.entries(metrics)) { obj[name] = value; }