mirror of https://github.com/sfeakes/AqualinkD.git
Updates
parent
cb605b94a6
commit
47820a1ef9
20
README.md
20
README.md
|
@ -113,10 +113,22 @@ Designed to mimic AqualinkRS devices, used to fully configure the master control
|
|||
# Updates in 2.3.8 (Dev)
|
||||
* Code & Repo refactor
|
||||
* Decoded more Pentair VSP pump status.
|
||||
* Changed VSP pump status handling (display more in web UI)
|
||||
* VSP Pump status & other attributes in HASSIO
|
||||
* Dual temperature sensors supported
|
||||
* Updated to serial_logger
|
||||
* Changed VSP pump status handling (display more in web UI).
|
||||
* VSP Pump status & other attributes in HASSIO.
|
||||
* Dual temperature sensors supported.
|
||||
* Updates to serial_logger.
|
||||
* Changes to aqmanager for adding more options for decoding protocols.
|
||||
* Support for packets changes from panels REV Yg
|
||||
<!--
|
||||
NEED TO FIX FOR THIS RELEASE.
|
||||
* Pump by name and not ID.
|
||||
* look at using 0x00 for no exit on serial errors / startup
|
||||
<done> * MQTT ID is now using a lot longer name due to arm64/armhf
|
||||
<done> * Ignore SWG 0 messages can now be removed since VSP is fixed.
|
||||
<done> * Increase packet length due to below (also the print message)
|
||||
Warning: RS Serial: Serial packet too large\
|
||||
Warning: RS Serial: Read Jandy packet BAD PACKET To 0x33 of type Unknown '0x72' | HEX: 0x10|0x02|0x33|0x72|0x20|0x01|0x02|0x03|0x04|0x05|0x06|0x07|0x08|0x09|0x0a|0x0b|0x0c|0x0d|0x0e|0x0f|0x10|0x11|0x12|0x13|0x14|0x15|0x16|0x17|0x18|0x19|0x1.........\
|
||||
-->
|
||||
|
||||
# Updates in Release 2.3.7
|
||||
* Fix for Pentair VSP losing connection & bouncing SWG to 0 and back.
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -147,10 +147,6 @@ rs485_frame_delay = 4
|
|||
# Get rid of the startup warning message about no low latency. BETTER option is to buy a better adapter.
|
||||
#ftdi_low_latency = no
|
||||
|
||||
# Stop the SWG bounce from displaying when using VSP.
|
||||
#swg_zero_ignore_count = 20
|
||||
|
||||
|
||||
# Enable AqualinkD scheduler.
|
||||
# A version of cron that supports cron.d must be installed for the scheduler to work.
|
||||
# If you used the install script and didn;t receive any cron warnings, you should be good to go.
|
||||
|
@ -228,28 +224,28 @@ use_panel_aux_labels=no
|
|||
#
|
||||
# Below is an example of how different Panels map into the buttons.
|
||||
#
|
||||
# | RS-6 Combo | RS-6 Only | RS-8 Combo | RS-2/6 Dual | RS-2/10 Dual | RS-16 Combo |
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# Button_01 | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump |
|
||||
# Button_02 | Spa | Aux_1 | Spa | Spa | Spa | Spa |
|
||||
# Button_03 | Aux 1 | Aux 2 | Aux 1 | Aux 1 | Aux 1 | Aux 1 |
|
||||
# Button_04 | Aux 2 | Aux 3 | Aux 2 | Aux 2 | Aux 2 | Aux 2 |
|
||||
# Button_05 | Aux 3 | Aux 4 | Aux 3 | Aux 3 | Aux 3 | Aux 3 |
|
||||
# Button_06 | Aux 4 | Aux 5 | Aux 4 | Aux 4 | Aux 4 | Aux 4 |
|
||||
# Button_07 | Aux 5 | Temp 1 | Aux 5 | Aux 5 | Aux 5 | Aux 5 |
|
||||
# Button_08 | Pool Heater | Temp 2 | Aux 6 | Aux 6 | Aux 6 | Aux 6 |
|
||||
# Button_09 | Spa Heater | Solar Heater | Aux 7 | Pool Heater | Aux B1 | Aux 7 |
|
||||
# Button_10 | Solar Heater | | Pool Heater | Spa Heater | Aux B2 | Aux B1 |
|
||||
# Button_11 | | | Spa Heater | Solar Heater | Aux B3 | Aux B2 |
|
||||
# Button_12 | | | Solar Heater | | Aux B4 | Aux B3 |
|
||||
# Button_13 | | | | | Pool Heater | Aux B4 |
|
||||
# Button_14 | | | | | Spa Heater | Aux B5 |
|
||||
# Button_15 | | | | | Solar Heater | Aux B6 |
|
||||
# Button_16 | | | | | | Aux B7 |
|
||||
# Button_17 | | | | | | Aux B8 |
|
||||
# Button_18 | | | | | | Pool Heater |
|
||||
# Button_19 | | | | | | Spa Heater |
|
||||
# Button_20 | | | | | | Solar Heater |
|
||||
# | RS-4 Combo | RS-6 Combo | RS-6 Only | RS-8 Combo | RS-2/6 Dual | RS-2/10 Dual | RS-16 Combo |
|
||||
# ----------------------------------------------------------------------------------------------------------
|
||||
# Button_01 | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump |
|
||||
# Button_02 | Spa | Spa | Aux_1 | Spa | Spa | Spa | Spa |
|
||||
# Button_03 | Aux 1 | Aux 1 | Aux 2 | Aux 1 | Aux 1 | Aux 1 | Aux 1 |
|
||||
# Button_04 | Aux 2 | Aux 2 | Aux 3 | Aux 2 | Aux 2 | Aux 2 | Aux 2 |
|
||||
# Button_05 | Aux 3 | Aux 3 | Aux 4 | Aux 3 | Aux 3 | Aux 3 | Aux 3 |
|
||||
# Button_06 | Pool Heater | Aux 4 | Aux 5 | Aux 4 | Aux 4 | Aux 4 | Aux 4 |
|
||||
# Button_07 | Spa Heater | Aux 5 | Temp 1 | Aux 5 | Aux 5 | Aux 5 | Aux 5 |
|
||||
# Button_08 | Solar Heater | Pool Heater | Temp 2 | Aux 6 | Aux 6 | Aux 6 | Aux 6 |
|
||||
# Button_09 | | Spa Heater | Solar Heater | Aux 7 | Pool Heater | Aux B1 | Aux 7 |
|
||||
# Button_10 | | Solar Heater | | Pool Heater | Spa Heater | Aux B2 | Aux B1 |
|
||||
# Button_11 | | | | Spa Heater | Solar Heater | Aux B3 | Aux B2 |
|
||||
# Button_12 | | | | Solar Heater | | Aux B4 | Aux B3 |
|
||||
# Button_13 | | | | | | Pool Heater | Aux B4 |
|
||||
# Button_14 | | | | | | Spa Heater | Aux B5 |
|
||||
# Button_15 | | | | | | Solar Heater | Aux B6 |
|
||||
# Button_16 | | | | | | | Aux B7 |
|
||||
# Button_17 | | | | | | | Aux B8 |
|
||||
# Button_18 | | | | | | | Pool Heater |
|
||||
# Button_19 | | | | | | | Spa Heater |
|
||||
# Button_20 | | | | | | | Solar Heater |
|
||||
|
||||
#
|
||||
# Optional, ( button_01_pumpID & button_01_pumpIndex )
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -536,6 +536,9 @@ void *set_allbutton_light_colormode( void *ptr )
|
|||
|
||||
if (i == LIGHT_COLOR_OPTIONS) {
|
||||
LOG(ALLB_LOG, LOG_ERR, "Light Programming didn't receive color light mode message for '%s'\n",use_current_mode?"light program":mode_name);
|
||||
} else {
|
||||
// Set before we are called.
|
||||
//updateButtonLightProgram(aq_data, val, btn);
|
||||
}
|
||||
|
||||
cleanAndTerminateThread(threadCtrl);
|
||||
|
@ -624,6 +627,9 @@ void *set_allbutton_light_programmode( void *ptr )
|
|||
}
|
||||
//waitForButtonState(aq_data, &aq_data->aqbuttons[btn], ON, 2);
|
||||
|
||||
// set before we are called
|
||||
//updateButtonLightProgram(aq_data, val, btn);
|
||||
|
||||
cleanAndTerminateThread(threadCtrl);
|
||||
|
||||
// just stop compiler error, ptr is not valid as it's just been freed
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
#define PUMP_MODE_TOPIC "/Mode"
|
||||
#define PUMP_STATUS_TOPIC "/Status"
|
||||
#define PUMP_PPC_TOPIC "/PPC"
|
||||
|
||||
#define LIGHT_PROGRAM_TOPIC "/program"
|
||||
/*
|
||||
#define AIR_TEMPERATURE "Air"
|
||||
#define POOL_TEMPERATURE "Pool_Water"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "serialadapter.h"
|
||||
#include "aq_timer.h"
|
||||
#include "allbutton_aq_programmer.h"
|
||||
#include "rs_msg_utils.h"
|
||||
|
||||
void initPanelButtons(struct aqualinkdata *aqdata, bool rspda, int size, bool combo, bool dual);
|
||||
void programDeviceLightMode(struct aqualinkdata *aqdata, int value, int button);
|
||||
|
@ -60,6 +61,8 @@ uint8_t getPanelSupport( char *rev_string, int rev_len)
|
|||
// Rev >=Q == iaqualink touch protocol.
|
||||
// REv >= P == chemlink
|
||||
// Rev >= HH serial adapter.
|
||||
|
||||
// Rev Yg (and maybe before) has Pump label (not number), and also Virtual Device called Label Auxiliraries
|
||||
if (REV[0] >= 81) // Q in ascii
|
||||
supported |= RSP_SUP_IAQT;
|
||||
|
||||
|
@ -752,6 +755,9 @@ void programDeviceLightMode(struct aqualinkdata *aqdata, int value, int button)
|
|||
sprintf(buf, "%-5d%-5d%-5d",value, button, light->lightType);
|
||||
aq_programmer(AQ_SET_LIGHTCOLOR_MODE, buf, aqdata);
|
||||
}
|
||||
|
||||
// Use function so can be called from programming thread if we decide to in future.
|
||||
updateButtonLightProgram(aqdata, value, button);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -794,7 +800,12 @@ bool panel_device_request(struct aqualinkdata *aqdata, action_type type, int dev
|
|||
start_timer(aqdata, deviceIndex, value);
|
||||
break;
|
||||
case LIGHT_MODE:
|
||||
programDeviceLightMode(aqdata, value, deviceIndex);
|
||||
if (value <= 0) {
|
||||
// Consider this a bad/malformed request to turn the light off.
|
||||
panel_device_request(aqdata, ON_OFF, deviceIndex, 0, source);
|
||||
} else {
|
||||
programDeviceLightMode(aqdata, value, deviceIndex);
|
||||
}
|
||||
break;
|
||||
case POOL_HTR_SETOINT:
|
||||
case SPA_HTR_SETOINT:
|
||||
|
@ -819,8 +830,27 @@ bool panel_device_request(struct aqualinkdata *aqdata, action_type type, int dev
|
|||
}
|
||||
|
||||
|
||||
// Programmable light has been updated, so update the status in AqualinkD
|
||||
void updateButtonLightProgram(struct aqualinkdata *aqdata, int value, int button)
|
||||
{
|
||||
int i;
|
||||
clight_detail *light = NULL;
|
||||
|
||||
for (i=0; i < aqdata->num_lights; i++) {
|
||||
if (&aqdata->aqbuttons[button] == aqdata->lights[i].button) {
|
||||
// Found the programmable light
|
||||
light = &aqdata->lights[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (light == NULL) {
|
||||
LOG(PANL_LOG,LOG_ERR, "Button not found for light button index=%d\n",button);
|
||||
return;
|
||||
}
|
||||
|
||||
light->currentValue = value;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DO_NOT_COMPILE
|
||||
|
|
|
@ -46,6 +46,8 @@ const char* getPanelString();
|
|||
|
||||
bool panel_device_request(struct aqualinkdata *aqdata, action_type type, int deviceIndex, int value, request_source source);
|
||||
|
||||
void updateButtonLightProgram(struct aqualinkdata *aqdata, int value, int button);
|
||||
|
||||
void changePanelToMode_Only();
|
||||
void addPanelOneTouchInterface();
|
||||
void addPanelIAQTouchInterface();
|
||||
|
|
|
@ -329,7 +329,7 @@ bool check_jandy_checksum(unsigned char* packet, int length)
|
|||
LOG(RSSD_LOG,LOG_INFO, "Ignoring bad checksum, seems to be bug in Jandy protocol\n");
|
||||
if (getLogLevel(RSSD_LOG) >= LOG_DEBUG) {
|
||||
static char buf[1000];
|
||||
beautifyPacket(buf,packet,length,true);
|
||||
beautifyPacket(buf,1000, packet,length,true);
|
||||
LOG(RSSD_LOG,LOG_DEBUG, "Packetin question %s\n",buf);
|
||||
}
|
||||
return true;
|
||||
|
@ -1128,7 +1128,7 @@ int get_packet(int fd, unsigned char* packet)
|
|||
// Break out of the loop if we exceed maximum packet
|
||||
// length.
|
||||
if (index >= AQ_MAXPKTLEN) {
|
||||
LOG(RSSD_LOG,LOG_WARNING, "Serial packet too large\n");
|
||||
LOG(RSSD_LOG,LOG_WARNING, "Serial packet too large for buffer, stopped reading\n");
|
||||
logPacketError(packet, index);
|
||||
//log_packet(LOG_WARNING, "Bad receive packet ", packet, index);
|
||||
return AQSERR_2LARGE;
|
||||
|
@ -1136,9 +1136,12 @@ int get_packet(int fd, unsigned char* packet)
|
|||
}
|
||||
}
|
||||
|
||||
// Clean out rest of buffer, make sure their is nothing else
|
||||
/* Doesn't work for shit due to probe message speed, need to come back and re-think
|
||||
*/
|
||||
|
||||
// Report any unusual size packets.
|
||||
if (index >= AQ_MAXPKTLEN_WARNING) {
|
||||
LOG(RSSD_LOG,LOG_WARNING, "Serial packet seems too large at length %d\n", index);
|
||||
logPacketError(packet, index);
|
||||
}
|
||||
|
||||
//LOG(RSSD_LOG,LOG_DEBUG, "Serial checksum, length %d got 0x%02hhx expected 0x%02hhx\n", index, packet[index-3], generate_checksum(packet, index));
|
||||
if (jandyPacketStarted) {
|
||||
|
@ -1156,6 +1159,8 @@ int get_packet(int fd, unsigned char* packet)
|
|||
return AQSERR_CHKSUM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (generate_checksum(packet, index) != packet[index-3]){
|
||||
LOG(RSSD_LOG,LOG_WARNING, "Serial read bad checksum, ignoring\n");
|
||||
|
|
|
@ -53,6 +53,32 @@ const char *getJandyDeviceName(emulation_type etype);
|
|||
#define JANDY_DEC_CHEM_MIN 128 // 0x80
|
||||
#define JANDY_DEC_CHEM_MAX 131 // 0x83
|
||||
|
||||
/*
|
||||
//===== Device ID's =====//
|
||||
//=========================================================================//
|
||||
DEV_MASTER_MASK = 0x00; // MASTER(S???0 00-03 0b0 0000 0XX //
|
||||
DEV_CTL_MASK = 0x08; // HOME CONTROLLER (RS-8?) 08-0b 0b0 0001 0XX //
|
||||
// 0x10; // XXXXX DEVICE 10-13 0b0 0010 0XX //
|
||||
// 0x18; // XXXXX DEVICE 18-1b 0b0 0011 0XX //
|
||||
DEV_SPA_MASK = 0x20; // SPA DEVICE 20-23 0b0 0100 0XX //
|
||||
DEV_RPC_MASK = 0x28; // REMOTE POWER CENTER DEVICE 28-2b 0b0 0101 0XX //
|
||||
DEV_AQUALINK_MASK = 0x30; // AQUALINK DEVICE 30-33 0b0 0110 0XX //
|
||||
DEV_LX_HTR_MASK = 0x38; // LX HEATER 38-3b 0b0 0111 0XX //
|
||||
DEV_ONETOUCH_MASK = 0x40; // XXXXX ONE TOUCH DEVICE 40-43 0b0 1000 0XX //
|
||||
// 0x48; // XXXXX DEVICE 48-4b 0b0 1001 0XX //
|
||||
DEV_AQUARITE_MASK = 0x50; // AQUARITE DEVICE 50-53 0b0 1010 0XX //
|
||||
DEV_PCDOCK_MASK = 0x58; // PCDOCK DEVICE 58-5b 0b0 1011 0XX //
|
||||
DEV_PDA_JDA_MASK = 0x60; // AQUAPALM DEVICE 60-63 0b0 1100 0XX //
|
||||
DEV_LXI_LRZE_MASK = 0x68; // LXi/LZRE DEVICE 68-6b 0b0 1101 0XX //
|
||||
DEV_HEATPUMP_MASK = 0x70; // HEAT PUMP DEVICE 70-73 0b0 1110 0XX //
|
||||
JANDY_EPUMP_MASK = 0x78; // EPUMP DEVICE 78-7b 0b0 1111 0XX //
|
||||
DEV_CHEMLINK_MASK = 0x80; // CHEMLINK DEVICE 80-83 0b1 0000 0XX //
|
||||
Heater 0x88; // XXXXX DEVICE 88-8b 0b1 0001 0XX //
|
||||
// 0x90; // XXXXX DEVICE 90-93 0b1 0010 0XX //
|
||||
// 0x98; // XXXXX DEVICE 98-9b 0b1 0011 0XX //
|
||||
DEV_AQUALINK_2_MASK = 0xA0; // AQUALINK 2 A0-A3 0b1 0100 0XX //
|
||||
DEV_UNKNOWN_MASK = 0xF8; // Unknown mask, used to reset values
|
||||
*/
|
||||
|
||||
// PACKET DEFINES Jandy
|
||||
#define NUL 0x00
|
||||
|
@ -94,12 +120,18 @@ const char *getJandyDeviceName(emulation_type etype);
|
|||
|
||||
#define AQ_MINPKTLEN 5
|
||||
//#define AQ_MAXPKTLEN 64
|
||||
#define AQ_MAXPKTLEN 128 // Max 79 bytes so far, so 128 is a guess at the moment, just seen large packets from iAqualink
|
||||
//#define AQ_MAXPKTLEN 128 // Max 79 bytes so far, so 128 is a guess at the moment, just seen large packets from iAqualink
|
||||
#define AQ_MAXPKTLEN 256 // Still getting this at 128, so temp increase to 256 and print message over 128 in aq_serial.c
|
||||
#define AQ_PSTLEN 5
|
||||
#define AQ_MSGLEN 16
|
||||
#define AQ_MSGLONGLEN 128
|
||||
#define AQ_TADLEN 13
|
||||
|
||||
// For printing warning & debug messages for packets.
|
||||
// The below are related to AQ_MAXPKTLEN
|
||||
#define AQ_MAXPKTLEN_WARNING 128 // Print warning message if over this
|
||||
//#define AQ_PACKET_PRINT_BUFFER 1400 // Must be at least AQ_MAXPKTLEN * 5 + 100
|
||||
|
||||
/* COMMANDS */
|
||||
#define CMD_PROBE 0x00
|
||||
#define CMD_ACK 0x01
|
||||
|
|
|
@ -89,7 +89,7 @@ typedef struct aqualinkkey
|
|||
#define VS_PUMP (1 << 0)
|
||||
#define PROGRAM_LIGHT (1 << 1)
|
||||
#define TIMER_ACTIVE (1 << 2)
|
||||
//#define DIMMER_LIGHT (1 << 3) // NOT USED YET
|
||||
//#define DIMMER_LIGHT (1 << 3) // NOT USED (Use PROGRAM_LIGHT or type LC_DIMMER)
|
||||
|
||||
//typedef struct ProgramThread ProgramThread; // Definition is later
|
||||
|
||||
|
@ -212,6 +212,7 @@ typedef struct clightd
|
|||
{
|
||||
clight_type lightType;
|
||||
aqkey *button;
|
||||
int currentValue;
|
||||
} clight_detail;
|
||||
|
||||
|
||||
|
@ -282,6 +283,9 @@ struct aqualinkdata
|
|||
|
||||
#ifdef AQ_MANAGER
|
||||
volatile bool run_slogger;
|
||||
int slogger_packets;
|
||||
bool slogger_debug;
|
||||
char slogger_ids[20];
|
||||
#endif
|
||||
|
||||
#ifdef AQ_RS16
|
||||
|
|
|
@ -527,7 +527,6 @@ int startup(char *self, char *cfgFile)
|
|||
_aqualink_data.total_buttons = 12;
|
||||
*/
|
||||
|
||||
|
||||
if (_cmdln_loglevel != -1)
|
||||
_aqconfig_.log_level = _cmdln_loglevel;
|
||||
|
||||
|
@ -635,10 +634,10 @@ int startup(char *self, char *cfgFile)
|
|||
LOG(AQUA_LOG,LOG_NOTICE, "Read JXi heater direct = %s\n", bool2text(READ_RSDEV_JXI));
|
||||
LOG(AQUA_LOG,LOG_NOTICE, "Read LX heater direct = %s\n", bool2text(READ_RSDEV_LX));
|
||||
LOG(AQUA_LOG,LOG_NOTICE, "Read Chem Feeder direct = %s\n", bool2text(READ_RSDEV_CHEM));
|
||||
|
||||
/*
|
||||
if (READ_RSDEV_SWG && _aqconfig_.swg_zero_ignore != DEFAULT_SWG_ZERO_IGNORE_COUNT)
|
||||
LOG(AQUA_LOG,LOG_NOTICE, "Ignore SWG 0 msg count = %d\n", _aqconfig_.swg_zero_ignore);
|
||||
|
||||
*/
|
||||
if (_aqconfig_.ftdi_low_latency == true)
|
||||
LOG(AQUA_LOG,LOG_NOTICE, "Serial FTDI low latency = %s\n", bool2text(_aqconfig_.ftdi_low_latency));
|
||||
|
||||
|
@ -874,6 +873,10 @@ void main_loop()
|
|||
_aqualink_data.pumps[i].pressureCurve = TEMP_UNKNOWN;
|
||||
}
|
||||
|
||||
for (i=0; i < MAX_LIGHTS; i++) {
|
||||
_aqualink_data.lights[i].currentValue = TEMP_UNKNOWN;
|
||||
}
|
||||
|
||||
if (_aqconfig_.force_swg == true) {
|
||||
//_aqualink_data.ar_swg_device_status = SWG_STATUS_OFF;
|
||||
_aqualink_data.swg_led_state = OFF;
|
||||
|
@ -1137,8 +1140,15 @@ void main_loop()
|
|||
if (_aqualink_data.run_slogger) {
|
||||
LOG(AQUA_LOG,LOG_WARNING, "Starting serial_logger, this will take some time!\n");
|
||||
broadcast_aqualinkstate_error(CONNECTION_RUNNING_SLOG);
|
||||
serial_logger(rs_fd, _aqconfig_.serial_port, getSystemLogLevel());
|
||||
|
||||
if (_aqualink_data.slogger_debug)
|
||||
addDebugLogMask(SLOG_LOG);
|
||||
|
||||
serial_logger(rs_fd, _aqconfig_.serial_port, _aqualink_data.slogger_debug?LOG_DEBUG:getSystemLogLevel(), _aqualink_data.slogger_packets, _aqualink_data.slogger_ids);
|
||||
_aqualink_data.run_slogger = false;
|
||||
|
||||
if (_aqualink_data.slogger_debug)
|
||||
removeDebugLogMask(SLOG_LOG);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ void init_parameters (struct aqconfig * parms)
|
|||
parms->force_frzprotect_setpoints = false;
|
||||
parms->force_chem_feeder = false;
|
||||
//parms->swg_pool_and_spa = false;
|
||||
parms->swg_zero_ignore = DEFAULT_SWG_ZERO_IGNORE_COUNT;
|
||||
//parms->swg_zero_ignore = DEFAULT_SWG_ZERO_IGNORE_COUNT;
|
||||
parms->display_warnings_web = false;
|
||||
|
||||
parms->log_protocol_packets = false; // Read & Write as packets write to file
|
||||
|
@ -244,6 +244,8 @@ char *generate_mqtt_id(char *buf, int len) {
|
|||
strncpy(buf, basename(__progname), len);
|
||||
i = strlen(buf);
|
||||
|
||||
if ( i > 9) { i=9; } // cut down to 9 characters (aqualinkd)
|
||||
|
||||
if (i < len) {
|
||||
buf[i++] = '_';
|
||||
// If we can't get MAC to pad mqtt id then use PID
|
||||
|
@ -603,9 +605,11 @@ bool setConfigValue(struct aqualinkdata *aqdata, char *param, char *value) {
|
|||
} else if (strncasecmp (param, "debug_RSProtocol_packets", 24) == 0) {
|
||||
_aqconfig_.log_protocol_packets = text2bool(value);
|
||||
rtn=true;
|
||||
/*
|
||||
} else if (strncasecmp (param, "swg_zero_ignore_count", 21) == 0) {
|
||||
_aqconfig_.swg_zero_ignore = strtoul(value, NULL, 10);
|
||||
rtn=true;
|
||||
*/
|
||||
} else if (strncasecmp (param, "display_warnings_in_web", 23) == 0) {
|
||||
_aqconfig_.display_warnings_web = text2bool(value);
|
||||
rtn=true;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define DEFAULT_MQTT_SERVER NULL
|
||||
#define DEFAULT_MQTT_USER NULL
|
||||
#define DEFAULT_MQTT_PASSWD NULL
|
||||
#define DEFAULT_SWG_ZERO_IGNORE_COUNT 0
|
||||
//#define DEFAULT_SWG_ZERO_IGNORE_COUNT 0
|
||||
|
||||
#define MQTT_ID_LEN 18 // 20 seems to kill mosquitto 1.6
|
||||
|
||||
|
@ -83,7 +83,7 @@ struct aqconfig
|
|||
bool force_ps_setpoints;
|
||||
bool force_frzprotect_setpoints;
|
||||
bool force_chem_feeder;
|
||||
int swg_zero_ignore;
|
||||
//int swg_zero_ignore; // This can be removed since this was due to VSP that's been fixed.
|
||||
bool display_warnings_web;
|
||||
bool log_protocol_packets; // Read & Write as packets
|
||||
bool log_raw_bytes; // Read as bytes
|
||||
|
|
|
@ -83,7 +83,7 @@ bool processJandyPacket(unsigned char *packet_buffer, int packet_length, struct
|
|||
else if (READ_RSDEV_SWG && packet_buffer[PKT_DEST] >= JANDY_DEC_SWG_MIN && packet_buffer[PKT_DEST] <= JANDY_DEC_SWG_MAX)
|
||||
{
|
||||
interestedInNextAck = DRS_SWG;
|
||||
rtn = processPacketToSWG(packet_buffer, packet_length, aqdata, _aqconfig_.swg_zero_ignore);
|
||||
rtn = processPacketToSWG(packet_buffer, packet_length, aqdata/*, _aqconfig_.swg_zero_ignore*/);
|
||||
previous_packet_to = packet_buffer[PKT_DEST];
|
||||
}
|
||||
else if (READ_RSDEV_ePUMP && packet_buffer[PKT_DEST] >= JANDY_DEC_PUMP_MIN && packet_buffer[PKT_DEST] <= JANDY_DEC_PUMP_MAX)
|
||||
|
@ -125,14 +125,14 @@ bool processJandyPacket(unsigned char *packet_buffer, int packet_length, struct
|
|||
return rtn;
|
||||
}
|
||||
|
||||
bool processPacketToSWG(unsigned char *packet, int packet_length, struct aqualinkdata *aqdata, int swg_zero_ignore) {
|
||||
static int swg_zero_cnt = 0;
|
||||
bool processPacketToSWG(unsigned char *packet, int packet_length, struct aqualinkdata *aqdata /*, int swg_zero_ignore*/) {
|
||||
//static int swg_zero_cnt = 0;
|
||||
bool changedAnything = false;
|
||||
|
||||
// Only log if we are jandy debug move and not serial (otherwise it'll print twice)
|
||||
if (getLogLevel(DJAN_LOG) == LOG_DEBUG && getLogLevel(RSSD_LOG) < LOG_DEBUG ) {
|
||||
char buff[1024];
|
||||
beautifyPacket(buff, packet, packet_length, true);
|
||||
beautifyPacket(buff, 1024, packet, packet_length, true);
|
||||
LOG(DJAN_LOG,LOG_DEBUG, "To SWG: %s", buff);
|
||||
}
|
||||
|
||||
|
@ -142,32 +142,33 @@ bool processPacketToSWG(unsigned char *packet, int packet_length, struct aqualin
|
|||
// Not really sure what to do with this, just ignore 0xff / 255 for the moment. (if statment above)
|
||||
|
||||
// SWG can get ~10 messages to set to 0 then go back again for some reason, so don't go to 0 until 10 messages are received
|
||||
if (swg_zero_cnt <= swg_zero_ignore && packet[4] == 0x00) {
|
||||
/*
|
||||
if (swg_zero_cnt < swg_zero_ignore && packet[4] == 0x00) {
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "Ignoring SWG set to %d due to packet packet count %d <= %d from control panel to SWG 0x%02hhx 0x%02hhx\n", (int)packet[4],
|
||||
swg_zero_cnt, swg_zero_ignore, packet[4], packet[5]);
|
||||
swg_zero_cnt++;
|
||||
} else if (swg_zero_cnt > swg_zero_ignore && packet[4] == 0x00) {
|
||||
} else if (swg_zero_cnt >= swg_zero_ignore && packet[4] == 0x00) {
|
||||
if (aqdata->swg_percent != (int)packet[4]) {
|
||||
//aqdata->swg_percent = (int)packet[4];
|
||||
setSWGpercent(aqdata, (int)packet[4]);
|
||||
changedAnything = true;
|
||||
aqdata->updated = true;
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "Set SWG %% to %d from reading control panel packet sent to SWG (received %d messages)\n", aqdata->swg_percent, swg_zero_cnt);
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "Set SWG %% to %d from reading control panel RS485 packet sent to SWG\n", aqdata->swg_percent);
|
||||
}
|
||||
// LOG(DJAN_LOG, LOG_DEBUG, "SWG set to %d due to packet packet count %d <= %d from control panel to SWG 0x%02hhx 0x%02hhx\n",
|
||||
// (int)packet[4],swg_zero_cnt,SWG_ZERO_IGNORE_COUNT,packet[4],packet[5]); swg_zero_cnt++;
|
||||
} else {
|
||||
swg_zero_cnt = 0;
|
||||
} else {*/
|
||||
//swg_zero_cnt = 0;
|
||||
if (aqdata->swg_percent != (int)packet[4]) {
|
||||
//aqdata->swg_percent = (int)packet[4];
|
||||
setSWGpercent(aqdata, (int)packet[4]);
|
||||
changedAnything = true;
|
||||
aqdata->updated = true;
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "Set SWG %% to %d from control panel packet to SWG\n", aqdata->swg_percent);
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "Set SWG %% to %d from control panel RS485 packet to SWG\n", aqdata->swg_percent);
|
||||
}
|
||||
// LOG(DJAN_LOG, LOG_DEBUG, "SWG set to %d due to packet from control panel to SWG 0x%02hhx 0x%02hhx\n",
|
||||
// aqdata.swg_percent,packet[4],packet[5]);
|
||||
}
|
||||
/*}*/
|
||||
|
||||
if (aqdata->swg_percent > 100)
|
||||
aqdata->boost = true;
|
||||
|
@ -194,7 +195,7 @@ bool processPacketFromSWG(unsigned char *packet, int packet_length, struct aqual
|
|||
// Only log if we are jandy debug move and not serial (otherwise it'll print twice)
|
||||
if (getLogLevel(DJAN_LOG) == LOG_DEBUG && getLogLevel(RSSD_LOG) < LOG_DEBUG ) {
|
||||
char buff[1024];
|
||||
beautifyPacket(buff, packet, packet_length, true);
|
||||
beautifyPacket(buff, 1024, packet, packet_length, true);
|
||||
LOG(DJAN_LOG,LOG_DEBUG, "From SWG: %s", buff);
|
||||
}
|
||||
|
||||
|
@ -562,8 +563,8 @@ bool processPacketToJandyPump(unsigned char *packet_buffer, int packet_length, s
|
|||
*/
|
||||
// Only log if we are jandy debug move and not serial (otherwise it'll print twice)
|
||||
if (getLogLevel(DJAN_LOG) == LOG_DEBUG && getLogLevel(RSSD_LOG) < LOG_DEBUG ) {
|
||||
char msg[1000];
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
char msg[1024];
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "To ePump: %s\n", msg);
|
||||
}
|
||||
|
||||
|
@ -594,9 +595,9 @@ bool processPacketFromJandyPump(unsigned char *packet_buffer, int packet_length,
|
|||
|
||||
// Only log if we are jandy debug move and not serial (otherwise it'll print twice)
|
||||
if (getLogLevel(DJAN_LOG) == LOG_DEBUG && getLogLevel(RSSD_LOG) < LOG_DEBUG ) {
|
||||
char msg[1000];
|
||||
char msg[1024];
|
||||
//logMessage(LOG_DEBUG, "Need to log ePump message here for future\n");
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "From ePump: %s\n", msg);
|
||||
}
|
||||
|
||||
|
@ -659,9 +660,9 @@ bool processPacketToJandyJXiHeater(unsigned char *packet_buffer, int packet_leng
|
|||
{
|
||||
|
||||
if (getLogLevel(DJAN_LOG) == LOG_DEBUG && getLogLevel(RSSD_LOG) < LOG_DEBUG ) {
|
||||
char msg[1000];
|
||||
char msg[1024];
|
||||
//logMessage(LOG_DEBUG, "Need to log ePump message here for future\n");
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "To JXi: %s\n", msg);
|
||||
}
|
||||
|
||||
|
@ -792,9 +793,9 @@ void getJandyHeaterErrorMQTT(struct aqualinkdata *aqdata, char *message)
|
|||
bool processPacketFromJandyJXiHeater(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata, const unsigned char previous_packet_to)
|
||||
{
|
||||
if (getLogLevel(DJAN_LOG) == LOG_DEBUG && getLogLevel(RSSD_LOG) < LOG_DEBUG ) {
|
||||
char msg[1000];
|
||||
char msg[1024];
|
||||
//logMessage(LOG_DEBUG, "Need to log ePump message here for future\n");
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_DEBUG, "From JXi: %s\n", msg);
|
||||
}
|
||||
|
||||
|
@ -848,10 +849,10 @@ bool processPacketFromJandyJXiHeater(unsigned char *packet_buffer, int packet_le
|
|||
bool processPacketToJandyLXHeater(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata)
|
||||
{
|
||||
|
||||
char msg[1000];
|
||||
char msg[1024];
|
||||
int length = 0;
|
||||
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_INFO, "To LX: %s\n", msg);
|
||||
|
||||
length += sprintf(msg+length, "Last panel info ");
|
||||
|
@ -877,10 +878,10 @@ bool processPacketToJandyLXHeater(unsigned char *packet_buffer, int packet_lengt
|
|||
|
||||
bool processPacketFromJandyLXHeater(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata, const unsigned char previous_packet_to)
|
||||
{
|
||||
char msg[1000];
|
||||
char msg[1024];
|
||||
int length = 0;
|
||||
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_INFO, "From LX: %s\n", msg);
|
||||
|
||||
length += sprintf(msg+length, "Last panel info ");
|
||||
|
@ -906,10 +907,10 @@ bool processPacketFromJandyLXHeater(unsigned char *packet_buffer, int packet_len
|
|||
|
||||
bool processPacketToJandyChemFeeder(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata)
|
||||
{
|
||||
char msg[1000];
|
||||
char msg[1024];
|
||||
int length = 0;
|
||||
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_INFO, "To Chem: %s\n", msg);
|
||||
|
||||
length += sprintf(msg+length, "Last panel info ");
|
||||
|
@ -922,10 +923,10 @@ bool processPacketToJandyChemFeeder(unsigned char *packet_buffer, int packet_len
|
|||
}
|
||||
|
||||
bool processPacketFromJandyChemFeeder(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata, const unsigned char previous_packet_to){
|
||||
char msg[1000];
|
||||
char msg[1024];
|
||||
int length = 0;
|
||||
|
||||
beautifyPacket(msg, packet_buffer, packet_length, true);
|
||||
beautifyPacket(msg, 1024, packet_buffer, packet_length, true);
|
||||
LOG(DJAN_LOG, LOG_INFO, "From Chem: %s\n", msg);
|
||||
|
||||
length += sprintf(msg+length, "Last panel info ");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
bool processJandyPacket(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata);
|
||||
|
||||
bool processPacketToSWG(unsigned char *packet, int packet_length, struct aqualinkdata *aqdata, int swg_zero_ignore);
|
||||
bool processPacketToSWG(unsigned char *packet, int packet_length, struct aqualinkdata *aqdata/*, int swg_zero_ignore*/);
|
||||
bool processPacketFromSWG(unsigned char *packet, int packet_length, struct aqualinkdata *aqdata, const unsigned char previous_packet_to);
|
||||
bool processPacketToJandyPump(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata);
|
||||
bool processPacketFromJandyPump(unsigned char *packet_buffer, int packet_length, struct aqualinkdata *aqdata, const unsigned char previous_packet_to);
|
||||
|
|
|
@ -34,7 +34,7 @@ bool processPentairPacket(unsigned char *packet, int packet_length, struct aqual
|
|||
// Only log if we are pentair debug move and not serial (otherwise it'll print twice)
|
||||
if (getLogLevel(DPEN_LOG) == LOG_DEBUG && getLogLevel(RSSD_LOG) < LOG_DEBUG ) {
|
||||
char buff[1024];
|
||||
beautifyPacket(buff, packet, packet_length, true);
|
||||
beautifyPacket(buff, 1024, packet, packet_length, true);
|
||||
LOG(DPEN_LOG,LOG_DEBUG, "%s", buff);
|
||||
}
|
||||
|
||||
|
|
|
@ -417,6 +417,21 @@ void iaqt_pump_update(struct aqualinkdata *aq_data, int updated) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Some newer revisions support pump by name and not number.
|
||||
Seen this is rev Yg
|
||||
|
||||
Info: iAQ Touch: Page: Status (diff ID) | 0x2a\
|
||||
Info: iAQ Touch: Status page 00| Filter Pump\
|
||||
Info: iAQ Touch: Status page 01| Spa Light\
|
||||
Info: iAQ Touch: Status page 02| Pool Light\
|
||||
Info: iAQ Touch: Status page 03| Pump 2248\ <--- This is the pump name.
|
||||
Info: iAQ Touch: Status page 04| RPM: 1350\
|
||||
Info: iAQ Touch: Status page 05| Watts: 176\
|
||||
Info: iAQ Touch: Status page 06| #1 AquaPure\
|
||||
|
||||
*/
|
||||
|
||||
void passDeviceStatusPage(struct aqualinkdata *aq_data)
|
||||
{
|
||||
int i;
|
||||
|
@ -724,8 +739,8 @@ bool process_iaqtouch_packet(unsigned char *packet, int length, struct aqualinkd
|
|||
|
||||
if ( packet[3] != CMD_IAQ_POLL && getLogLevel(IAQT_LOG) >= LOG_DEBUG ) {
|
||||
//if ( getLogLevel(IAQT_LOG) >= LOG_DEBUG ) {
|
||||
char buff[1000];
|
||||
beautifyPacket(buff, packet, length, false);
|
||||
char buff[1024];
|
||||
beautifyPacket(buff, 1024, packet, length, false);
|
||||
LOG(IAQT_LOG,LOG_DEBUG, "Received message : %s", buff);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,9 +142,9 @@ int ref_iaqt_control_cmd(unsigned char **cmd)
|
|||
*cmd = _iaqt_control_cmd;
|
||||
|
||||
if ( getLogLevel(IAQT_LOG) >= LOG_DEBUG ) {
|
||||
char buff[1000];
|
||||
char buff[1024];
|
||||
//sprintf("Sending control command:")
|
||||
beautifyPacket(buff, _iaqt_control_cmd, _iaqt_control_cmd_len, false);
|
||||
beautifyPacket(buff, 1024, _iaqt_control_cmd, _iaqt_control_cmd_len, false);
|
||||
LOG(IAQT_LOG,LOG_DEBUG, "Sending commandsed : %s\n", buff);
|
||||
}
|
||||
|
||||
|
|
|
@ -488,7 +488,7 @@ int build_device_JSON(struct aqualinkdata *aqdata, char* buffer, int size, bool
|
|||
//return length;
|
||||
}
|
||||
|
||||
int logmaskjsonobject(int16_t flag, char* buffer)
|
||||
int logmaskjsonobject(logmask_t flag, char* buffer)
|
||||
{
|
||||
int length = sprintf(buffer, "{\"name\":\"%s\",\"id\":\"%d\",\"set\":\"%s\"},", logmask2name(flag), flag,(isDebugLogMaskSet(flag)?JSON_ON:JSON_OFF));
|
||||
return length;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "simulator.h"
|
||||
#include "hassio.h"
|
||||
#include "version.h"
|
||||
#include "color_lights.h"
|
||||
|
||||
#ifdef AQ_PDA
|
||||
#include "pda.h"
|
||||
|
@ -939,6 +940,18 @@ void mqtt_broadcast_aqualinkstate(struct mg_connection *nc)
|
|||
send_mqtt_aux_msg(nc, _aqualink_data->pumps[i].button->name, PUMP_STATUS_TOPIC, pumpStatus);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over programmable lights
|
||||
for (i=0; i < _aqualink_data->num_lights; i++) {
|
||||
char topic[50];
|
||||
if ( _aqualink_data->lights[i].currentValue != TEMP_UNKNOWN && _aqualink_data->lights[i].currentValue != _last_mqtt_aqualinkdata.lights[i].currentValue ) {
|
||||
_last_mqtt_aqualinkdata.lights[i].currentValue = _aqualink_data->lights[i].currentValue;
|
||||
send_mqtt_aux_msg(nc, _aqualink_data->lights[i].button->name, LIGHT_PROGRAM_TOPIC, _aqualink_data->lights[i].currentValue);
|
||||
|
||||
sprintf(topic, "%s%s/name", _aqualink_data->lights[i].button->name, LIGHT_PROGRAM_TOPIC);
|
||||
send_mqtt_string_msg(nc, topic, light_mode_name(_aqualink_data->lights[i].lightType, _aqualink_data->lights[i].currentValue - 1, ALLBUTTON));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1077,8 +1090,25 @@ uriAtype action_URI(request_source from, const char *URI, int uri_length, float
|
|||
return uActioned;
|
||||
} else if (strncmp(ri1, "seriallogger", 12) == 0 && from == NET_WS) { // Only valid from websocket.
|
||||
LOG(NET_LOG,LOG_NOTICE, "Received request to run serial_logger!\n");
|
||||
//LOG(NET_LOG,LOG_NOTICE, "Received request ri1=%s, ri2=%s, ri3=%s value=%f\n",ri1,ri2,ri3,value);
|
||||
_aqualink_data->slogger_packets = round(value);
|
||||
if (ri2 != NULL) {
|
||||
//MIN( 19, (ri3 - ri2));
|
||||
snprintf(_aqualink_data->slogger_ids, MIN( 19, (ri3 - ri2)+1 ), ri2); // 0x01 0x02 0x03 0x04
|
||||
} else {
|
||||
_aqualink_data->slogger_ids[0] = '\0';
|
||||
}
|
||||
if (ri3 != NULL && strncmp(ri3, "true", 4) == 0) {
|
||||
_aqualink_data->slogger_debug = true;
|
||||
} else {
|
||||
_aqualink_data->slogger_debug = false;
|
||||
}
|
||||
//LOG(NET_LOG,LOG_NOTICE, "Received request to run serial_logger (%d,%s,%s)!\n",
|
||||
// _aqualink_data->slogger_packets,
|
||||
// _aqualink_data->slogger_ids[0]!='\0'?_aqualink_data->slogger_ids:" ",
|
||||
// _aqualink_data->slogger_debug?"debug":"" );
|
||||
_aqualink_data->run_slogger = true;
|
||||
return uActioned;
|
||||
return uActioned;
|
||||
#else // AQ_MANAGER
|
||||
} else if (strncmp(ri1, "aqmanager", 9) == 0 && from == NET_WS) { // Only valid from websocket.
|
||||
return uNotAvailable;
|
||||
|
@ -1947,6 +1977,10 @@ void reset_last_mqtt_status()
|
|||
//_last_mqtt_aqualinkdata.pumps[i].driveState = TEMP_UNKNOWN;
|
||||
}
|
||||
|
||||
for (i=0; i < _aqualink_data->num_lights; i++) {
|
||||
_last_mqtt_aqualinkdata.lights[i].currentValue = TEMP_UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void start_mqtt(struct mg_mgr *mgr) {
|
||||
|
|
|
@ -15,8 +15,8 @@ static bool _logfile_packets = false;
|
|||
//static bool _includePentair = false;
|
||||
static unsigned char _lastReadFrom = NUL;
|
||||
|
||||
void _logPacket(int16_t from, unsigned char *packet_buffer, int packet_length, bool error, bool force, bool is_read);
|
||||
int _beautifyPacket(char *buff, unsigned char *packet_buffer, int packet_length, bool error, bool is_read);
|
||||
void _logPacket(logmask_t from, unsigned char *packet_buffer, int packet_length, bool error, bool force, bool is_read);
|
||||
int _beautifyPacket(char *buff, int buff_size, unsigned char *packet_buffer, int packet_length, bool error, bool is_read);
|
||||
|
||||
//void startPacketLogger(bool debug_RSProtocol_packets) {
|
||||
void startPacketLogger() {
|
||||
|
@ -88,12 +88,12 @@ void logPacketError(unsigned char *packet_buffer, int packet_length) {
|
|||
_logPacket(RSSD_LOG, packet_buffer, packet_length, true, false, true);
|
||||
}
|
||||
|
||||
void debuglogPacket(int16_t from, unsigned char *packet_buffer, int packet_length, bool is_read) {
|
||||
if ( getLogLevel(from) >= LOG_DEBUG )
|
||||
_logPacket(from, packet_buffer, packet_length, false, true, is_read);
|
||||
void debuglogPacket(logmask_t from, unsigned char *packet_buffer, int packet_length, bool is_read, bool forcelog) {
|
||||
if ( forcelog == true || getLogLevel(from) >= LOG_DEBUG )
|
||||
_logPacket(from, packet_buffer, packet_length, false, forcelog, is_read);
|
||||
}
|
||||
|
||||
void _logPacket(int16_t from, unsigned char *packet_buffer, int packet_length, bool error, bool force, bool is_read)
|
||||
void _logPacket(logmask_t from, unsigned char *packet_buffer, int packet_length, bool error, bool force, bool is_read)
|
||||
{
|
||||
// No point in continuing if loglevel is < debug_serial and not writing to file
|
||||
if ( force == false &&
|
||||
|
@ -119,31 +119,34 @@ void _logPacket(int16_t from, unsigned char *packet_buffer, int packet_length, b
|
|||
}
|
||||
*/
|
||||
}
|
||||
//char buff[1000];
|
||||
char buff[LARGELOGBUFFER];
|
||||
|
||||
char buff[1000];
|
||||
|
||||
_beautifyPacket(buff, packet_buffer, packet_length, error, is_read);
|
||||
int len = _beautifyPacket(buff, LARGELOGBUFFER, packet_buffer, packet_length, error, is_read);
|
||||
|
||||
if (_logfile_packets)
|
||||
writePacketLog(buff);
|
||||
|
||||
if (error == true)
|
||||
LOG(from,LOG_WARNING, "%s", buff);
|
||||
LOG_LARGEMSG(from,LOG_WARNING, buff, len);
|
||||
else {
|
||||
if (force)
|
||||
LOG(from,LOG_DEBUG, "%s", buff);
|
||||
if (force) {
|
||||
LOG_LARGEMSG(from, getSystemLogLevel()<LOG_DEBUG?getSystemLogLevel():LOG_DEBUG, buff, len);
|
||||
//LOG_LARGEMSG(from, LOG_DEBUG, buff, len);
|
||||
}
|
||||
//else if (is_read && _aqconfig_.serial_debug_filter != NUL && _aqconfig_.serial_debug_filter == packet_buffer[PKT_DEST])
|
||||
// LOG(from,LOG_NOTICE, "%s", buff);
|
||||
else
|
||||
LOG(from,LOG_DEBUG_SERIAL, "%s", buff);
|
||||
else {
|
||||
LOG_LARGEMSG(from,LOG_DEBUG_SERIAL, buff, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int beautifyPacket(char *buff, unsigned char *packet_buffer, int packet_length, bool is_read)
|
||||
int beautifyPacket(char *buff, int buff_size, unsigned char *packet_buffer, int packet_length, bool is_read)
|
||||
{
|
||||
return _beautifyPacket(buff, packet_buffer, packet_length, false, is_read);
|
||||
return _beautifyPacket(buff, buff_size, packet_buffer, packet_length, false, is_read);
|
||||
}
|
||||
int _beautifyPacket(char *buff, unsigned char *packet_buffer, int packet_length, bool error, bool is_read)
|
||||
int _beautifyPacket(char *buff, int buff_size, unsigned char *packet_buffer, int packet_length, bool error, bool is_read)
|
||||
{
|
||||
int i = 0;
|
||||
int cnt = 0;
|
||||
|
@ -163,8 +166,13 @@ int _beautifyPacket(char *buff, unsigned char *packet_buffer, int packet_length,
|
|||
cnt = sprintf(buff, "%5.5s %sTo 0x%02hhx of type %16.16s | HEX: ",(is_read?"Read":"Write"),(error?"BAD PACKET ":""), packet_buffer[PKT_DEST], get_packet_type(packet_buffer, packet_length));
|
||||
}
|
||||
*/
|
||||
for (i = 0; i < packet_length; i++)
|
||||
for (i = 0; i < packet_length; i++) {
|
||||
// Check we have enough space for next set of chars
|
||||
if ( (cnt + 6) > buff_size)
|
||||
break;
|
||||
|
||||
cnt += sprintf(buff + cnt, "0x%02hhx|", packet_buffer[i]);
|
||||
}
|
||||
|
||||
cnt += sprintf(buff + cnt, "\n");
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#define RS485LOGFILE "/tmp/RS485.log"
|
||||
#define RS485BYTELOGFILE "/tmp/RS485raw.log"
|
||||
|
||||
|
@ -21,7 +23,7 @@ void logPacketByte(unsigned char *byte);
|
|||
|
||||
// Only use for manual debugging
|
||||
//void debuglogPacket(unsigned char *packet_buffer, int packet_length);
|
||||
void debuglogPacket(int16_t from, unsigned char *packet_buffer, int packet_length, bool is_read);
|
||||
int beautifyPacket(char *buff, unsigned char *packet_buffer, int packet_length, bool is_read);
|
||||
void debuglogPacket(logmask_t from, unsigned char *packet_buffer, int packet_length, bool is_read, bool forcelog);
|
||||
int beautifyPacket(char *buff, int buff_size, unsigned char *packet_buffer, int packet_length, bool is_read);
|
||||
|
||||
#endif //PACKETLOGGER_H_
|
|
@ -41,7 +41,7 @@
|
|||
#define SLOG_MAX 80
|
||||
#define PACKET_MAX 800
|
||||
|
||||
#define VERSION "serial_logger V2.4"
|
||||
#define VERSION "serial_logger V2.5"
|
||||
|
||||
/*
|
||||
typedef enum used {
|
||||
|
@ -99,14 +99,46 @@ void broadcast_log(char *msg){
|
|||
}
|
||||
void intHandler(int dummy) {
|
||||
_keepRunning = false;
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Stopping!\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Stopping!\n");
|
||||
if (_playback_file) // If we are reading file, loop is irevelent
|
||||
exit(0);
|
||||
}
|
||||
#else
|
||||
int serial_logger (int rs_fd, char *port_name, int logLevel) {
|
||||
return _serial_logger(rs_fd, port_name, PACKET_MAX, (logLevel>=LOG_NOTICE?logLevel:LOG_NOTICE), true, false, false, false, false);
|
||||
int serial_logger (int rs_fd, char *port_name, int logLevel, int slogger_packets, char *slogger_ids)
|
||||
{
|
||||
int packets=PACKET_MAX;
|
||||
unsigned int n;
|
||||
int i=0;
|
||||
|
||||
// Reset some globals so we run.
|
||||
_filters=0;
|
||||
_pfilters=0;
|
||||
_keepRunning = true;
|
||||
|
||||
if (slogger_packets > 0)
|
||||
packets = slogger_packets;
|
||||
|
||||
int id_len = strlen(slogger_ids)-4;
|
||||
|
||||
//LOG(SLOG_LOG, LOG_NOTICE, "Jandy filter len=%d\n",id_len);
|
||||
for (i=0; i <= id_len; i=i+5) {
|
||||
//LOG(SLOG_LOG, LOG_NOTICE, "Jandy filter loop i=%d\n",i);
|
||||
if (slogger_ids[i] == '0' && slogger_ids[i+1] == 'x') {
|
||||
//LOG(SLOG_LOG, LOG_NOTICE, "Jandy filter loop %d %d\n",slogger_ids[i],slogger_ids[i+1]);
|
||||
sscanf(&slogger_ids[i], "0x%2x", &n);
|
||||
if (n != 0) {
|
||||
_filter[_filters] = n;
|
||||
_filters++;
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Add Jandy filter %i 0x%02hhx\n",_filters, _filter[_filters-1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Running serial logger with %d pakets, loglevel %s\n",packets,elevel2text(logLevel>=LOG_NOTICE?logLevel:LOG_NOTICE) );
|
||||
|
||||
return _serial_logger(rs_fd, port_name, packets, (logLevel>=LOG_NOTICE?logLevel:LOG_NOTICE), true, false, false, false, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define MASTER " <-- Master control panel"
|
||||
|
@ -123,6 +155,10 @@ int serial_logger (int rs_fd, char *port_name, int logLevel) {
|
|||
#define CHEM " <-- Chemlink"
|
||||
#define JXI_HEATER " <-- LXi / LRZ Heater"
|
||||
|
||||
#define IAQLNK2 " <-- iAqualink 2.0"
|
||||
#define HEAT_PUMP " <-- Heat Pump"
|
||||
#define REM_PWR_CENT " <-- Remote Power Center"
|
||||
|
||||
#define UNKNOWN " <-- Unknown Device"
|
||||
|
||||
#define P_VSP " <-- Pentair VSP"
|
||||
|
@ -136,31 +172,52 @@ int serial_logger (int rs_fd, char *port_name, int logLevel) {
|
|||
const char *getDevice(unsigned char ID) {
|
||||
if (ID >= 0x00 && ID <= 0x03)
|
||||
return MASTER;
|
||||
|
||||
if (ID >= 0x08 && ID <= 0x0B)
|
||||
return KEYPAD;
|
||||
|
||||
if (ID >= 0x50 && ID <= 0x53)
|
||||
return SWG;
|
||||
|
||||
if (ID >= 0x20 && ID <= 0x23)
|
||||
return SPA_R;
|
||||
|
||||
if (ID >= 0x30 && ID <= 0x33)
|
||||
return AQUA;
|
||||
|
||||
if (ID >= 0x38 && ID <= 0x3B)
|
||||
return LX_HEATER;
|
||||
|
||||
if (ID >= 0x40 && ID <= 0x43)
|
||||
return ONE_T;
|
||||
|
||||
if (ID >= 0x48 && ID <= 0x4B)
|
||||
return RS_SERL;
|
||||
|
||||
if (ID >= 0x58 && ID <= 0x5B)
|
||||
return PC_DOCK;
|
||||
|
||||
if (ID >= 0x60 && ID <= 0x63)
|
||||
return PDA;
|
||||
|
||||
if (ID >= 0x68 && ID <= 0x6B)
|
||||
return JXI_HEATER;
|
||||
//if (ID >= 0x70 && ID <= 0x73)
|
||||
|
||||
if (ID >= 0x70 && ID <= 0x73)
|
||||
return HEAT_PUMP;
|
||||
|
||||
if (ID >= 0x78 && ID <= 0x7B)
|
||||
return EPUMP;
|
||||
|
||||
if (ID >= 0x80 && ID <= 0x83)
|
||||
return CHEM;
|
||||
|
||||
if (ID >= 0xA0 && ID <= 0xA3)
|
||||
return IAQLNK2;
|
||||
|
||||
if (ID >= 0x28 && ID <= 0x2B)
|
||||
return REM_PWR_CENT;
|
||||
|
||||
//if (ID == 0x08)
|
||||
// return KEYPAD;
|
||||
|
||||
|
@ -310,6 +367,45 @@ void getPanelInfo(int rs_fd, unsigned char *packet_buffer, int packet_length)
|
|||
|
||||
}
|
||||
|
||||
bool filterMatch(unsigned char ID, unsigned char *packet_buffer, bool failNoFilters) {
|
||||
int i;
|
||||
|
||||
//printf("Check 0x%02hhx & 0x%02hhx - ",ID,packet_buffer[PKT_DEST]);
|
||||
|
||||
if (_filters != 0 || _pfilters != 0)
|
||||
{
|
||||
bool dest_match = false;
|
||||
bool src_match = false;
|
||||
bool pent_match = false;
|
||||
|
||||
if (_filters != 0) {
|
||||
for (i=0; i < _filters; i++) {
|
||||
if ( packet_buffer[PKT_DEST] == _filter[i])
|
||||
dest_match = true;
|
||||
if ( ID == _filter[i] && packet_buffer[PKT_DEST] == 0x00 )
|
||||
src_match = true;
|
||||
}
|
||||
}
|
||||
if (_pfilters != 0) {
|
||||
for (i=0; i < _pfilters; i++) {
|
||||
if ( packet_buffer[PEN_PKT_FROM] == _pfilter[i] ||
|
||||
packet_buffer[PEN_PKT_DEST] == _pfilter[i] )
|
||||
pent_match = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(dest_match == false && src_match == false && pent_match == false) {
|
||||
//printf("don't print\n");
|
||||
return false;
|
||||
}
|
||||
} else if (failNoFilters) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//printf("print\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SERIAL_LOGGER
|
||||
|
||||
void printHex(char *pk, int length)
|
||||
|
@ -332,6 +428,10 @@ void printPacket(unsigned char ID, unsigned char *packet_buffer, int packet_leng
|
|||
return;
|
||||
}
|
||||
|
||||
if ( filterMatch(ID, packet_buffer, false) == false ) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
// if filter is set and not match, then return without printing.
|
||||
if (_filters != 0 || _pfilters != 0)
|
||||
{
|
||||
|
@ -358,7 +458,7 @@ void printPacket(unsigned char ID, unsigned char *packet_buffer, int packet_leng
|
|||
if(dest_match == false && src_match == false && pent_match == false)
|
||||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
if (message != NULL)
|
||||
printf("%s",message);
|
||||
|
||||
|
@ -491,7 +591,7 @@ int main(int argc, char *argv[]) {
|
|||
if (_playback_file) {
|
||||
rs_fd = open(argv[1], O_RDONLY | O_NOCTTY | O_NONBLOCK | O_NDELAY);
|
||||
if (rs_fd < 0) {
|
||||
LOG(RSSD_LOG, LOG_ERR, "Unable to open file: %s\n", argv[1]);
|
||||
LOG(SLOG_LOG, LOG_ERR, "Unable to open file: %s\n", argv[1]);
|
||||
displayLastSystemError(argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -502,7 +602,7 @@ int main(int argc, char *argv[]) {
|
|||
rs_fd = init_blocking_serial_port(argv[1]);
|
||||
|
||||
if (rs_fd < 0) {
|
||||
LOG(RSSD_LOG, LOG_ERR, "Unable to open port: %s\n", argv[1]);
|
||||
LOG(SLOG_LOG, LOG_ERR, "Unable to open port: %s\n", argv[1]);
|
||||
displayLastSystemError(argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -512,14 +612,14 @@ int main(int argc, char *argv[]) {
|
|||
signal(SIGTERM, intHandler);
|
||||
|
||||
if (!errorMonitor) {
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Logging serial information!\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Logging serial information!\n");
|
||||
} else {
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Logging serial errors!\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Logging serial errors!\n");
|
||||
}
|
||||
if (_aqconfig_.log_protocol_packets)
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Logging packets to %s!\n",RS485LOGFILE);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Logging packets to %s!\n",RS485LOGFILE);
|
||||
if (_aqconfig_.log_raw_bytes)
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Logging raw bytes to %s!\n",RS485BYTELOGFILE);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Logging raw bytes to %s!\n",RS485BYTELOGFILE);
|
||||
|
||||
if (logLevel < LOG_DEBUG && errorMonitor==false )
|
||||
printf("Please wait.");
|
||||
|
@ -568,7 +668,7 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
|
||||
while (_keepRunning == true) {
|
||||
if (rs_fd < 0) {
|
||||
LOG(RSSD_LOG, LOG_ERR, "ERROR, serial port disconnect\n");
|
||||
LOG(SLOG_LOG, LOG_ERR, "ERROR, serial port disconnect\n");
|
||||
}
|
||||
|
||||
packet_length = get_packet(rs_fd, packet_buffer);
|
||||
|
@ -582,27 +682,27 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
|
||||
if (packet_length == AQSERR_READ) {
|
||||
// Unrecoverable read error. Force an attempt to reconnect.
|
||||
LOG(RSSD_LOG, LOG_ERR, "ERROR, on serial port! Please check %s\n",port_name);
|
||||
LOG(SLOG_LOG, LOG_ERR, "ERROR, on serial port! Please check %s\n",port_name);
|
||||
_keepRunning = false;
|
||||
returnError = true;
|
||||
} else if (packet_length == AQSERR_TIMEOUT) {
|
||||
// Unrecoverable read error. Force an attempt to reconnect.
|
||||
LOG(RSSD_LOG, LOG_ERR, "ERROR, Timeout on serial port, nothing read! Please check %s\n",port_name);
|
||||
LOG(SLOG_LOG, LOG_ERR, "ERROR, Timeout on serial port, nothing read! Please check %s\n",port_name);
|
||||
_keepRunning = false;
|
||||
returnError = true;
|
||||
} else if (packet_length < 0) {
|
||||
// Error condition
|
||||
if (errorMonitor && last_packet_length > 0) { // Error packet wwould have already been printed.
|
||||
char buff[900];
|
||||
beautifyPacket(buff, last_packet_buffer, last_packet_length, true);
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Previous packet (before error)\n");
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "%s------------------------------\n",buff);
|
||||
//LOG(RSSD_LOG, LOG_NOTICE, "\n");
|
||||
char buff[1024];
|
||||
beautifyPacket(buff, 1024, last_packet_buffer, last_packet_length, true);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Previous packet (before error)\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "%s------------------------------\n",buff);
|
||||
//LOG(SLOG_LOG, LOG_NOTICE, "\n");
|
||||
}
|
||||
} else if (packet_length == 0) {
|
||||
// Nothing read
|
||||
if (++blankReads > (rsSerialSpeedTest?100000000:1000) ) {
|
||||
LOG(RSSD_LOG, LOG_ERR, "ERROR, too many blank reads! Please check %s\n",port_name);
|
||||
LOG(SLOG_LOG, LOG_ERR, "ERROR, too many blank reads! Please check %s\n",port_name);
|
||||
_keepRunning = false;
|
||||
returnError = true;
|
||||
}
|
||||
|
@ -610,10 +710,14 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
delay(1);
|
||||
} else if (packet_length > 0) {
|
||||
blankReads = 0;
|
||||
//LOG(RSSD_LOG, LOG_DEBUG_SERIAL, "Received Packet for ID 0x%02hhx of type %s\n", packet_buffer[PKT_DEST], get_packet_type(packet_buffer, packet_length));
|
||||
//LOG(SLOG_LOG, LOG_DEBUG_SERIAL, "Received Packet for ID 0x%02hhx of type %s\n", packet_buffer[PKT_DEST], get_packet_type(packet_buffer, packet_length));
|
||||
#ifdef SERIAL_LOGGER
|
||||
if (logLevel > LOG_NOTICE)
|
||||
printPacket(lastID, packet_buffer, packet_length, timePackets?extra_message:NULL);
|
||||
#else
|
||||
if (logLevel >= LOG_DEBUG || filterMatch(lastID, packet_buffer, true)) {
|
||||
debuglogPacket(SLOG_LOG, packet_buffer, packet_length, true, true);
|
||||
}
|
||||
#endif
|
||||
if (getProtocolType(packet_buffer) == PENTAIR) {
|
||||
found = false;
|
||||
|
@ -646,7 +750,7 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
}
|
||||
|
||||
if (packet_buffer[PKT_DEST] == DEV_MASTER /*&& packet_buffer[PKT_CMD] == CMD_ACK*/) {
|
||||
//LOG(RSSD_LOG, LOG_NOTICE, "ID is in use 0x%02hhx %x\n", lastID, lastID);
|
||||
//LOG(SLOG_LOG, LOG_NOTICE, "ID is in use 0x%02hhx %x\n", lastID, lastID);
|
||||
for (i = 0; i <= sindex; i++) {
|
||||
if (slog[i].ID == lastID) {
|
||||
slog[i].inuse = true;
|
||||
|
@ -669,7 +773,7 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
|
||||
if (packet_length > 0 && packet_buffer[PKT_DEST] != 0x00) {
|
||||
// Only test for packets from panel, when you test to panel you are timing reply.
|
||||
LOG(RSSD_LOG, LOG_ERR, "SERIOUS RS485 ERROR, Slow serial port read detected, (check RS485 adapteer / os performance / USB serial speed\n");
|
||||
LOG(SLOG_LOG, LOG_ERR, "SERIOUS RS485 ERROR, Slow serial port read detected, (check RS485 adapteer / os performance / USB serial speed\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -677,7 +781,7 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
|
||||
#ifndef SERIAL_LOGGER
|
||||
if(received_packets%100==0) {
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Read %d of %d packets\n", received_packets, logPackets);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Read %d of %d packets\n", received_packets, logPackets);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -711,42 +815,42 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
|
||||
sl_timespec_subtract(&elapsed, &end_time, &start_time);
|
||||
|
||||
LOG(RSSD_LOG, LOG_DEBUG, "\n\n");
|
||||
LOG(SLOG_LOG, LOG_DEBUG, "\n\n");
|
||||
if (logLevel < LOG_DEBUG)
|
||||
printf("\n\n");
|
||||
|
||||
if (sindex >= SLOG_MAX)
|
||||
LOG(RSSD_LOG, LOG_ERR, "Ran out of storage, some ID's were not captured, please increase SLOG_MAX and recompile\n");
|
||||
LOG(SLOG_LOG, LOG_ERR, "Ran out of storage, some ID's were not captured, please increase SLOG_MAX and recompile\n");
|
||||
|
||||
if (elapsed.tv_sec > 0) {
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "RS485 interface received %d packets in %d seconds (~%.2f Msg/Sec)\n", received_packets, elapsed.tv_sec, (received_packets / (float)elapsed.tv_sec) );
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "RS485 interface received %d packets in %d seconds (~%.2f Msg/Sec)\n", received_packets, elapsed.tv_sec, (received_packets / (float)elapsed.tv_sec) );
|
||||
}
|
||||
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Jandy Control Panel Model : %s\n", _panelType);
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Jandy Control Panel Version : %s\n", _panelRev);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Jandy Control Panel Model : %s\n", _panelType);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Jandy Control Panel Version : %s\n", _panelRev);
|
||||
|
||||
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Jandy ID's found\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Jandy ID's found\n");
|
||||
for (i = 0; i < sindex; i++) {
|
||||
//LOG(RSSD_LOG, LOG_NOTICE, "ID 0x%02hhx is %s %s\n", slog[i].ID, (slog[i].inuse == true) ? "in use" : "not used",
|
||||
//LOG(SLOG_LOG, LOG_NOTICE, "ID 0x%02hhx is %s %s\n", slog[i].ID, (slog[i].inuse == true) ? "in use" : "not used",
|
||||
// (slog[i].inuse == false && canUse(slog[i].ID) == true)? " <-- can use for Aqualinkd" : "");
|
||||
//if (logLevel >= LOG_DEBUG || slog[i].inuse == true || canUse(slog[i].ID) == true) {
|
||||
if (logLevel >= LOG_DEBUG || slog[i].inuse == true || canUse(slog[i].ID) == true || printAllIDs == true) {
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "ID 0x%02hhx is %s %s\n", slog[i].ID, (slog[i].inuse == true) ? "in use " : "not used",
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "ID 0x%02hhx is %s %s\n", slog[i].ID, (slog[i].inuse == true) ? "in use " : "not used",
|
||||
(slog[i].inuse == false)?canUseExtended(slog[i].ID):getDevice(slog[i].ID));
|
||||
}
|
||||
}
|
||||
|
||||
if (pent_sindex > 0) {
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "\n\n");
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Pentair ID's found\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "\n\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Pentair ID's found\n");
|
||||
}
|
||||
for (i=0; i < pent_sindex; i++) {
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "ID 0x%02hhx is %s %s\n", pent_slog[i].ID, (pent_slog[i].inuse == true) ? "in use " : "not used",
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "ID 0x%02hhx is %s %s\n", pent_slog[i].ID, (pent_slog[i].inuse == true) ? "in use " : "not used",
|
||||
(pent_slog[i].inuse == false)?canUseExtended(pent_slog[i].ID):getPentairDevice(pent_slog[i].ID));
|
||||
}
|
||||
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "\n\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "\n\n");
|
||||
|
||||
|
||||
char mainID = 0x00;
|
||||
|
@ -778,21 +882,21 @@ int _serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, boo
|
|||
}
|
||||
|
||||
}
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "Suggested aqualinkd.conf values\n");
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "-------------------------\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Suggested aqualinkd.conf values\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "-------------------------\n");
|
||||
if (strlen (_panelType) > 0)
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "panel_type = %s\n",_panelType);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "panel_type = %s\n",_panelType);
|
||||
|
||||
if (mainID != 0x00)
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "device_id = 0x%02hhx\n",mainID);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "device_id = 0x%02hhx\n",mainID);
|
||||
|
||||
if (rssaID != 0x00)
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "rssa_device_id = 0x%02hhx\n",rssaID);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "rssa_device_id = 0x%02hhx\n",rssaID);
|
||||
|
||||
if (extID != 0x00)
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "extended_device_id = 0x%02hhx\n",extID);
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "extended_device_id = 0x%02hhx\n",extID);
|
||||
|
||||
LOG(RSSD_LOG, LOG_NOTICE, "-------------------------\n");
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "-------------------------\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ int logPackets = PACKET_MAX;
|
|||
//int serial_logger(int rs_fd, char *port_name);
|
||||
//int serial_logger(int rs_fd, char *port_name, int logPackets, int logLevel, bool panleProbe, bool rsSerialSpeedTest, bool errorMonitor);
|
||||
|
||||
int serial_logger (int rs_fd, char *port_name, int logLevel);
|
||||
//int serial_logger (int rs_fd, char *port_name, int logLevel);
|
||||
int serial_logger (int rs_fd, char *port_name, int logLevel, int slogger_packets, char *slogger_ids);
|
||||
void getPanelInfo(int rs_fd, unsigned char *packet_buffer, int packet_length);
|
||||
|
||||
#endif // SERIAL_LOGGER_H_
|
|
@ -59,9 +59,9 @@ bool processSimulatorPacket(unsigned char *packet, int packet_length, struct aqu
|
|||
aqdata->simulator_packet_length = packet_length;
|
||||
|
||||
if ( getLogLevel(SIM_LOG) >= LOG_DEBUG ) {
|
||||
char buff[1000];
|
||||
char buff[1024];
|
||||
//sprintf("Sending control command:")
|
||||
beautifyPacket(buff, packet, packet_length, false);
|
||||
beautifyPacket(buff, 1024, packet, packet_length, false);
|
||||
LOG(SIM_LOG,LOG_DEBUG, "Received message : %s", buff);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static int _cfg_log_level;
|
|||
static int _log_level = LOG_WARNING;
|
||||
|
||||
static char *_loq_display_message = NULL;
|
||||
int16_t _logforcemask = 0;
|
||||
logmask_t _logforcemask = 0;
|
||||
|
||||
//static char _log_filename[256];
|
||||
|
||||
|
@ -104,13 +104,14 @@ int getSystemLogLevel()
|
|||
{
|
||||
return _log_level;
|
||||
}
|
||||
int getLogLevel(int16_t from)
|
||||
int getLogLevel(logmask_t from)
|
||||
{
|
||||
|
||||
// RSSD_LOG should default to INFO unless the mask is explicitly set.
|
||||
// IE Even if DEBUG is set, (Note ignored for the moment)
|
||||
|
||||
if ( from == RSSD_LOG && ((_logforcemask & from) == from ) && _log_level < LOG_DEBUG_SERIAL)
|
||||
//if ( from == RSSD_LOG && ((_logforcemask & from) == from ) && _log_level < LOG_DEBUG_SERIAL)
|
||||
if ( (from == RSSD_LOG || from == SLOG_LOG) && ((_logforcemask & from) == from ) && _log_level < LOG_DEBUG_SERIAL)
|
||||
return LOG_DEBUG_SERIAL;
|
||||
else if ( ((_logforcemask & from) == from ) && _log_level < LOG_DEBUG_SERIAL)
|
||||
return LOG_DEBUG;
|
||||
|
@ -186,7 +187,7 @@ bool islogFileReady()
|
|||
/*
|
||||
* This function reports the last error
|
||||
*/
|
||||
void LOGSystemError (int errnum, int16_t from, const char *on_what)
|
||||
void LOGSystemError (int errnum, logmask_t from, const char *on_what)
|
||||
{
|
||||
fputs (strerror (errno), stderr);
|
||||
fputs (": ", stderr);
|
||||
|
@ -283,7 +284,7 @@ const char* loglevel2name(int level)
|
|||
return elevel2text(level);
|
||||
}
|
||||
|
||||
const char* logmask2name(int16_t from)
|
||||
const char* logmask2name(logmask_t from)
|
||||
{
|
||||
switch (from) {
|
||||
case NET_LOG:
|
||||
|
@ -328,6 +329,9 @@ const char* logmask2name(int16_t from)
|
|||
case SIM_LOG:
|
||||
return "Simulator: ";
|
||||
break;
|
||||
case SLOG_LOG:
|
||||
return "Serial Log:";
|
||||
break;
|
||||
case AQUA_LOG:
|
||||
default:
|
||||
return "AqualinkD: ";
|
||||
|
@ -478,12 +482,12 @@ void test(int msg_level, char *msg)
|
|||
}
|
||||
*/
|
||||
|
||||
void addDebugLogMask(int16_t flag)
|
||||
void addDebugLogMask(logmask_t flag)
|
||||
{
|
||||
_logforcemask |= flag;
|
||||
}
|
||||
|
||||
void removeDebugLogMask(int16_t flag)
|
||||
void removeDebugLogMask(logmask_t flag)
|
||||
{
|
||||
_logforcemask &= ~flag;
|
||||
}
|
||||
|
@ -493,12 +497,12 @@ void clearDebugLogMask()
|
|||
_logforcemask = 0;
|
||||
}
|
||||
|
||||
bool isDebugLogMaskSet(int16_t flag)
|
||||
bool isDebugLogMaskSet(logmask_t flag)
|
||||
{
|
||||
return _logforcemask & flag;
|
||||
}
|
||||
|
||||
void _LOG(int16_t from, int msg_level, char * message);
|
||||
void _LOG(logmask_t from, int msg_level, char * message);
|
||||
|
||||
/*
|
||||
void logMessage(int msg_level, const char *format, ...)
|
||||
|
@ -518,7 +522,27 @@ void logMessage(int msg_level, const char *format, ...)
|
|||
}
|
||||
*/
|
||||
|
||||
void LOG(int16_t from, int msg_level, const char * format, ...)
|
||||
#define LOG_OFFSET 20 // Number of chars for logging the type example "Info: iAQ Touch: "
|
||||
|
||||
void LOG_LARGEMSG(const logmask_t from, const int msg_level, const char *message, const int message_length)
|
||||
{
|
||||
// message_length is not used at present. But maybe in th future we can add a bufer using malloc and realloc that's
|
||||
// reused between calls and simply use realloc if it's not large enough.
|
||||
// Need to be careful, as it would also need to be thread safe.
|
||||
|
||||
if ( msg_level > getLogLevel(from))
|
||||
return;
|
||||
|
||||
char buffer[LARGELOGBUFFER + LOG_OFFSET + 1];
|
||||
|
||||
memset(buffer, ' ', LOG_OFFSET * sizeof(char));
|
||||
|
||||
strncpy(&buffer[LOG_OFFSET], message, LARGELOGBUFFER);
|
||||
|
||||
_LOG(from, msg_level, buffer);
|
||||
}
|
||||
|
||||
void LOG(const logmask_t from, const int msg_level, const char * format, ...)
|
||||
{
|
||||
//printf("msg_level=%d _log_level=%d mask=%d\n",msg_level,_log_level,(_logforcemask & from));
|
||||
/*
|
||||
|
@ -532,11 +556,13 @@ void LOG(int16_t from, int msg_level, const char * format, ...)
|
|||
char buffer[LOGBUFFER];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
strncpy(buffer, " ", 20);
|
||||
//strncpy(buffer, " ", 20);
|
||||
memset(buffer, ' ', LOG_OFFSET * sizeof(char));
|
||||
|
||||
//vsprintf (&buffer[20], format, args);
|
||||
int size = vsnprintf (&buffer[20], LOGBUFFER-30, format, args);
|
||||
int size = vsnprintf (&buffer[LOG_OFFSET], LOGBUFFER-LOG_OFFSET-10, format, args);
|
||||
va_end(args);
|
||||
if (size >= LOGBUFFER-30 ) {
|
||||
if (size >= LOGBUFFER-LOG_OFFSET-10 ) {
|
||||
sprintf(&buffer[LOGBUFFER-11], ".........\n");
|
||||
}
|
||||
|
||||
|
@ -544,20 +570,44 @@ void LOG(int16_t from, int msg_level, const char * format, ...)
|
|||
}
|
||||
|
||||
|
||||
void _LOG(int16_t from, int msg_level, char *message)
|
||||
void _LOG(logmask_t from, int msg_level, char *message)
|
||||
{
|
||||
/*
|
||||
message should have the first LOG_OFFSET (20) characters as spaces, this allows us to add Type & From to message.
|
||||
example " The Message ..... "
|
||||
we add "Warning: NetService:The Message ..... "
|
||||
Type is characters 0 to 8
|
||||
From is characters 9 to 20
|
||||
|
||||
*/
|
||||
|
||||
int i;
|
||||
|
||||
// Make all printable chars
|
||||
/*
|
||||
for(i = 8; i+8 < strlen(&message[8]) && i < LOGBUFFER; i++) {
|
||||
if ( (message[i] < 32 || message[i] > 125) && message[i] != 10 ) {
|
||||
//printf ("Change %c to %c in %s\n",message[i], ' ', message);
|
||||
message[i] = ' ';
|
||||
}
|
||||
}*/
|
||||
|
||||
int msglen = strlen(&message[LOG_OFFSET]);
|
||||
|
||||
// Fill first 20 chars and any non printable chars with a space.
|
||||
for(i = 0; i < LOGBUFFER && i < (msglen+LOG_OFFSET+1) ; i++) {
|
||||
if (i > LOG_OFFSET && message[i] == '\0')
|
||||
break;
|
||||
|
||||
if ( message[i] != 10 && message[i] != 13 && ( i < LOG_OFFSET || message[i] < 32 || message[i] > 125) ) {
|
||||
//printf ("Change %c to %c in %s\n",message[i], ' ', message);
|
||||
message[i] = ' ';
|
||||
}
|
||||
}
|
||||
// Add return to end of string if not already their.
|
||||
// NSF need to come back to this, doesn;t always work
|
||||
if (message[i] != '\n') {
|
||||
|
||||
// Add line feed to end of string if not already there.
|
||||
// i-1 == 10 and i == 0
|
||||
if (message[i] != '\0' || message[i-1] != '\n') {
|
||||
message[i] = '\n';
|
||||
message[i+1] = '\0';
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#endif
|
||||
|
||||
#define LOGBUFFER 256
|
||||
#define LARGELOGBUFFER 1400 // / Must be at least AQ_MAXPKTLEN * 5 + 100
|
||||
|
||||
//#define MAXLEN 256
|
||||
|
||||
|
@ -27,7 +28,9 @@
|
|||
#define roundf(a) (float) ((a*100)/100) // 2 decimal places
|
||||
#define roundf3(a) (float) ((a*1000)/1000) // 3 decimal places
|
||||
|
||||
// Defined as int16_t so 16 bits to mask
|
||||
|
||||
typedef int32_t logmask_t;
|
||||
// Defined as int32_t so 32 bits to mask
|
||||
#define AQUA_LOG (1 << 0) // Aqualink Generic / catchall
|
||||
#define NET_LOG (1 << 1) // Network
|
||||
// Control protocols
|
||||
|
@ -44,10 +47,12 @@
|
|||
#define PROG_LOG (1 << 10) // Programmer
|
||||
#define SCHD_LOG (1 << 11) // Scheduler Timer
|
||||
#define RSTM_LOG (1 << 12) // RS packet Time
|
||||
#define SIM_LOG (1 << 13) // Simulator
|
||||
#define SIM_LOG (1 << 13) // Simulator
|
||||
|
||||
#define DBGT_LOG (1 << 14) // Debug Timer
|
||||
|
||||
#define SLOG_LOG (1 << 15) // Serial_Logger
|
||||
|
||||
#define TIMR_LOG SCHD_LOG
|
||||
#define PANL_LOG PROG_LOG
|
||||
|
||||
|
@ -72,7 +77,7 @@ void setLoggingPrms(int level , bool deamonized, char *error_messages);
|
|||
#else
|
||||
void setLoggingPrms(int level , bool deamonized, char* log_file, char *error_messages);
|
||||
#endif
|
||||
int getLogLevel(int16_t from);
|
||||
int getLogLevel(logmask_t from);
|
||||
int getSystemLogLevel();
|
||||
void setSystemLogLevel( int level);
|
||||
void daemonise ( char *pidFile, void (*main_function)(void) );
|
||||
|
@ -80,11 +85,11 @@ void daemonise ( char *pidFile, void (*main_function)(void) );
|
|||
|
||||
|
||||
|
||||
void addDebugLogMask(int16_t flag);
|
||||
void removeDebugLogMask(int16_t flag);
|
||||
void addDebugLogMask(logmask_t flag);
|
||||
void removeDebugLogMask(logmask_t flag);
|
||||
void clearDebugLogMask();
|
||||
bool isDebugLogMaskSet(int16_t flag);
|
||||
const char* logmask2name(int16_t mask);
|
||||
bool isDebugLogMaskSet(logmask_t flag);
|
||||
const char* logmask2name(logmask_t mask);
|
||||
const char* loglevel2name(int level);
|
||||
//#define logMessage(msg_level, format, ...) LOG (1, msg_level, format, ##__VA_ARGS__)
|
||||
|
||||
|
@ -93,8 +98,10 @@ const char* loglevel2name(int level);
|
|||
|
||||
|
||||
//void LOG(int from, int level, char *format, ...);
|
||||
void LOG(int16_t from, int msg_level, const char *format, ...);
|
||||
void LOGSystemError (int errnum, int16_t from, const char *on_what);
|
||||
void LOG(const logmask_t from, const int msg_level, const char *format, ...);
|
||||
void LOG_LARGEMSG(const logmask_t from, const int msg_level, const char * buffer, const int buffer_length);
|
||||
|
||||
void LOGSystemError (int errnum, logmask_t from, const char *on_what);
|
||||
void displayLastSystemError (const char *on_what);
|
||||
|
||||
int count_characters(const char *str, char character);
|
||||
|
@ -134,9 +141,6 @@ char *getInlineLogFName();
|
|||
bool islogFileReady();
|
||||
#endif
|
||||
|
||||
|
||||
//const char *logmask2name(int16_t from);
|
||||
|
||||
//#ifndef _UTILS_C_
|
||||
extern bool _daemon_;
|
||||
extern bool _debuglog_;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
justify-content: center;
|
||||
/*border: 1px solid red;*/
|
||||
row-gap: 20px;
|
||||
|
||||
/*overflow-y: scroll; this only works if we know the height, we can caculate but not important at moment */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -698,6 +698,20 @@
|
|||
case "seriallog":
|
||||
cmd.uri = "seriallogger"
|
||||
break;
|
||||
case "seriallogWoptions":
|
||||
var ids = document.getElementById("slog_ids").value;
|
||||
if ( ids.length == 0 )
|
||||
ids='--';
|
||||
|
||||
cmd.uri = "seriallogger/"+ids+"/"+document.getElementById("slog_debug").checked;
|
||||
cmd.value = document.getElementById("slog_packets").value
|
||||
console.log("Command = "+cmd);
|
||||
//console.log("Packets=" + document.getElementById("slog_packets").value );
|
||||
//console.log("IDs=" + document.getElementById("slog_ids").value );
|
||||
//console.log("ListQueriedID=" + document.getElementById("slog_ids_queried").checked );
|
||||
//console.log("debug=" + document.getElementById("slog_debug").checked );
|
||||
//return; // REMOVE
|
||||
break;
|
||||
default:
|
||||
alert("Unknown button");
|
||||
return;
|
||||
|
@ -737,6 +751,10 @@
|
|||
<tr>
|
||||
<td colspan="2" align="center"><label id="statusmsg" class="statusmsg">status</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input id="restart" type="button" onclick="send(this);" value="Restart AqualinkD"></td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr>
|
||||
<td align="center">
|
||||
<input id="restart" type="button" onclick="send(this);" value="Restart AqualinkD">
|
||||
|
@ -745,6 +763,7 @@
|
|||
<input id="seriallog" type="button" onclick="send(this);" value="Run Serial Logger">
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
</table>
|
||||
<button class="collapsible" id="systembutton">System Information</button>
|
||||
<div class="content" id="system">
|
||||
|
@ -773,7 +792,7 @@
|
|||
<!-- Will be populated on load -->
|
||||
</div>
|
||||
<button class="collapsible">Log File</button>
|
||||
<div class="content" id="loglevels">
|
||||
<div class="content" id="logfile">
|
||||
<!--
|
||||
<label class="toggle logtoggle"><input class="toggle-checkbox" type="checkbox" id="logfile"
|
||||
onclick="setlogfile(this);">
|
||||
|
@ -797,6 +816,29 @@
|
|||
<div class="debugmasks content" id="debugmasks">
|
||||
<!-- Will be populated on load -->
|
||||
</div>
|
||||
<button class="collapsible">Serial Logger</button>
|
||||
<div class="content" id="seriallogger">
|
||||
<table border='0'>
|
||||
<tr>
|
||||
<td colspan="2" align="center"><input id="seriallogWoptions" type="button" onclick="send(this);" value="Run Serial Logger"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>#Packets</td>
|
||||
<td><input id="slog_packets" type="text" value="800" size="5"></input></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ID's <font size="-2">(Eg 0x08 0x10)</font></td>
|
||||
<td><input id="slog_ids" type="text" value="" size="15"></input></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Debug</td>
|
||||
<td><input id="slog_debug" type="checkbox"></input></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center">AqualinkD will be disabled while running</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<button class="collapsible">Config</button>
|
||||
<div class="content" id="config">
|
||||
<!-- Will be populated on load -->
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
"CHEM/pH",
|
||||
"CHEM/ORP",
|
||||
"Solar_Heater",
|
||||
"Extra_Aux",
|
||||
];
|
||||
|
||||
// This get's picked up by dynamic_config.js and used as mode 0
|
||||
|
|
Loading…
Reference in New Issue