From c9508d26607f288471938f7e82b1073a8d047e5d Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Thu, 7 Dec 2023 20:26:11 +0100 Subject: [PATCH] Doc: Added byte specification to each command --- .../commands/ActivePowerControlCommand.cpp | 22 ++++++++++++++-- .../src/commands/AlarmDataCommand.cpp | 20 +++++++++++++- .../src/commands/ChannelChangeCommand.cpp | 14 ++++++++++ lib/Hoymiles/src/commands/CommandAbstract.cpp | 26 ++++++++++++++++++- .../src/commands/DevControlCommand.cpp | 19 +++++++++++++- .../src/commands/DevInfoAllCommand.cpp | 18 ++++++++++++- .../src/commands/DevInfoSimpleCommand.cpp | 18 ++++++++++++- .../src/commands/GridOnProFilePara.cpp | 18 ++++++++++++- .../src/commands/MultiDataCommand.cpp | 23 ++++++++++++++++ .../src/commands/PowerControlCommand.cpp | 21 ++++++++++++++- .../src/commands/RealTimeRunDataCommand.cpp | 16 ++++++++++++ .../src/commands/RequestFrameCommand.cpp | 20 +++++++++++++- .../src/commands/SingleDataCommand.cpp | 17 +++++++++++- .../src/commands/SystemConfigParaCommand.cpp | 16 ++++++++++++ 14 files changed, 257 insertions(+), 11 deletions(-) diff --git a/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp b/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp index 78bcd55..cfbd75c 100644 --- a/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp +++ b/lib/Hoymiles/src/commands/ActivePowerControlCommand.cpp @@ -1,7 +1,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to send a limit to the inverter. + +Derives from DevControlCommand. + +Command structure: +SCmd: Sub-Command ID. Is always 0x0b +Limit: limit to be set in the inverter +Type: absolute / relative and persistant/non-persistant + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +------------------------------------------------------------------------------------------------------------------- + |<------ CRC16 ------>| +51 71 60 35 46 80 12 23 04 81 0b 00 00 00 00 00 00 00 00 -- -- -- -- -- -- -- -- -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Cmd SCmd ? Limit Type CRC16 CRC8 +*/ #include "ActivePowerControlCommand.h" #include "inverters/InverterAbstract.h" @@ -17,7 +35,7 @@ ActivePowerControlCommand::ActivePowerControlCommand(uint64_t target_address, ui _payload[14] = 0x00; _payload[15] = 0x00; - udpateCRC(CRC_SIZE); // 2 byte crc + udpateCRC(CRC_SIZE); // 6 byte crc _payload_size = 18; diff --git a/lib/Hoymiles/src/commands/AlarmDataCommand.cpp b/lib/Hoymiles/src/commands/AlarmDataCommand.cpp index 574e0be..49382c6 100644 --- a/lib/Hoymiles/src/commands/AlarmDataCommand.cpp +++ b/lib/Hoymiles/src/commands/AlarmDataCommand.cpp @@ -1,7 +1,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to fetch the eventlog from the inverter. + +Derives from MultiDataCommand + +Command structure: +* DT: this specific command uses 0x11 +* AlarmId: The last event id received from the inverter or zero in case that no events + has been received yet. --> Not Implemented yet + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------------- + |<------------------- CRC16 --------------------->| +15 71 60 35 46 80 12 23 04 80 11 00 65 72 06 B8 00 00 00 00 00 00 00 00 00 00 00 -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^ ^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Idx DT ? Time Gap AlarmId Password CRC16 CRC8 +*/ #include "AlarmDataCommand.h" #include "inverters/InverterAbstract.h" diff --git a/lib/Hoymiles/src/commands/ChannelChangeCommand.cpp b/lib/Hoymiles/src/commands/ChannelChangeCommand.cpp index 139bbea..c7e9dcd 100644 --- a/lib/Hoymiles/src/commands/ChannelChangeCommand.cpp +++ b/lib/Hoymiles/src/commands/ChannelChangeCommand.cpp @@ -2,6 +2,20 @@ /* * Copyright (C) 2023 Thomas Basler and others */ + +/* +Derives from CommandAbstract. Special command to set frequency channel on HMS/HMT inverters. + +Command structure: +* ID: fixed identifier and everytime 0x56 +* CH: Channel to which the inverter will be switched to + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------- +56 71 60 35 46 80 12 23 04 02 15 21 00 14 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^ ^^ ^^ +ID Target Addr Source Addr ? ? ? CH ? CRC8 +*/ #include "ChannelChangeCommand.h" ChannelChangeCommand::ChannelChangeCommand(uint64_t target_address, uint64_t router_address, uint8_t channel) diff --git a/lib/Hoymiles/src/commands/CommandAbstract.cpp b/lib/Hoymiles/src/commands/CommandAbstract.cpp index 78d8d07..1621306 100644 --- a/lib/Hoymiles/src/commands/CommandAbstract.cpp +++ b/lib/Hoymiles/src/commands/CommandAbstract.cpp @@ -1,7 +1,31 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +Command structure: +* Each package has a maximum of 32 bytes +* Target Address: the address of the inverter. Has to be read as hex value +* Source Address the address of the dtu itself. Has to be read as hex value +* CRC8: a crc8 checksum added to the end of the payload containing all valid data. + Each sub-commmand has to set it's own payload size. + +Conversion of Target Addr: +Inverter Serial Number: (0x)116171603546 +Target Address: 71 60 35 46 + +Conversion of Source Addr: +DTU Serial Number: (0x)199980122304 +Source Address: 80 12 23 04 + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------- +|<------------- CRC8 ------------>| +00 71 60 35 46 80 12 23 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ + Target Addr Source Addr CRC8 +*/ #include "CommandAbstract.h" #include "crc.h" #include diff --git a/lib/Hoymiles/src/commands/DevControlCommand.cpp b/lib/Hoymiles/src/commands/DevControlCommand.cpp index fce935b..d57b3de 100644 --- a/lib/Hoymiles/src/commands/DevControlCommand.cpp +++ b/lib/Hoymiles/src/commands/DevControlCommand.cpp @@ -1,8 +1,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +Derives from CommandAbstract. Has a variable length. + +Command structure: +* ID: fixed identifier and everytime 0x51 +* Cmd: Fixed at 0x81 for these types of commands +* Payload: dynamic amount of bytes +* CRC16: calcuclated over the highlighted amount of bytes + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +------------------------------------------------------------------------------------------------------------- + |<->| CRC16 +51 71 60 35 46 80 12 23 04 81 00 00 00 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^^^^ ^^ ^^ +ID Target Addr Source Addr Cmd Payload CRC16 CRC8 +*/ #include "DevControlCommand.h" #include "crc.h" diff --git a/lib/Hoymiles/src/commands/DevInfoAllCommand.cpp b/lib/Hoymiles/src/commands/DevInfoAllCommand.cpp index b175822..6820ba6 100644 --- a/lib/Hoymiles/src/commands/DevInfoAllCommand.cpp +++ b/lib/Hoymiles/src/commands/DevInfoAllCommand.cpp @@ -1,7 +1,23 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to fetch firmware information from the inverter. + +Derives from MultiDataCommand + +Command structure: +* DT: this specific command uses 0x01 + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------------- + |<------------------- CRC16 --------------------->| +15 71 60 35 46 80 12 23 04 80 01 00 65 72 06 B8 00 00 00 00 00 00 00 00 00 00 00 -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Idx DT ? Time Gap Password CRC16 CRC8 +*/ #include "DevInfoAllCommand.h" #include "inverters/InverterAbstract.h" diff --git a/lib/Hoymiles/src/commands/DevInfoSimpleCommand.cpp b/lib/Hoymiles/src/commands/DevInfoSimpleCommand.cpp index 09d5a46..3caccf7 100644 --- a/lib/Hoymiles/src/commands/DevInfoSimpleCommand.cpp +++ b/lib/Hoymiles/src/commands/DevInfoSimpleCommand.cpp @@ -1,7 +1,23 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to fetch hardware information from the inverter. + +Derives from MultiDataCommand + +Command structure: +* DT: this specific command uses 0x00 + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------------- + |<------------------- CRC16 --------------------->| +15 71 60 35 46 80 12 23 04 80 00 00 65 72 06 B8 00 00 00 00 00 00 00 00 00 00 00 -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Idx DT ? Time Gap Password CRC16 CRC8 +*/ #include "DevInfoSimpleCommand.h" #include "inverters/InverterAbstract.h" diff --git a/lib/Hoymiles/src/commands/GridOnProFilePara.cpp b/lib/Hoymiles/src/commands/GridOnProFilePara.cpp index e917167..5af8e46 100644 --- a/lib/Hoymiles/src/commands/GridOnProFilePara.cpp +++ b/lib/Hoymiles/src/commands/GridOnProFilePara.cpp @@ -1,7 +1,23 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to fetch the grid profile from the inverter. + +Derives from MultiDataCommand + +Command structure: +* DT: this specific command uses 0x02 + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------------- + |<------------------- CRC16 --------------------->| +15 71 60 35 46 80 12 23 04 80 02 00 65 72 06 B8 00 00 00 00 00 00 00 00 00 00 00 -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Idx DT ? Time Gap Password CRC16 CRC8 +*/ #include "GridOnProFilePara.h" #include "Hoymiles.h" #include "inverters/InverterAbstract.h" diff --git a/lib/Hoymiles/src/commands/MultiDataCommand.cpp b/lib/Hoymiles/src/commands/MultiDataCommand.cpp index 3964060..3b9e165 100644 --- a/lib/Hoymiles/src/commands/MultiDataCommand.cpp +++ b/lib/Hoymiles/src/commands/MultiDataCommand.cpp @@ -2,6 +2,29 @@ /* * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +Derives from CommandAbstract. Has a fixed length of 26 bytes. + +Command structure: +* ID: fixed identifier and everytime 0x15 +* Idx: the counter of sequencial packages to send. Currently it's only 0x80 + because all request requests only consist of one package. +* DT: repressents the data type and specifies which sub-command to be fetched +* Time: represents the current unix timestamp as hex format. The time on the inverter is synced to the sent time. + Can be calculated e.g. using the following command + echo "obase=16; $(date --date='2023-12-07 18:54:00' +%s)" | bc +* Gap: always 0x0 +* Password: currently always 0x0 +* CRC16: calcuclated over the highlighted amount of bytes + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------------- + |<------------------- CRC16 --------------------->| +15 71 60 35 46 80 12 23 04 80 00 00 65 72 06 B8 00 00 00 00 00 00 00 00 00 00 00 -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Idx DT ? Time Gap Password CRC16 CRC8 +*/ #include "MultiDataCommand.h" #include "crc.h" diff --git a/lib/Hoymiles/src/commands/PowerControlCommand.cpp b/lib/Hoymiles/src/commands/PowerControlCommand.cpp index 522ad5f..6698c84 100644 --- a/lib/Hoymiles/src/commands/PowerControlCommand.cpp +++ b/lib/Hoymiles/src/commands/PowerControlCommand.cpp @@ -1,7 +1,26 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to power cycle the inverter. + +Derives from DevControlCommand. + +Command structure: +SCmd: Sub-Command ID + 00 --> Turn On + 01 --> Turn Off + 02 --> Restart + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +--------------------------------------------------------------------------------------------------------------- + |<--->| CRC16 +51 71 60 35 46 80 12 23 04 81 00 00 00 00 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^ +ID Target Addr Source Addr Cmd SCmd ? CRC16 CRC8 +*/ #include "PowerControlCommand.h" #include "inverters/InverterAbstract.h" diff --git a/lib/Hoymiles/src/commands/RealTimeRunDataCommand.cpp b/lib/Hoymiles/src/commands/RealTimeRunDataCommand.cpp index 1be41f9..ccca087 100644 --- a/lib/Hoymiles/src/commands/RealTimeRunDataCommand.cpp +++ b/lib/Hoymiles/src/commands/RealTimeRunDataCommand.cpp @@ -2,6 +2,22 @@ /* * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to fetch live run time data from the inverter. + +Derives from MultiDataCommand + +Command structure: +* DT: this specific command uses 0x0b + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------------- + |<------------------- CRC16 --------------------->| +15 71 60 35 46 80 12 23 04 80 0b 00 65 72 06 B8 00 00 00 00 00 00 00 00 00 00 00 -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Idx DT ? Time Gap Password CRC16 CRC8 +*/ #include "RealTimeRunDataCommand.h" #include "Hoymiles.h" #include "inverters/InverterAbstract.h" diff --git a/lib/Hoymiles/src/commands/RequestFrameCommand.cpp b/lib/Hoymiles/src/commands/RequestFrameCommand.cpp index e2bfb76..0e379c3 100644 --- a/lib/Hoymiles/src/commands/RequestFrameCommand.cpp +++ b/lib/Hoymiles/src/commands/RequestFrameCommand.cpp @@ -1,7 +1,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to re-request a specific fragment returned by a MultiDataCommand from the inverter. + +Derives from SingleDataCommand. Has a fixed length of 10 bytes. + +Command structure: +* ID: fixed identifier and everytime 0x15 +* Idx: the counter of sequencial packages to send. Currently it's only 0x80 + because all request requests only consist of one package. +* Frm: is set to the fragment id to re-request. "Or" operation with 0x80 is applied to the frame. + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +--------------------------------------------------------------------------------------------------------- +15 71 60 35 46 80 12 23 04 85 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ +ID Target Addr Source Addr Frm CRC8 +*/ #include "RequestFrameCommand.h" RequestFrameCommand::RequestFrameCommand(uint64_t target_address, uint64_t router_address, uint8_t frame_no) diff --git a/lib/Hoymiles/src/commands/SingleDataCommand.cpp b/lib/Hoymiles/src/commands/SingleDataCommand.cpp index 636ee87..4915548 100644 --- a/lib/Hoymiles/src/commands/SingleDataCommand.cpp +++ b/lib/Hoymiles/src/commands/SingleDataCommand.cpp @@ -1,7 +1,22 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (C) 2022 Thomas Basler and others + * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to send simple commands, containing only one payload, to the inverter. + +Derives from CommandAbstract. + +Command structure: +* ID: fixed identifier and everytime 0x15 + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +--------------------------------------------------------------------------------------------------------- +15 71 60 35 46 80 12 23 04 00 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ +ID Target Addr Source Addr CRC8 +*/ #include "SingleDataCommand.h" SingleDataCommand::SingleDataCommand(uint64_t target_address, uint64_t router_address) diff --git a/lib/Hoymiles/src/commands/SystemConfigParaCommand.cpp b/lib/Hoymiles/src/commands/SystemConfigParaCommand.cpp index ca42f48..48a5623 100644 --- a/lib/Hoymiles/src/commands/SystemConfigParaCommand.cpp +++ b/lib/Hoymiles/src/commands/SystemConfigParaCommand.cpp @@ -2,6 +2,22 @@ /* * Copyright (C) 2022-2023 Thomas Basler and others */ + +/* +This command is used to fetch current set limits from the inverter. + +Derives from MultiDataCommand + +Command structure: +* DT: this specific command uses 0x05 + +00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 +----------------------------------------------------------------------------------------------------------------------- + |<------------------- CRC16 --------------------->| +15 71 60 35 46 80 12 23 04 80 05 00 65 72 06 B8 00 00 00 00 00 00 00 00 00 00 00 -- -- -- -- -- +^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^^ ^^^^^ ^^ +ID Target Addr Source Addr Idx DT ? Time Gap Password CRC16 CRC8 +*/ #include "SystemConfigParaCommand.h" #include "Hoymiles.h" #include "inverters/InverterAbstract.h"