diff --git a/.clang-format b/.clang-format index 558af559a..fe1790709 100644 --- a/.clang-format +++ b/.clang-format @@ -22,5 +22,6 @@ SpaceAfterCStyleCast: true AllowShortFunctionsOnASingleLine: Inline BreakBeforeBinaryOperators: None #AllowShortBlocksOnASingleLine: true +SortIncludes: false # google-readability-braces-around-statements diff --git a/cspell.json b/cspell.json new file mode 100644 index 000000000..3abaf2c92 --- /dev/null +++ b/cspell.json @@ -0,0 +1,9 @@ +{ + "version": "0.2", + "ignorePaths": [], + "dictionaryDefinitions": [], + "dictionaries": [], + "words": [], + "ignoreWords": [], + "import": [] +} diff --git a/database b/database index b1628d11a..941db6777 100644 Binary files a/database and b/database differ diff --git a/resources/database/vscp-hashtypeevents.sqlite3 b/resources/database/vscp-hashtypeevents.sqlite3 index b1628d11a..941db6777 100644 Binary files a/resources/database/vscp-hashtypeevents.sqlite3 and b/resources/database/vscp-hashtypeevents.sqlite3 differ diff --git a/src/vscp/common/vscp-bootdevice-pic1.cpp b/src/vscp/common/vscp-bootdevice-pic1.cpp index ca77139f2..909347b88 100644 --- a/src/vscp/common/vscp-bootdevice-pic1.cpp +++ b/src/vscp/common/vscp-bootdevice-pic1.cpp @@ -40,9 +40,9 @@ // #include #include +#include #include -#include -#include +#include /////////////////////////////////////////////////////////////////////////////// // Constructor @@ -228,14 +228,14 @@ CBootDevice_PIC1::deviceInfo(void) // int -CBootDevice_PIC1::deviceInit(cguid& ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail) +CBootDevice_PIC1::deviceInit(cguid &ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail) { int rv; // Save our local GUID m_ourguid = ourguid; - // Save Firmware device code + // Save Firmware device code m_firmwaredeviceCode = devicecode; /* @@ -359,7 +359,7 @@ CBootDevice_PIC1::deviceInit(cguid& ourguid, uint16_t devicecode, bool bAbortOnF // Set device in boot mode cguid guid; m_stdRegs.getGUID(guid); - msg.data[0] = (uint8_t)m_nodeid; // Nickname to read register from + msg.data[0] = (uint8_t) m_nodeid; // Nickname to read register from msg.data[1] = VSCP_BOOTLOADER_PIC1; // VSCP PIC1 bootloader algorithm msg.data[2] = guid.getAt(0); msg.data[3] = guid.getAt(3); @@ -566,7 +566,7 @@ int CBootDevice_PIC1::writeDeviceControlRegs(uint32_t addr, uint8_t flags, uint8_t cmd, uint8_t cmdData0, uint8_t cmdData1) { int rv; - //vscpEventEx event; + // vscpEventEx event; canalMsg msg; // Save the internal addresss @@ -640,7 +640,7 @@ CBootDevice_PIC1::checkResponseLevel1(uint32_t response_id) // Response received from all - return success spdlog::debug("checkResponseLevel1: RECEIVE OK"); if (nullptr != m_statusCallback) { - //m_statusCallback(-1, "checkResponseLevel1: Response received OK."); + // m_statusCallback(-1, "checkResponseLevel1: Response received OK."); } return VSCP_ERROR_SUCCESS; } @@ -688,7 +688,7 @@ CBootDevice_PIC1::checkResponseLevel2(uint32_t id) // Response received - return success spdlog::debug("checkResponseLevel2: RECEIVE OK"); if (nullptr != m_statusCallback) { - //m_statusCallback(-1, "checkResponseLevel2: Response received OK."); + // m_statusCallback(-1, "checkResponseLevel2: Response received OK."); } return VSCP_ERROR_SUCCESS; } @@ -855,7 +855,7 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end) } // Start at beginning - paddr += minAddr-start; + paddr += minAddr - start; for (uint32_t blk = 0; blk < nPackets; blk++) { spdlog::debug("Loading flash on remote device... block={0} {1:X}", blk, blk * 8); @@ -865,11 +865,11 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end) } paddr += 8; if (nullptr != m_statusCallback) { - m_statusCallback((100 * blk) / nPackets, ""/*vscp_str_format("blk %d.", blk).c_str()*/); + m_statusCallback((100 * blk) / nPackets, "" /*vscp_str_format("blk %d.", blk).c_str()*/); } } // for - } // code + } // code delete[] pbuf; return VSCP_ERROR_SUCCESS; @@ -882,18 +882,18 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end) int CBootDevice_PIC1::deviceLoad(std::function statusCallback, bool bAbortOnFirmwareCodeFail) { - //bool bRun = true; + // bool bRun = true; int rv; - m_checksum = 0; - //uint32_t progress = 0; + m_checksum = 0; + // uint32_t progress = 0; uint32_t addr = 0; std::string strStatus; - //uint8_t pbuf[BUFFER_SIZE_CODE]; - //uint32_t nPackets; - // uint32_t minAddr; - // uint32_t maxAddr; + // uint8_t pbuf[BUFFER_SIZE_CODE]; + // uint32_t nPackets; + // uint32_t minAddr; + // uint32_t maxAddr; if (nullptr != m_statusCallback) { m_statusCallback(0, "Starting firmware download"); diff --git a/src/vscp/common/vscp-bootdevice-pic1.h b/src/vscp/common/vscp-bootdevice-pic1.h index aef815f98..d84d49ccf 100644 --- a/src/vscp/common/vscp-bootdevice-pic1.h +++ b/src/vscp/common/vscp-bootdevice-pic1.h @@ -33,8 +33,8 @@ #pragma once -#include "vscp.h" #include "vscp-bootdevice.h" +#include "vscp.h" #include @@ -127,8 +127,6 @@ class CBootDevice_PIC1 : public CBootDevice { MEM_TYPE_USERID // 0x200000 }; - - // flags // CONTROL is defined as follows // @@ -186,7 +184,7 @@ class CBootDevice_PIC1 : public CBootDevice { MDF is not the same as the one read from the remote device. @return VSCP_ERROR_SUCCESS on success. */ - int deviceInit(cguid& ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail = false); + int deviceInit(cguid &ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail = false); /*! Write a boot block to the device @@ -202,7 +200,8 @@ class CBootDevice_PIC1 : public CBootDevice { and status message (const char *) @return VSCP_ERROR_SUCCESS on success. */ - int deviceLoad(std::function statusCallback = nullptr, bool bAbortOnFirmwareCodeFail = false); + int deviceLoad(std::function statusCallback = nullptr, + bool bAbortOnFirmwareCodeFail = false); /*! Restart remote device diff --git a/src/vscp/common/vscp-bootdevice.cpp b/src/vscp/common/vscp-bootdevice.cpp index 9a4283b83..5510d31f3 100644 --- a/src/vscp/common/vscp-bootdevice.cpp +++ b/src/vscp/common/vscp-bootdevice.cpp @@ -55,9 +55,9 @@ #include #include +#include #include -#include -#include +#include /////////////////////////////////////////////////////////////////////////////// // Ctor @@ -104,9 +104,9 @@ CBootDevice::CBootDevice(CVscpClient *pclient, m_guid.clear(); m_guid.setNicknameID(nodeid); m_guidif.clear(); - m_timeout = timeout; - m_statusCallback = statusCallback; - m_startAddr = 0; // Boot start + m_timeout = timeout; + m_statusCallback = statusCallback; + m_startAddr = 0; // Boot start m_firmwaredeviceCode = 0; } @@ -162,8 +162,8 @@ int CBootDevice::loadIntelHexFile(const std::string &path) { char szline[2048]; - //char buf[16]; - //char *endptr; + // char buf[16]; + // char *endptr; std::ifstream hexfile; uint16_t lowaddr = 0; // Low part of address uint16_t highaddr = 0; // High part if address diff --git a/src/vscp/common/vscp-bootdevice.h b/src/vscp/common/vscp-bootdevice.h index b7aaada77..4e35e3741 100644 --- a/src/vscp/common/vscp-bootdevice.h +++ b/src/vscp/common/vscp-bootdevice.h @@ -274,6 +274,8 @@ class CBootDevice { The device code tell the type of hardware of the remote device Must/should be the same as for the firmware we try to load. + This code is set in devicInit and is compared with the code in the device + Some (old) devices will have this code set to 0 in this cae no check should be performed. */ diff --git a/src/vscp/common/vscp-class.h b/src/vscp/common/vscp-class.h index 6f904ba6f..c40801ff4 100644 --- a/src/vscp/common/vscp-class.h +++ b/src/vscp/common/vscp-class.h @@ -47,7 +47,7 @@ !!!!!!!!!!!!!!!!!!!! W A R N I N G !!!!!!!!!!!!!!!!!!!! This file is auto-generated see https://github.com/grodansparadis/vscp-classes - Generated: 2024-11-05 21:03:46.717561 + Generated: 2024-12-09 21:43:36.673255 */ #ifndef VSCP_CLASS_H diff --git a/src/vscp/common/vscp-hashclass.h b/src/vscp/common/vscp-hashclass.h index 7d5a80341..eed28b99b 100644 --- a/src/vscp/common/vscp-hashclass.h +++ b/src/vscp/common/vscp-hashclass.h @@ -2,7 +2,7 @@ !!!!!!!!!!!!!!!!!!!! W A R N I N G !!!!!!!!!!!!!!!!!!!! This file is auto-generated see https://github.com/grodansparadis/vscp-classes - Generated: 2024-11-05 21:03:50.106254 + Generated: 2024-12-09 21:43:37.667848 */ m_hashClass[ 0 ] = _("CLASS1_PROTOCOL"); diff --git a/src/vscp/common/vscp-hashtype.h b/src/vscp/common/vscp-hashtype.h index d189b3edb..edb2a8fb1 100644 --- a/src/vscp/common/vscp-hashtype.h +++ b/src/vscp/common/vscp-hashtype.h @@ -2,7 +2,7 @@ !!!!!!!!!!!!!!!!!!!! W A R N I N G !!!!!!!!!!!!!!!!!!!! This file is auto-generated see https://github.com/grodansparadis/vscp-classes - Generated: 2024-11-05 21:03:51.292883 + Generated: 2024-12-09 21:43:38.327870 */ @@ -51,8 +51,11 @@ m_hashType[ MAKE_CLASSTYPE_LONG(0,41) ] = _("VSCP_TYPE_PROTOCOL_GET_EVENT_INTEREST_RESPONSE"); m_hashType[ MAKE_CLASSTYPE_LONG(0,48) ] = _("VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_ACK"); m_hashType[ MAKE_CLASSTYPE_LONG(0,49) ] = _("VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_NACK"); - m_hashType[ MAKE_CLASSTYPE_LONG(0,50) ] = _("VSCP_TYPE_PROTOCOL_START_BLOCK_ACK"); + m_hashType[ MAKE_CLASSTYPE_LONG(0,50) ] = _("VSCP_TYPE_PROTOCOL_START_BLOCK_ACK "); m_hashType[ MAKE_CLASSTYPE_LONG(0,51) ] = _("VSCP_TYPE_PROTOCOL_START_BLOCK_NACK"); + m_hashType[ MAKE_CLASSTYPE_LONG(0,52) ] = _("VSCP_TYPE_PROTOCOL_BLOCK_CHUNK_ACK "); + m_hashType[ MAKE_CLASSTYPE_LONG(0,53) ] = _("VSCP_TYPE_PROTOCOL_BLOCK_CHUNK_NACK"); + m_hashType[ MAKE_CLASSTYPE_LONG(0,54) ] = _("VSCP_TYPE_PROTOCOL_BOOT_LOADER_CHECK"); // CLASS1.ALARM = 1 - Alarm functionality m_hashType[ MAKE_CLASSTYPE_LONG(1,0) ] = _("VSCP_TYPE_ALARM_GENERAL"); @@ -1103,8 +1106,11 @@ m_hashType[ MAKE_CLASSTYPE_LONG(512,41) ] = _("VSCP_TYPE_PROTOCOL_GET_EVENT_INTEREST_RESPONSE"); m_hashType[ MAKE_CLASSTYPE_LONG(512,48) ] = _("VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_ACK"); m_hashType[ MAKE_CLASSTYPE_LONG(512,49) ] = _("VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_NACK"); - m_hashType[ MAKE_CLASSTYPE_LONG(512,50) ] = _("VSCP_TYPE_PROTOCOL_START_BLOCK_ACK"); + m_hashType[ MAKE_CLASSTYPE_LONG(512,50) ] = _("VSCP_TYPE_PROTOCOL_START_BLOCK_ACK "); m_hashType[ MAKE_CLASSTYPE_LONG(512,51) ] = _("VSCP_TYPE_PROTOCOL_START_BLOCK_NACK"); + m_hashType[ MAKE_CLASSTYPE_LONG(512,52) ] = _("VSCP_TYPE_PROTOCOL_BLOCK_CHUNK_ACK "); + m_hashType[ MAKE_CLASSTYPE_LONG(512,53) ] = _("VSCP_TYPE_PROTOCOL_BLOCK_CHUNK_NACK"); + m_hashType[ MAKE_CLASSTYPE_LONG(512,54) ] = _("VSCP_TYPE_PROTOCOL_BOOT_LOADER_CHECK"); // CLASS2.LEVEL1.ALARM = 513 - Class2 Level I Alarm // Event types is the same as CLASS1.ALARM = 1 - Alarm functionality diff --git a/src/vscp/common/vscp-type.h b/src/vscp/common/vscp-type.h index e3ae202de..a21d62f37 100644 --- a/src/vscp/common/vscp-type.h +++ b/src/vscp/common/vscp-type.h @@ -48,7 +48,7 @@ !!!!!!!!!!!!!!!!!!!! W A R N I N G !!!!!!!!!!!!!!!!!!!! This file is auto-generated see https://github.com/grodansparadis/vscp-classes - Generated: 2024-11-05 21:03:48.911038 + Generated: 2024-12-09 21:43:37.152426 */ #ifndef VSCP_TYPE_H @@ -101,8 +101,11 @@ #define VSCP_TYPE_PROTOCOL_GET_EVENT_INTEREST_RESPONSE 41 /* Get event interest response. */ #define VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_ACK 48 /* Activate new image ACK. */ #define VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE_NACK 49 /* Activate new image NACK. */ -#define VSCP_TYPE_PROTOCOL_START_BLOCK_ACK 50 /* Block data transfer ACK. */ -#define VSCP_TYPE_PROTOCOL_START_BLOCK_NACK 51 /* Block data transfer NACK. */ +#define VSCP_TYPE_PROTOCOL_START_BLOCK_ACK 50 /* Start Block ACK. */ +#define VSCP_TYPE_PROTOCOL_START_BLOCK_NACK 51 /* Start Block NACK. */ +#define VSCP_TYPE_PROTOCOL_BLOCK_CHUNK_ACK 52 /* Block Data Chunk ACK. */ +#define VSCP_TYPE_PROTOCOL_BLOCK_CHUNK_NACK 53 /* Block Data Chunk NACK. */ +#define VSCP_TYPE_PROTOCOL_BOOT_LOADER_CHECK 54 /* Bootloader CHECK. */ /* CLASS1.ALARM = 1 - Alarm functionality */ #define VSCP_TYPE_ALARM_GENERAL 0 /* General event */ diff --git a/src/vscp/common/vscp.h b/src/vscp/common/vscp.h index bf51f6dfe..2d426e27e 100644 --- a/src/vscp/common/vscp.h +++ b/src/vscp/common/vscp.h @@ -656,7 +656,9 @@ struct vscpMyNode { #define VSCP_ERROR_SIZE 64 /* The size is wring */ #define VSCP_ERROR_NACK 65 /* NACK received */ #define VSCP_ERROR_READ_ERROR 66 /* Error when reading data */ -#define VSCP_ERROR_READ 66 /* Error when reading data */ +#define VSCP_ERROR_READ 66 /* DUPLICATE FOR CONVENIENCE! Error when reading data */ +#define VSCP_ERROR_INVALID_CHECKSUM 67 /* Checksum is not correct */ +#define VSCP_ERROR_INTERFACE 68 /* Interface error (not defined etc) */ /*! HLO (High Level Object) type (bits 7,6,5,4) diff --git a/src/vscp/common/vscphelper.h b/src/vscp/common/vscphelper.h index f9ac520f5..95e2d0ef3 100644 --- a/src/vscp/common/vscphelper.h +++ b/src/vscp/common/vscphelper.h @@ -28,7 +28,7 @@ /*! \file vscphelper.h \brief The vscphelper file contains often used functionality when - working with VSCP. \details vscphealper have common used functionality to do + working with VSCP. \details vscphelper have common used functionality to do things in the VSCP world. It can be seen as the main toolbox for the VSCP programmer. */