mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
Continue modbus developing, DMXbuf corruption fix
This commit is contained in:
@@ -260,12 +260,13 @@ dmxout.setTxMaxChannels(channels);
|
|||||||
#ifndef DMX_DISABLE
|
#ifndef DMX_DISABLE
|
||||||
for (int i=1;i<=channels;i++) DmxWrite(i,0);
|
for (int i=1;i<=channels;i++) DmxWrite(i,0);
|
||||||
#endif
|
#endif
|
||||||
|
debugSerial<<F("DMXOut. Free:")<<freeRam()<<endl;
|
||||||
#ifdef DMX_SMOOTH
|
#ifdef DMX_SMOOTH
|
||||||
if (DMXinterimBuf) delete DMXinterimBuf;
|
if (DMXinterimBuf) delete DMXinterimBuf;
|
||||||
DMXinterimBuf = new uint8_t [channels];
|
DMXinterimBuf = new uint8_t [channels+1];
|
||||||
DMXOUT_Channels=channels;
|
DMXOUT_Channels=channels;
|
||||||
for (int i=1;i<=channels;i++) DMXinterimBuf[i]=0;
|
for (int i=1;i<=channels;i++) DMXinterimBuf[i]=0;
|
||||||
|
debugSerial<<F("DMXInterim. Free:")<<freeRam()<<endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -822,6 +822,16 @@ return false;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int itemCmd::doMappingCmd(aJsonObject *mappingData)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
int itemCmd::doReverseMappingCmd (aJsonObject *mappingData)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
char * itemCmd::toString(char * Buffer, int bufLen, int sendFlags )
|
char * itemCmd::toString(char * Buffer, int bufLen, int sendFlags )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -230,6 +230,8 @@ public:
|
|||||||
|
|
||||||
int doMapping(aJsonObject *mappingData);
|
int doMapping(aJsonObject *mappingData);
|
||||||
int doReverseMapping (aJsonObject *mappingData);
|
int doReverseMapping (aJsonObject *mappingData);
|
||||||
|
int doMappingCmd(aJsonObject *mappingData);
|
||||||
|
int doReverseMappingCmd (aJsonObject *mappingData);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1033,6 +1033,7 @@ setupSyslog();
|
|||||||
if (dmxoutArr && (numParams=aJson.getArraySize(dmxoutArr)) >=1 ) {
|
if (dmxoutArr && (numParams=aJson.getArraySize(dmxoutArr)) >=1 ) {
|
||||||
DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, numParams-1)->valueint);
|
DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, numParams-1)->valueint);
|
||||||
infoSerial<<F("DMX out started. Channels: ")<<maxChannels<<endl;
|
infoSerial<<F("DMX out started. Channels: ")<<maxChannels<<endl;
|
||||||
|
debugSerial<<F("Free:")<<freeRam()<<endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef _modbus
|
#ifdef _modbus
|
||||||
@@ -1467,17 +1468,21 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
htclient.stop();
|
htclient.stop();
|
||||||
wdt_res();
|
wdt_res();
|
||||||
infoSerial<<F("HTTP Status code: ")<<responseStatusCode<<endl;
|
infoSerial<<F("HTTP Status code: ")<<responseStatusCode<<endl;
|
||||||
//debugSerial<<"GET Response: ");
|
|
||||||
//delay(1000);
|
//delay(1000);
|
||||||
if (responseStatusCode == 200) {
|
if (responseStatusCode == 200) {
|
||||||
|
debugSerial<<F("GET Response: ")<<response<<endl;
|
||||||
|
debugSerial<<F("Free:")<<freeRam()<<endl;
|
||||||
cleanConf();
|
cleanConf();
|
||||||
debugSerial<<F("Configuration cleaned")<<endl;
|
debugSerial<<F("Configuration cleaned")<<endl;
|
||||||
|
debugSerial<<F("Free:")<<freeRam()<<endl;
|
||||||
root = aJson.parse((char *) response.c_str());
|
root = aJson.parse((char *) response.c_str());
|
||||||
|
|
||||||
if (!root) {
|
if (!root) {
|
||||||
errorSerial<<F("Config parsing failed\n");
|
errorSerial<<F("Config parsing failed\n");
|
||||||
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
return READ_RE_CONFIG;//-11; //Load from NVRAM
|
||||||
} else {
|
} else {
|
||||||
|
debugSerial<<F("Parsed. Free:")<<freeRam()<<endl;
|
||||||
//debugSerial<<response;
|
//debugSerial<<response;
|
||||||
applyConfig();
|
applyConfig();
|
||||||
infoSerial<<F("Done.\n");
|
infoSerial<<F("Done.\n");
|
||||||
|
|||||||
@@ -374,6 +374,11 @@ int out_Modbus::getChanType()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//!Control unified Modbus item
|
||||||
|
// Priority of selection sub-items control to:
|
||||||
|
// 1. if defined standard suffix Code inside cmd
|
||||||
|
// 2. custom textual subItem
|
||||||
|
// 3. non-standard numeric suffix Code equal param id
|
||||||
|
|
||||||
int out_Modbus::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int out_Modbus::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
||||||
{
|
{
|
||||||
@@ -381,6 +386,37 @@ int out_Modbus::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
|||||||
//bool toExecute = (chActive>0);
|
//bool toExecute = (chActive>0);
|
||||||
//itemCmd st(ST_UINT32,CMD_VOID);
|
//itemCmd st(ST_UINT32,CMD_VOID);
|
||||||
int suffixCode = cmd.getSuffix();
|
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
|
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ int owSetup(owChangedType owCh) {
|
|||||||
if (oneWire) return true; // Already initialized
|
if (oneWire) return true; // Already initialized
|
||||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||||
debugSerial<<F("DS2482_100_I2C_TO_1W_BRIDGE init")<<endl;
|
debugSerial<<F("DS2482_100_I2C_TO_1W_BRIDGE init")<<endl;
|
||||||
|
debugSerial<<F("Free:")<<freeRam()<<endl;
|
||||||
oneWire = new OneWire;
|
oneWire = new OneWire;
|
||||||
#else
|
#else
|
||||||
debugSerial.print(F("One wire setup on PIN:"));
|
debugSerial.print(F("One wire setup on PIN:"));
|
||||||
@@ -102,12 +103,25 @@ int owSetup(owChangedType owCh) {
|
|||||||
oneWire = new OneWire (USE_1W_PIN);
|
oneWire = new OneWire (USE_1W_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!oneWire)
|
||||||
|
{
|
||||||
|
errorSerial<<F("Error 1-w init #1")<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Pass our oneWire reference to Dallas Temperature.
|
// Pass our oneWire reference to Dallas Temperature.
|
||||||
// sensors = new DallasTemperature(oneWire);
|
// sensors = new DallasTemperature(oneWire);
|
||||||
|
|
||||||
term = new DeviceAddress[t_max];
|
term = new DeviceAddress[t_max];
|
||||||
|
debugSerial<<F("Term. Free:")<<freeRam()<<endl;
|
||||||
//regs = new int [t_max];
|
//regs = new int [t_max];
|
||||||
wstat = new uint16_t[t_max];
|
wstat = new uint16_t[t_max];
|
||||||
|
debugSerial<<F("wstat. Free:")<<freeRam()<<endl;
|
||||||
|
if (!term || ! wstat)
|
||||||
|
{
|
||||||
|
errorSerial<<F("Error 1-w init #2 Free:")<<freeRam()<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
owChanged = owCh;
|
owChanged = owCh;
|
||||||
|
|
||||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||||
|
|||||||
@@ -550,6 +550,9 @@ switch (cmd->type)
|
|||||||
break;
|
break;
|
||||||
case aJson_Object:
|
case aJson_Object:
|
||||||
{
|
{
|
||||||
|
aJsonObject *act = aJson.getObjectItem(cmd, "act");
|
||||||
|
if (act) return executeCommand(act,toggle,_itemCmd);
|
||||||
|
|
||||||
aJsonObject *item = aJson.getObjectItem(cmd, "item");
|
aJsonObject *item = aJson.getObjectItem(cmd, "item");
|
||||||
aJsonObject *emit = aJson.getObjectItem(cmd, "emit");
|
aJsonObject *emit = aJson.getObjectItem(cmd, "emit");
|
||||||
aJsonObject *icmd = NULL;
|
aJsonObject *icmd = NULL;
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ default_envs =
|
|||||||
; mega2560-5500
|
; mega2560-5500
|
||||||
|
|
||||||
; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53)
|
; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53)
|
||||||
; lighthub21
|
lighthub21
|
||||||
|
|
||||||
; Arduino DUE + Ethernet shield Wiznet 5100
|
; Arduino DUE + Ethernet shield Wiznet 5100
|
||||||
; due-5100
|
; due-5100
|
||||||
|
|
||||||
; Generic DUE
|
; Generic DUE
|
||||||
due
|
; due
|
||||||
; Arduino DUE + Ethernet shield Wiznet 5500
|
; Arduino DUE + Ethernet shield Wiznet 5500
|
||||||
; due-5500
|
; due-5500
|
||||||
|
|
||||||
@@ -56,6 +56,7 @@ default_envs =
|
|||||||
[env:nrf52840-5500]
|
[env:nrf52840-5500]
|
||||||
platform = nordicnrf52
|
platform = nordicnrf52
|
||||||
board = nrf52840_dk
|
board = nrf52840_dk
|
||||||
|
monitor_baud = 115200
|
||||||
;board_build.variant = breakout
|
;board_build.variant = breakout
|
||||||
;upload_protocol = mbed
|
;upload_protocol = mbed
|
||||||
;upload_port = /dev/cu.SLAB_USBtoUART
|
;upload_port = /dev/cu.SLAB_USBtoUART
|
||||||
@@ -118,6 +119,7 @@ lib_deps =
|
|||||||
[env:m5stack]
|
[env:m5stack]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = m5stack-core-esp32
|
board = m5stack-core-esp32
|
||||||
|
monitor_baud = 115200
|
||||||
framework = arduino
|
framework = arduino
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
build_flags = !python get_build_flags.py m5stack
|
build_flags = !python get_build_flags.py m5stack
|
||||||
@@ -170,6 +172,7 @@ lib_deps =
|
|||||||
[env:esp32-wifi]
|
[env:esp32-wifi]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
monitor_baud = 115200
|
||||||
monitor_filters = esp32_exception_decoder
|
monitor_filters = esp32_exception_decoder
|
||||||
build_type = debug
|
build_type = debug
|
||||||
;board = pico32
|
;board = pico32
|
||||||
@@ -227,6 +230,7 @@ lib_deps =
|
|||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
|
monitor_baud = 115200
|
||||||
build_flags = !python get_build_flags.py due-5100
|
build_flags = !python get_build_flags.py due-5100
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||||
@@ -276,6 +280,7 @@ lib_deps =
|
|||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
|
monitor_baud = 115200
|
||||||
build_flags = !python get_build_flags.py due
|
build_flags = !python get_build_flags.py due
|
||||||
; Need to place arduinoOTA utility from Arduino IDE distribution to folder in your PATH
|
; Need to place arduinoOTA utility from Arduino IDE distribution to folder in your PATH
|
||||||
;fix address and password
|
;fix address and password
|
||||||
@@ -330,6 +335,7 @@ lib_deps =
|
|||||||
[env:mega2560slim-5100]
|
[env:mega2560slim-5100]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
|
monitor_baud = 115200
|
||||||
;upload_port = net:192.168.88.31:23
|
;upload_port = net:192.168.88.31:23
|
||||||
upload_port = net:192.168.88.2:23000
|
upload_port = net:192.168.88.2:23000
|
||||||
framework = arduino
|
framework = arduino
|
||||||
@@ -376,6 +382,7 @@ lib_deps =
|
|||||||
[env:mega2560-5500]
|
[env:mega2560-5500]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
|
monitor_baud = 115200
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = !python get_build_flags.py mega2560-5500
|
build_flags = !python get_build_flags.py mega2560-5500
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
@@ -421,6 +428,7 @@ lib_deps =
|
|||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = nodemcuv2
|
board = nodemcuv2
|
||||||
|
monitor_baud = 115200
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
|
|
||||||
;upload_protocol = espota
|
;upload_protocol = espota
|
||||||
@@ -482,6 +490,7 @@ lib_deps =
|
|||||||
[env:mega2560-5100]
|
[env:mega2560-5100]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
|
monitor_baud = 115200
|
||||||
framework = arduino
|
framework = arduino
|
||||||
upload_port = net:192.168.88.2:23000
|
upload_port = net:192.168.88.2:23000
|
||||||
build_flags = !python get_build_flags.py mega2560-5100
|
build_flags = !python get_build_flags.py mega2560-5100
|
||||||
@@ -528,6 +537,7 @@ lib_deps =
|
|||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
|
monitor_baud = 115200
|
||||||
;build_flags = !bash check_custom_build_flags_due-5500.sh
|
;build_flags = !bash check_custom_build_flags_due-5500.sh
|
||||||
build_flags = !python get_build_flags.py due-5500
|
build_flags = !python get_build_flags.py due-5500
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
@@ -579,10 +589,11 @@ lib_deps =
|
|||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
|
monitor_baud = 115200
|
||||||
build_flags = !python get_build_flags.py lighthub21
|
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.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_command = arduinoOTA -address 192.168.88.28 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE
|
||||||
upload_protocol = custom
|
;upload_protocol = custom
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
@@ -634,6 +645,7 @@ lib_deps =
|
|||||||
[env:controllino]
|
[env:controllino]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
|
monitor_baud = 115200
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = !python get_build_flags.py controllino
|
build_flags = !python get_build_flags.py controllino
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
@@ -680,6 +692,7 @@ lib_deps =
|
|||||||
platform = ststm32
|
platform = ststm32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = nucleo_f103rb
|
board = nucleo_f103rb
|
||||||
|
monitor_baud = 115200
|
||||||
upload_protocol = stlink
|
upload_protocol = stlink
|
||||||
debug_tool = stlink
|
debug_tool = stlink
|
||||||
build_flags = !python get_build_flags.py stm32-enc2860
|
build_flags = !python get_build_flags.py stm32-enc2860
|
||||||
|
|||||||
Reference in New Issue
Block a user