38
38
UV390::UV390(QObject *parent)
39
: Radio(parent), _name("TYT MD-UV390"), _dev(nullptr), _config(nullptr)
39
: Radio(parent), _name("TYT MD-UV390"), _dev(nullptr), _codeplugUpdate(true), _config(nullptr)
195
196
totb += _codeplug.image(0).element(n).data().size()/BSIZE;
198
// First download codeplug from device:
199
199
size_t bcount = 0;
200
for (int n=0; n<_codeplug.image(0).numElements(); n++) {
201
uint addr = _codeplug.image(0).element(n).address();
202
uint size = _codeplug.image(0).element(n).data().size();
203
uint b0 = addr/BSIZE, nb = size/BSIZE;
204
for (uint b=0; b<nb; b++, bcount++) {
205
if (! _dev->read_block(b0+b, _codeplug.data((b0+b)*BSIZE), BSIZE)) {
206
_errorMessage = QString("%1 Cannot upload codeplug: %2").arg(__func__)
207
.arg(_dev->errorMessage());
208
logError() << _errorMessage;
213
emit downloadError(this);
201
// If codeplug gets updated, download codeplug from device first:
202
if (_codeplugUpdate) {
203
for (int n=0; n<_codeplug.image(0).numElements(); n++) {
204
uint addr = _codeplug.image(0).element(n).address();
205
uint size = _codeplug.image(0).element(n).data().size();
206
uint b0 = addr/BSIZE, nb = size/BSIZE;
207
for (uint b=0; b<nb; b++, bcount++) {
208
if (! _dev->read_block(b0+b, _codeplug.data((b0+b)*BSIZE), BSIZE)) {
209
_errorMessage = QString("%1 Cannot upload codeplug: %2").arg(__func__)
210
.arg(_dev->errorMessage());
211
logError() << _errorMessage;
216
emit downloadError(this);
219
emit uploadProgress(float(bcount*50)/totb);
216
emit uploadProgress(float(bcount*50)/totb);
220
// Send encode config into codeplug
224
// Encode config into codeplug
221
225
_codeplug.encode(_config);
223
227
// then erase memory