Skip to content

Commit

Permalink
Added VSCP_ERROR_INTERFACE
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Dec 11, 2024
1 parent 877deb0 commit 57f501c
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 40 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ SpaceAfterCStyleCast: true
AllowShortFunctionsOnASingleLine: Inline
BreakBeforeBinaryOperators: None
#AllowShortBlocksOnASingleLine: true
SortIncludes: false

# google-readability-braces-around-statements
9 changes: 9 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "0.2",
"ignorePaths": [],
"dictionaryDefinitions": [],
"dictionaries": [],
"words": [],
"ignoreWords": [],
"import": []
}
Binary file modified database
Binary file not shown.
Binary file modified resources/database/vscp-hashtypeevents.sqlite3
Binary file not shown.
36 changes: 18 additions & 18 deletions src/vscp/common/vscp-bootdevice-pic1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
// #include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>

#include <iomanip>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <sstream>

///////////////////////////////////////////////////////////////////////////////
// Constructor
Expand Down Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -882,18 +882,18 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
int
CBootDevice_PIC1::deviceLoad(std::function<void(int, const char *)> 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");
Expand Down
9 changes: 4 additions & 5 deletions src/vscp/common/vscp-bootdevice-pic1.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

#pragma once

#include "vscp.h"
#include "vscp-bootdevice.h"
#include "vscp.h"

#include <string>

Expand Down Expand Up @@ -127,8 +127,6 @@ class CBootDevice_PIC1 : public CBootDevice {
MEM_TYPE_USERID // 0x200000
};



// flags
// CONTROL is defined as follows
//
Expand Down Expand Up @@ -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
Expand All @@ -202,7 +200,8 @@ class CBootDevice_PIC1 : public CBootDevice {
and status message (const char *)
@return VSCP_ERROR_SUCCESS on success.
*/
int deviceLoad(std::function<void(int, const char *)> statusCallback = nullptr, bool bAbortOnFirmwareCodeFail = false);
int deviceLoad(std::function<void(int, const char *)> statusCallback = nullptr,
bool bAbortOnFirmwareCodeFail = false);

/*!
Restart remote device
Expand Down
14 changes: 7 additions & 7 deletions src/vscp/common/vscp-bootdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
#include <spdlog/spdlog.h>

#include <fstream>
#include <iomanip>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <sstream>

///////////////////////////////////////////////////////////////////////////////
// Ctor
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/vscp/common/vscp-bootdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/vscp/common/vscp-class.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/vscp/common/vscp-hashclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
12 changes: 9 additions & 3 deletions src/vscp/common/vscp-hashtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/


Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/vscp/common/vscp-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 3 additions & 1 deletion src/vscp/common/vscp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/vscp/common/vscphelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 57f501c

Please sign in to comment.