From 43162cf0f09efb4da8378ef24cb7cf86147de8e1 Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Thu, 17 Dec 2020 01:35:13 +0300 Subject: [PATCH] Continue modbus developing, DMXbuf corruption fix --- lighthub/dmx.cpp | 5 +++-- lighthub/itemCmd.cpp | 10 +++++++++ lighthub/itemCmd.h | 2 ++ lighthub/main.cpp | 7 ++++++- lighthub/modules/out_modbus.cpp | 36 +++++++++++++++++++++++++++++++++ lighthub/owTerm.cpp | 14 +++++++++++++ lighthub/utils.cpp | 3 +++ platformio.ini | 21 +++++++++++++++---- 8 files changed, 91 insertions(+), 7 deletions(-) diff --git a/lighthub/dmx.cpp b/lighthub/dmx.cpp index a2fc016..1d21e20 100644 --- a/lighthub/dmx.cpp +++ b/lighthub/dmx.cpp @@ -260,12 +260,13 @@ dmxout.setTxMaxChannels(channels); #ifndef DMX_DISABLE for (int i=1;i<=channels;i++) DmxWrite(i,0); #endif - +debugSerial<=1 ) { DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, numParams-1)->valueint); infoSerial<0); //itemCmd st(ST_UINT32,CMD_VOID); int suffixCode = cmd.getSuffix(); +aJsonObject *templateParamObj = NULL; +short mappedCmdVal = 0; + +// trying to find parameter in template with name == subItem (NB!! standard suffixes dint working here) +if (subItem && strlen (subItem)) templateParamObj = aJson.getObjectItem(store->parameters, subItem); + +if (!templateParamObj) +{ + // Trying to find template parameter where id == suffixCode + templateParamObj = store->parameters->child; + + while (templateParamObj) + { + //aJsonObject *regObj = aJson.getObjectItem(paramObj, "reg"); + aJsonObject *idObj = aJson.getObjectItem(templateParamObj, "id"); + if (idObj->type==aJson_Int && idObj->valueint == suffixCode) break; + + aJsonObject *mapObj = aJson.getObjectItem(templateParamObj, "mapcmd"); + if (mapObj && (mappedCmdVal = cmd.doReverseMappingCmd(mapObj))) break; + + templateParamObj=templateParamObj->next; + } +} + + +// aJsonObject *typeObj = aJson.getObjectItem(paramObj, "type"); +// aJsonObject *mapObj = aJson.getObjectItem(paramObj, "map"); +// aJsonObject * itemParametersObj = aJson.getArrayItem(item->itemArg, 2); +// uint16_t data = node.getResponseBuffer(posInBuffer); + + if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it diff --git a/lighthub/owTerm.cpp b/lighthub/owTerm.cpp index e47f235..633632b 100644 --- a/lighthub/owTerm.cpp +++ b/lighthub/owTerm.cpp @@ -95,6 +95,7 @@ int owSetup(owChangedType owCh) { if (oneWire) return true; // Already initialized #ifdef DS2482_100_I2C_TO_1W_BRIDGE debugSerial<type) break; case aJson_Object: { +aJsonObject *act = aJson.getObjectItem(cmd, "act"); +if (act) return executeCommand(act,toggle,_itemCmd); + aJsonObject *item = aJson.getObjectItem(cmd, "item"); aJsonObject *emit = aJson.getObjectItem(cmd, "emit"); aJsonObject *icmd = NULL; diff --git a/platformio.ini b/platformio.ini index 4ba86f2..828105d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -23,13 +23,13 @@ default_envs = ; mega2560-5500 ; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53) -; lighthub21 + lighthub21 ; Arduino DUE + Ethernet shield Wiznet 5100 ; due-5100 ; Generic DUE - due +; due ; Arduino DUE + Ethernet shield Wiznet 5500 ; due-5500 @@ -56,6 +56,7 @@ default_envs = [env:nrf52840-5500] platform = nordicnrf52 board = nrf52840_dk +monitor_baud = 115200 ;board_build.variant = breakout ;upload_protocol = mbed ;upload_port = /dev/cu.SLAB_USBtoUART @@ -118,6 +119,7 @@ lib_deps = [env:m5stack] platform = espressif32 board = m5stack-core-esp32 +monitor_baud = 115200 framework = arduino upload_speed = 921600 build_flags = !python get_build_flags.py m5stack @@ -170,6 +172,7 @@ lib_deps = [env:esp32-wifi] platform = espressif32 framework = arduino +monitor_baud = 115200 monitor_filters = esp32_exception_decoder build_type = debug ;board = pico32 @@ -227,6 +230,7 @@ lib_deps = platform = atmelsam framework = arduino board = due +monitor_baud = 115200 build_flags = !python get_build_flags.py due-5100 lib_ignore = ;DS2482_OneWire //UNCOMMENT for software 1-wire driver @@ -276,6 +280,7 @@ lib_deps = platform = atmelsam framework = arduino board = due +monitor_baud = 115200 build_flags = !python get_build_flags.py due ; Need to place arduinoOTA utility from Arduino IDE distribution to folder in your PATH ;fix address and password @@ -330,6 +335,7 @@ lib_deps = [env:mega2560slim-5100] platform = atmelavr board = megaatmega2560 +monitor_baud = 115200 ;upload_port = net:192.168.88.31:23 upload_port = net:192.168.88.2:23000 framework = arduino @@ -376,6 +382,7 @@ lib_deps = [env:mega2560-5500] platform = atmelavr board = megaatmega2560 +monitor_baud = 115200 framework = arduino build_flags = !python get_build_flags.py mega2560-5500 lib_ignore = @@ -421,6 +428,7 @@ lib_deps = platform = espressif8266 framework = arduino board = nodemcuv2 +monitor_baud = 115200 upload_protocol = esptool ;upload_protocol = espota @@ -482,6 +490,7 @@ lib_deps = [env:mega2560-5100] platform = atmelavr board = megaatmega2560 +monitor_baud = 115200 framework = arduino upload_port = net:192.168.88.2:23000 build_flags = !python get_build_flags.py mega2560-5100 @@ -528,6 +537,7 @@ lib_deps = platform = atmelsam framework = arduino board = due +monitor_baud = 115200 ;build_flags = !bash check_custom_build_flags_due-5500.sh build_flags = !python get_build_flags.py due-5500 lib_ignore = @@ -579,10 +589,11 @@ lib_deps = platform = atmelsam framework = arduino board = due +monitor_baud = 115200 build_flags = !python get_build_flags.py lighthub21 ;upload_command = arduinoOTA -address 192.168.11.172 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE -upload_command = arduinoOTA -address 192.168.88.28 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE -upload_protocol = custom +;upload_command = arduinoOTA -address 192.168.88.28 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE +;upload_protocol = custom lib_ignore = ;DS2482_OneWire //UNCOMMENT for software 1-wire driver DHT sensor library for ESPx @@ -634,6 +645,7 @@ lib_deps = [env:controllino] platform = atmelavr board = megaatmega2560 +monitor_baud = 115200 framework = arduino build_flags = !python get_build_flags.py controllino lib_ignore = @@ -680,6 +692,7 @@ lib_deps = platform = ststm32 framework = arduino board = nucleo_f103rb +monitor_baud = 115200 upload_protocol = stlink debug_tool = stlink build_flags = !python get_build_flags.py stm32-enc2860