PC app: play JTAG file: improved progress bar updates

When the chunk sizes were not power of 2 the progress bar
updates were irregular. This change ensures that any
upload progress is regularly updated."
This commit is contained in:
ole00 2024-04-12 22:23:52 +01:00
parent ad9308e291
commit cce891c513

View File

@ -1294,6 +1294,7 @@ static int readJtagSerialLine(char* buf, int bufSize, int maxDelay, int* feedReq
static int playJtagFile(char* label, int fSize, int vpp, int showProgress) { static int playJtagFile(char* label, int fSize, int vpp, int showProgress) {
char buf[MAX_LINE] = {0}; char buf[MAX_LINE] = {0};
int sendPos = 0; int sendPos = 0;
int lastSendPos = 0;
char ready = 0; char ready = 0;
int result = 0; int result = 0;
unsigned int csum = 0; unsigned int csum = 0;
@ -1344,7 +1345,8 @@ static int playJtagFile(char* label, int fSize, int vpp, int showProgress) {
int w = serialDeviceWrite(serialF, galbuffer + sendPos, chunkSize); int w = serialDeviceWrite(serialF, galbuffer + sendPos, chunkSize);
sendPos += w; sendPos += w;
// print progress / file position // print progress / file position
if (showProgress && (sendPos % 1024 == 0 || sendPos == fSize)) { if (showProgress && (sendPos - lastSendPos >= 1024 || sendPos == fSize)) {
lastSendPos = sendPos;
updateProgressBar(label, sendPos, fSize); updateProgressBar(label, sendPos, fSize);
} }
} }