Skip to content

Commit

Permalink
Fixed GD77 callsign db upload. In the end, it was a misplaced line of…
Browse files Browse the repository at this point in the history
… code. Fixes #132.
  • Loading branch information
hmatuschek committed Sep 10, 2022
1 parent ad89a5d commit a2406cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/gd77.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ GD77::uploadCallsigns()

size_t totb = _callsigns.memSize();
unsigned bcount = 0;
// Then upload callsign DB
for (int n=0; n<_callsigns.image(0).numElements(); n++) {
unsigned addr = _callsigns.image(0).element(n).address();
unsigned size = _callsigns.image(0).element(n).data().size();
unsigned b0 = addr/BSIZE, nb = size/BSIZE;
RadioddityInterface::MemoryBank bank = (
(0x10000 > addr) ? RadioddityInterface::MEMBANK_CALLSIGN_LOWER : RadioddityInterface::MEMBANK_CALLSIGN_UPPER );
for (unsigned b=0; b<nb; b++, bcount+=BSIZE) {
if (! _dev->write(bank, (b0+b)*BSIZE,
RadioddityInterface::MemoryBank bank = (
(0x10000 > (b0+b)*BSIZE) ? RadioddityInterface::MEMBANK_CALLSIGN_LOWER : RadioddityInterface::MEMBANK_CALLSIGN_UPPER );
if (! _dev->write(bank, ((b0+b)*BSIZE)&0xffff,
_callsigns.data((b0+b)*BSIZE, 0), BSIZE, _errorStack))
{
errMsg(_errorStack) << "Cannot write block " << (b0+b) << ".";
Expand All @@ -109,6 +108,7 @@ GD77::uploadCallsigns()
}
}


_dev->write_finish();
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/gd77_callsigndb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define OFFSET_USERDB 0x00000

#define USERDB_MAX_ENTRIES 10920
#define USERDB_MAX_ENTRIES_PER_BANK 5460
#define BLOCK_SIZE 32


Expand Down Expand Up @@ -103,14 +104,14 @@ GD77CallsignDB::encode(UserDatabase *calldb, const Selection &selection, const E
[](const UserDatabase::User &a, const UserDatabase::User &b) { return a.id < b.id; });

// Allocate segment for user db if requested
unsigned size = align_size(sizeof(userdb_t)+n*sizeof(userdb_entry_t), BLOCK_SIZE);
size_t size = align_size(sizeof(userdb_t)+n*sizeof(userdb_entry_t), BLOCK_SIZE);
logDebug() << "Allocate 0x" << QString::number(size,16) << " bytes for call-sign DB.";
this->image(0).addElement(OFFSET_USERDB, size);

// Encode user DB
userdb_t *userdb = (userdb_t *)this->data(OFFSET_USERDB);
userdb->clear(); userdb->setSize(n);
userdb_entry_t *db = (userdb_entry_t *)this->data(OFFSET_USERDB+sizeof(userdb_t));
userdb_entry_t *db = (userdb_entry_t *)this->data(OFFSET_USERDB+sizeof(userdb_t), 0);
for (unsigned i=0; i<n; i++) {
db[i].fromEntry(users[i]);
}
Expand Down

0 comments on commit a2406cb

Please sign in to comment.