Skip to content

Commit

Permalink
New class for Victron Chargers and first support for sending VE.Direc…
Browse files Browse the repository at this point in the history
…t hex commands

cleanup
  • Loading branch information
philippsandhaus committed Oct 20, 2023
1 parent 58cf701 commit 7d75895
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/VeDirectFrameHandler/VeDirectFrameHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,12 @@ void VeDirectFrameHandler::textRxEvent(char * name, char * value, veStruct& fram
=======
}



/*
* hexRxEvent
* This function records hex answers or async messages
*/
int VeDirectFrameHandler::hexRxEvent(uint8_t inbyte) {
int VeDirectFrameHandler::hexRxEvent(uint8_t inbyte)
{
int ret=RECORD_HEX; // default - continue recording until end of frame

switch (inbyte) {
Expand Down Expand Up @@ -469,6 +468,7 @@ template String const& VeDirectFrameHandler::getAsString(std::map<uint8_t, Strin
template String const& VeDirectFrameHandler::getAsString(std::map<uint16_t, String> const& values, uint16_t val);
template String const& VeDirectFrameHandler::getAsString(std::map<uint32_t, String> const& values, uint32_t val);


/*
* getPidAsString
* This function returns the product id (PID) as readable text.
Expand Down
3 changes: 2 additions & 1 deletion lib/VeDirectFrameHandler/VeDirectFrameHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define VE_MAX_VALUE_LEN 33 // VE.Direct Protocol: max value size is 33 including /0
#define VE_MAX_HEX_LEN 100 // Maximum size of hex frame - max payload 34 byte (=68 char) + safe buffer


// hex commands
enum VeDirectHexCommand {
ENTER_BOOT = 0x00,
Expand Down Expand Up @@ -55,7 +56,6 @@ class VeDirectFrameHandler {
bool _verboseLogging;
Print* _msgOut;
uint32_t _lastUpdate;

typedef struct {
uint16_t PID = 0; // product id
char SER[VE_MAX_VALUE_LEN]; // serial number
Expand All @@ -67,6 +67,7 @@ class VeDirectFrameHandler {
String getPidAsString() const; // product id as string
} veStruct;

void sendHexCommand(VeDirectHexCommand cmd, VeDirectHexId id, VeDirectFlag flag, uint16_t value);
bool textRxEvent(std::string const& who, char* name, char* value, veStruct& frame);
void sendHexCommand(VeDirectHexCommand cmd, VeDirectHexId id, VeDirectFlag flag, uint16_t value);
bool isDataValid(veStruct const& frame) const; // return true if data valid and not outdated
Expand Down

0 comments on commit 7d75895

Please sign in to comment.