40
40
// #include <spdlog/sinks/stdout_color_sinks.h>
41
41
#include < spdlog/spdlog.h>
42
42
43
- #include < iomanip>
44
43
#include < iostream>
45
- #include < sstream>
44
+ #include < iomanip>
45
+ #include < sstream>
46
46
47
47
// /////////////////////////////////////////////////////////////////////////////
48
48
// Constructor
@@ -228,16 +228,13 @@ CBootDevice_PIC1::deviceInfo(void)
228
228
//
229
229
230
230
int
231
- CBootDevice_PIC1::deviceInit (cguid & ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail)
231
+ CBootDevice_PIC1::deviceInit (cguid& ourguid, uint16_t devicecode, bool bAbortOnFirmwareCodeFail)
232
232
{
233
233
int rv;
234
234
235
235
// Save our local GUID
236
236
m_ourguid = ourguid;
237
237
238
- // Save Firmware device code
239
- m_firmwaredeviceCode = devicecode;
240
-
241
238
/*
242
239
First do a test to see if the device is already in boot mode
243
240
if it is 0x14nn/0x15nn should be returned (nn == nodeid).
@@ -359,7 +356,7 @@ CBootDevice_PIC1::deviceInit(cguid &ourguid, uint16_t devicecode, bool bAbortOnF
359
356
// Set device in boot mode
360
357
cguid guid;
361
358
m_stdRegs.getGUID (guid);
362
- msg.data [0 ] = (uint8_t ) m_nodeid; // Nickname to read register from
359
+ msg.data [0 ] = (uint8_t )m_nodeid; // Nickname to read register from
363
360
msg.data [1 ] = VSCP_BOOTLOADER_PIC1; // VSCP PIC1 bootloader algorithm
364
361
msg.data [2 ] = guid.getAt (0 );
365
362
msg.data [3 ] = guid.getAt (3 );
566
563
CBootDevice_PIC1::writeDeviceControlRegs (uint32_t addr, uint8_t flags, uint8_t cmd, uint8_t cmdData0, uint8_t cmdData1)
567
564
{
568
565
int rv;
569
- // vscpEventEx event;
566
+ // vscpEventEx event;
570
567
canalMsg msg;
571
568
572
569
// Save the internal addresss
@@ -640,7 +637,7 @@ CBootDevice_PIC1::checkResponseLevel1(uint32_t response_id)
640
637
// Response received from all - return success
641
638
spdlog::debug (" checkResponseLevel1: RECEIVE OK" );
642
639
if (nullptr != m_statusCallback) {
643
- // m_statusCallback(-1, "checkResponseLevel1: Response received OK.");
640
+ // m_statusCallback(-1, "checkResponseLevel1: Response received OK.");
644
641
}
645
642
return VSCP_ERROR_SUCCESS;
646
643
}
@@ -688,7 +685,7 @@ CBootDevice_PIC1::checkResponseLevel2(uint32_t id)
688
685
// Response received - return success
689
686
spdlog::debug (" checkResponseLevel2: RECEIVE OK" );
690
687
if (nullptr != m_statusCallback) {
691
- // m_statusCallback(-1, "checkResponseLevel2: Response received OK.");
688
+ // m_statusCallback(-1, "checkResponseLevel2: Response received OK.");
692
689
}
693
690
return VSCP_ERROR_SUCCESS;
694
691
}
@@ -831,7 +828,7 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
831
828
}
832
829
833
830
// Init the block
834
- if (VSCP_ERROR_SUCCESS != (rv = fillMemoryBuffer (pbuf, size, start))) {
831
+ if (VSCP_ERROR_SUCCESS != (rv = fillMemoryBuffer (pbuf, size, start, end ))) {
835
832
spdlog::error (" writeFirmwareBlock: Failed to fill code block with data." );
836
833
if (nullptr != m_statusCallback) {
837
834
m_statusCallback (-1 ,
@@ -855,7 +852,7 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
855
852
}
856
853
857
854
// Start at beginning
858
- paddr += minAddr - start;
855
+ paddr += minAddr- start;
859
856
860
857
for (uint32_t blk = 0 ; blk < nPackets; blk++) {
861
858
spdlog::debug (" Loading flash on remote device... block={0} {1:X}" , blk, blk * 8 );
@@ -865,11 +862,11 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
865
862
}
866
863
paddr += 8 ;
867
864
if (nullptr != m_statusCallback) {
868
- m_statusCallback ((100 * blk) / nPackets, " " /* vscp_str_format("blk %d.", blk).c_str()*/ );
865
+ m_statusCallback ((100 * blk) / nPackets, " " /* vscp_str_format("blk %d.", blk).c_str()*/ );
869
866
}
870
867
871
868
} // for
872
- } // code
869
+ } // code
873
870
874
871
delete[] pbuf;
875
872
return VSCP_ERROR_SUCCESS;
@@ -882,18 +879,18 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
882
879
int
883
880
CBootDevice_PIC1::deviceLoad (std::function<void (int , const char *)> statusCallback, bool bAbortOnFirmwareCodeFail)
884
881
{
885
- // bool bRun = true;
882
+ // bool bRun = true;
886
883
int rv;
887
884
888
- m_checksum = 0 ;
889
- // uint32_t progress = 0;
885
+ m_checksum = 0 ;
886
+ // uint32_t progress = 0;
890
887
uint32_t addr = 0 ;
891
888
std::string strStatus;
892
889
893
- // uint8_t pbuf[BUFFER_SIZE_CODE];
894
- // uint32_t nPackets;
895
- // uint32_t minAddr;
896
- // uint32_t maxAddr;
890
+ // uint8_t pbuf[BUFFER_SIZE_CODE];
891
+ // uint32_t nPackets;
892
+ // uint32_t minAddr;
893
+ // uint32_t maxAddr;
897
894
898
895
if (nullptr != m_statusCallback) {
899
896
m_statusCallback (0 , " Starting firmware download" );
0 commit comments