Added provisions to programmer protocol for specifying readback
size.
This commit is contained in:
parent
20ed6dffdf
commit
b8bf3e878b
|
@ -166,6 +166,10 @@ void MainWindow::programmerWriteStatusChanged(WriteStatus newStatus)
|
|||
ui->pages->setCurrentWidget(ui->controlPage);
|
||||
QMessageBox::warning(this, "Write timed out", "The write operation timed out.");
|
||||
break;
|
||||
case WriteFileTooBig:
|
||||
ui->pages->setCurrentWidget(ui->controlPage);
|
||||
QMessageBox::warning(this, "File too big", "The file you chose to write to the SIMM is too big according to the chip size you have selected.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ typedef enum ProgrammerCommandState
|
|||
ElectricalTestWaitingSecondFail,
|
||||
|
||||
ReadSIMMWaitingStartReply,
|
||||
ReadSIMMWaitingLengthReply,
|
||||
ReadSIMMWaitingData,
|
||||
ReadSIMMWaitingStatusReply,
|
||||
|
||||
|
@ -164,6 +165,7 @@ void Programmer::readSIMMToFile(QString filename)
|
|||
readFile = new QFile(filename);
|
||||
readFile->open(QFile::WriteOnly);
|
||||
lenRead = 0;
|
||||
lenRemaining = _simmCapacity;
|
||||
|
||||
startProgrammerCommand(ReadChips, ReadSIMMWaitingStartReply);
|
||||
}
|
||||
|
@ -177,10 +179,19 @@ void Programmer::writeFileToSIMM(QString filename)
|
|||
emit writeStatusChanged(WriteError);
|
||||
return;
|
||||
}
|
||||
lenWritten = 0;
|
||||
writeLenRemaining = writeFile->size();
|
||||
if (writeFile->size() > _simmCapacity)
|
||||
{
|
||||
curState = WaitingForNextCommand;
|
||||
emit writeStatusChanged(WriteFileTooBig);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
lenWritten = 0;
|
||||
writeLenRemaining = writeFile->size();
|
||||
|
||||
startProgrammerCommand(EraseChips, WriteSIMMWaitingEraseReply);
|
||||
startProgrammerCommand(EraseChips, WriteSIMMWaitingEraseReply);
|
||||
}
|
||||
}
|
||||
|
||||
void Programmer::sendByte(uint8_t b)
|
||||
|
@ -380,11 +391,45 @@ void Programmer::handleChar(uint8_t c)
|
|||
|
||||
// READ SIMM STATE HANDLERS
|
||||
case ReadSIMMWaitingStartReply:
|
||||
emit readStatusChanged(ReadStarting);
|
||||
curState = ReadSIMMWaitingData;
|
||||
emit readTotalLengthChanged(_simmCapacity);
|
||||
emit readCompletionLengthChanged(0);
|
||||
readChunkLenRemaining = READ_CHUNK_SIZE;
|
||||
switch (c)
|
||||
{
|
||||
case CommandReplyOK:
|
||||
|
||||
emit readStatusChanged(ReadStarting);
|
||||
curState = ReadSIMMWaitingLengthReply;
|
||||
|
||||
// Send the length requesting to be read
|
||||
sendByte((lenRemaining >> 0) & 0xFF);
|
||||
sendByte((lenRemaining >> 8) & 0xFF);
|
||||
sendByte((lenRemaining >> 16) & 0xFF);
|
||||
sendByte((lenRemaining >> 24) & 0xFF);
|
||||
|
||||
// Now wait for the go-ahead from the programmer's side
|
||||
break;
|
||||
case CommandReplyError:
|
||||
case CommandReplyInvalid:
|
||||
default:
|
||||
emit readStatusChanged(ReadError);
|
||||
curState = WaitingForNextCommand;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ReadSIMMWaitingLengthReply:
|
||||
switch (c)
|
||||
{
|
||||
case ProgrammerReadOK:
|
||||
curState = ReadSIMMWaitingData;
|
||||
emit readTotalLengthChanged(_simmCapacity);
|
||||
emit readCompletionLengthChanged(0);
|
||||
readChunkLenRemaining = READ_CHUNK_SIZE;
|
||||
break;
|
||||
case ProgrammerReadError:
|
||||
default:
|
||||
emit readStatusChanged(ReadError);
|
||||
curState = WaitingForNextCommand;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ReadSIMMWaitingData:
|
||||
readFile->write((const char *)&c, 1);
|
||||
|
|
|
@ -30,7 +30,8 @@ typedef enum WriteStatus
|
|||
WriteCancelled,
|
||||
WriteEraseComplete,
|
||||
WriteEraseFailed,
|
||||
WriteTimedOut
|
||||
WriteTimedOut,
|
||||
WriteFileTooBig
|
||||
} WriteStatus;
|
||||
|
||||
typedef enum ElectricalTestStatus
|
||||
|
@ -129,6 +130,7 @@ private:
|
|||
|
||||
uint32_t readChunkLenRemaining;
|
||||
uint32_t lenRead;
|
||||
uint32_t lenRemaining;
|
||||
|
||||
int identificationCounter;
|
||||
uint8_t chipManufacturerIDs[4];
|
||||
|
|
Loading…
Reference in New Issue