Skip to content

Commit

Permalink
Adding support the Intex HEX files format
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbigmdm committed Jan 24, 2024
1 parent 5a792c5 commit f769c32
Show file tree
Hide file tree
Showing 21 changed files with 1,412 additions and 927 deletions.
2 changes: 1 addition & 1 deletion IMSProg_programmer/dialogabout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DialogAbout::DialogAbout(QWidget *parent) :
ui->label_7->setTextFormat(Qt::RichText);
ui->label_7->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->label_7->setOpenExternalLinks(true);
ui->label_8->setText("V1.1.6");
ui->label_8->setText("V1.1.8");
}

DialogAbout::~DialogAbout()
Expand Down
Binary file modified IMSProg_programmer/language/chipProgrammer_de_DE.qm
Binary file not shown.
266 changes: 151 additions & 115 deletions IMSProg_programmer/language/chipProgrammer_de_DE.ts

Large diffs are not rendered by default.

Binary file modified IMSProg_programmer/language/chipProgrammer_es_ES.qm
Binary file not shown.
266 changes: 151 additions & 115 deletions IMSProg_programmer/language/chipProgrammer_es_ES.ts

Large diffs are not rendered by default.

Binary file modified IMSProg_programmer/language/chipProgrammer_hu_HU.qm
Binary file not shown.
266 changes: 151 additions & 115 deletions IMSProg_programmer/language/chipProgrammer_hu_HU.ts

Large diffs are not rendered by default.

Binary file modified IMSProg_programmer/language/chipProgrammer_it_IT.qm
Binary file not shown.
268 changes: 152 additions & 116 deletions IMSProg_programmer/language/chipProgrammer_it_IT.ts

Large diffs are not rendered by default.

Binary file modified IMSProg_programmer/language/chipProgrammer_pt_BR.qm
Binary file not shown.
266 changes: 151 additions & 115 deletions IMSProg_programmer/language/chipProgrammer_pt_BR.ts

Large diffs are not rendered by default.

Binary file modified IMSProg_programmer/language/chipProgrammer_ru_RU.qm
Binary file not shown.
266 changes: 151 additions & 115 deletions IMSProg_programmer/language/chipProgrammer_ru_RU.ts

Large diffs are not rendered by default.

Binary file modified IMSProg_programmer/language/chipProgrammer_uk_UA.qm
Binary file not shown.
268 changes: 152 additions & 116 deletions IMSProg_programmer/language/chipProgrammer_uk_UA.ts

Large diffs are not rendered by default.

Binary file modified IMSProg_programmer/language/chipProgrammer_zn_CH.qm
Binary file not shown.
266 changes: 151 additions & 115 deletions IMSProg_programmer/language/chipProgrammer_zn_CH.ts

Large diffs are not rendered by default.

170 changes: 170 additions & 0 deletions IMSProg_programmer/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,3 +1542,173 @@ QString MainWindow::getCRC32()
}
return hexiAddr(crc ^ 0xFFFFFFFF);
}

void MainWindow::on_actionExport_to_Intel_HEX_triggered()
{
int addr = 0, hi_addr =0;
QString result = "";
chipData = hexEdit->data();
int currSize = chipData.size();
uint8_t i, counter = 0;
int ostatok = 0;
ui->progressBar->setRange(0,chipData.size());
lastDirectory.replace(".bin", ".hex");
ui->statusBar->showMessage(tr("Saving file"));
fileName = QFileDialog::getSaveFileName(this,
QString(tr("Save file")),
lastDirectory,
"Intel HEX Images (*.hex *.HEX);;All files (*.*)");
QFileInfo info(fileName);
ui->statusBar->showMessage(tr("Current file: ") + info.fileName());
lastDirectory = info.filePath();
QFile file(fileName);
QTextStream stream(&file);
if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text))
{

return;
}
stream.seek(file.size());
while ((addr + hi_addr * 0x10000) < (chipData.size()))
{

if (addr < currSize - 0x20) ostatok = 0x20;
else ostatok =currSize - addr;

result.append(":");
result.append(bytePrint(static_cast<unsigned char>(ostatok))); //number of bytes per string
result.append(bytePrint(static_cast<unsigned char>((addr & 0xff00) >> 8))); //one address byte
result.append(bytePrint(static_cast<unsigned char>(addr & 0xff))); //zero address byte
result.append("00"); //type 00
counter = counter + static_cast<unsigned char>(ostatok) + uint8_t((addr & 0xff00) >> 8) + uint8_t(addr & 0xff) ;
for (i = 0; i < ostatok; i++)
{
result.append(bytePrint(static_cast<unsigned char>((chipData[hi_addr * 256 * 256 + addr + i]))));
counter = counter + static_cast<uint8_t>((chipData[hi_addr * 256 * 256 + addr + i]));
}
result.append(bytePrint(0xff - counter + 1));
counter = 0;
stream << result << "\n";
result.clear();

addr = addr + 0x20;
if (addr >= 0x10000) //command 04 - setting the high address
{
hi_addr ++;
addr = addr - 0x10000;
result.append(":02000004");
result.append(bytePrint(uint8_t((hi_addr & 0xff00) >> 8)));
result.append(bytePrint(uint8_t(hi_addr & 0xff)));
counter = 0x06 + uint8_t((hi_addr & 0xff00) >> 8) + uint8_t(hi_addr & 0xff);
result.append(bytePrint(0xff - counter + 1));
counter = 0;
stream << result << "\n";
result.clear();
ui->progressBar->setValue(hi_addr * 256 * 256);
}
}
result = ":00000001FF\n"; //end string
stream << result;
file.close();
fileName.clear();
ui->progressBar->setValue(0);
}

void MainWindow::on_actionImport_from_Intel_HEX_triggered()
{
chipData = hexEdit->data();
int chipSize = chipData.size();
uint_fast32_t lineLen, lo_addr, hi_addr, command, i;
unsigned char currByte;
uint8_t counter, checkSUM;
QString currStr ="", strVal = "";
ui->statusBar->showMessage(tr("Opening file"));
fileName = QFileDialog::getOpenFileName(this,
QString(tr("Open file")),
lastDirectory,
"Intel HEX Images (*.hex *.HEX);;All files (*.*)");
QFileInfo info(fileName);
ui->statusBar->showMessage(tr("Current file: ") + info.fileName());
lastDirectory = info.filePath();
QFile file(fileName);

if (!file.open(QIODevice::ReadOnly))
{

return;
}
hi_addr = 0;
ui->progressBar->setRange(0, chipSize);
while (!file.atEnd())
{
currStr = file.readLine();
counter = 0;
//parsing string
if (currStr[0] != ':')
{
QMessageBox::about(this, tr("Error"), tr("Not valid HEX format!"));
return;
}
strVal = currStr.mid(1,2); //Length of data in current string
lineLen = hexToInt(strVal);
counter = counter + static_cast<unsigned char>(lineLen);

strVal.clear(); //low address
strVal = currStr.mid(3,4);
lo_addr = hexToInt(strVal);
counter = counter + static_cast<unsigned char>((lo_addr) >> 8) + static_cast<unsigned char>(lo_addr & 0x00ff);

if (hi_addr * 256 * 256 + lo_addr > static_cast<unsigned long>(chipSize))
{
QMessageBox::about(this, tr("Error"), tr("The address is larger than the size of the chip!"));
return;
}

strVal.clear(); //command
strVal = currStr.mid(7,2);
command = hexToInt(strVal);
counter = counter + static_cast<unsigned char>(command);

if (command == 0) //reading bytes from current string
{
for (i = 0; i < lineLen; i++)
{

strVal.clear(); //get current byte of string
strVal = currStr.mid(int(i) * 2 + 9, 2);
currByte = static_cast<unsigned char>(hexToInt(strVal));
chipData.data()[hi_addr * 256 * 256 + lo_addr + i] = char(currByte);
counter = counter + static_cast<unsigned char>(hexToInt(strVal));

}
counter = 255 - counter + 1;
checkSUM = static_cast<unsigned char>(hexToInt( currStr.mid(int(i) * 2 + 9, 2)));

if (counter != checkSUM)
{
QMessageBox::about(this, tr("Error"), tr("Checksum error!"));
return;
}
}
if (command == 4) //Changing the high address
{
strVal.clear(); //low address
strVal = currStr.mid(9,4);
hi_addr = hexToInt(strVal);
counter = counter + static_cast<unsigned char>((hi_addr) >> 8) + static_cast<unsigned char>(hi_addr & 0x00ff);
counter = 255 - counter + 1;
checkSUM = static_cast<unsigned char>(hexToInt( currStr.mid(13, 2)));
ui->progressBar->setValue(int(hi_addr * 256 * 256));
if (counter != checkSUM)
{
QMessageBox::about(this, tr("Error"), tr("Checksum error!"));
return;
}
}


}
file.close();
fileName.clear();
hexEdit->setData(chipData);
}
4 changes: 4 additions & 0 deletions IMSProg_programmer/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ private slots:
void on_actionChip_info_triggered();
void on_comboBox_addr4bit_currentIndexChanged(int index);

void on_actionExport_to_Intel_HEX_triggered();

void on_actionImport_from_Intel_HEX_triggered();

private:
Ui::MainWindow *ui;
QColor defaultTextColor;
Expand Down
25 changes: 23 additions & 2 deletions IMSProg_programmer/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,8 @@ QPushButton::pressed{background-color: rgb(115, 210, 22);}</string>
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<height>29</height>
<width>950</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand All @@ -905,6 +905,9 @@ QPushButton::pressed{background-color: rgb(115, 210, 22);}</string>
<addaction name="actionLoad_Part"/>
<addaction name="actionSave_Part"/>
<addaction name="separator"/>
<addaction name="actionImport_from_Intel_HEX"/>
<addaction name="actionExport_to_Intel_HEX"/>
<addaction name="separator"/>
<addaction name="actionEdit_chips_Database"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
Expand Down Expand Up @@ -1199,6 +1202,24 @@ QPushButton::pressed{background-color: rgb(115, 210, 22);}</string>
<string>Ctrl+P</string>
</property>
</action>
<action name="actionImport_from_Intel_HEX">
<property name="icon">
<iconset resource="recource.qrc">
<normaloff>:/res/img/open64.png</normaloff>:/res/img/open64.png</iconset>
</property>
<property name="text">
<string>Import from Intel HEX</string>
</property>
</action>
<action name="actionExport_to_Intel_HEX">
<property name="icon">
<iconset resource="recource.qrc">
<normaloff>:/res/img/save64.png</normaloff>:/res/img/save64.png</iconset>
</property>
<property name="text">
<string>Export to Intel HEX</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@ sudo apt update
- Ver. 1.1.1 - Changing application folders according to Debian policy. Added new language translation.
- Ver. 1.1.2 - Added function for writing the Status Registers. Bugfix - Chip_Editor startup error when running IMSProg from command line. Added chips to the database. Added new language translation.
- Ver. 1.1.3 - Fixed an error when the file size exceeds the chip size.
- Ver. 1.1.4 - Removed debian packaging from upstream (moved to specific branch for official packages work)
- Ver. 1.1.5 - Detect udev path with pkg-config
- Ver. 1.1.4 - Removed debian packaging from upstream (moved to specific branch for official packages work).
- Ver. 1.1.5 - Detect udev path with pkg-config.
- Ver. 1.1.6 - SPI erase procedure fixed, deleted unused SPI procedures. Fixed program crash when reading/writing large size chips (25Q256/25Q512). Fixed error diagnostics.
- Ver. 1.1.7 - Fixed building errors.
- Ver. 1.1.8 - Adding support the Intex HEX files format.

## Project structure

Expand Down

0 comments on commit f769c32

Please sign in to comment.