From fb4a0c2e16a75017248e7347206726f3fd4d1be8 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 18 Oct 2019 20:04:37 -0700 Subject: [PATCH] better flow --- libs/core/input.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libs/core/input.ts b/libs/core/input.ts index a9ecdbec..41bdd7a9 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -279,8 +279,11 @@ void cUiUpdatePower(void) if (newConn == DAL.CONN_INPUT_UART) { control.dmesg(`new UART connection at ${sensorInfo.port}`) - if (!devcon) devcon = output.createBuffer(DevConOff.Size) - updateUartMode(devcon, sensorInfo.port, 0); + const status = getUartStatus(sensorInfo.port); + if (status & UART_PORT_CHANGED) { + if (!devcon) devcon = output.createBuffer(DevConOff.Size) + updateUartMode(devcon, sensorInfo.port, 0); + } } else if (newConn == DAL.CONN_NXT_IIC) { control.dmesg(`new IIC connection at ${sensorInfo.port}`) sensorInfo.devType = DAL.DEVICE_TYPE_IIC_UNKNOWN @@ -301,13 +304,13 @@ void cUiUpdatePower(void) } } - if (devcon) { + if (devcon) setUartModes(devcon); - for (const sensorInfo of sensorInfos.filter(si => si.connType == DAL.CONN_INPUT_UART)) { - const uinfo = readUartInfo(sensorInfo.port, devcon[DevConOff.Mode + sensorInfo.port]); - sensorInfo.devType = uinfo[TypesOff.Type]; - control.dmesg(`UART type ${sensorInfo.devType}`) - } + + for (const sensorInfo of sensorInfos.filter(si => si.connType == DAL.CONN_INPUT_UART && si.devType == DAL.CONN_NONE)) { + const uinfo = readUartInfo(sensorInfo.port, 0); + sensorInfo.devType = uinfo[TypesOff.Type]; + control.dmesg(`UART type ${sensorInfo.devType}`) } // assign sensors