Skip to content

Commit

Permalink
v1.02, add new device identifier function
Browse files Browse the repository at this point in the history
  • Loading branch information
thedjnK committed Oct 4, 2015
1 parent 4fbc49f commit e9da867
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
54 changes: 43 additions & 11 deletions UwxMainWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******************************************************************************
/******************************************************************************
** Copyright (C) 2015 Laird
**
** Project: UwTerminalX
Expand Down Expand Up @@ -1143,18 +1143,20 @@ MainWindow::readData(
if (gchTermBusyLines == 4)
{
//Enough data, check it.
QRegularExpression reTempRE("\n10 0 ([a-zA-Z0-9]{2,14})\r\n00\r\n10 13 ([a-zA-Z0-9]{4}) ([a-zA-Z0-9]{4}) \r\n00\r");
QRegularExpression reTempRE("\n10 0 (.{2,32}?)\r\n00\r\n10 13 ([a-zA-Z0-9]{4}) ([a-zA-Z0-9]{4}) \r\n00\r");
QRegularExpressionMatch remTempREM = reTempRE.match(gstrTermBusyData);
if (remTempREM.hasMatch() == true)
{
//Extract device name
QString strDevName = AtiToXCompName(remTempREM.captured(1));
if (gchTermMode == MODE_SERVER_COMPILE || gchTermMode == MODE_SERVER_COMPILE_LOAD || gchTermMode == MODE_SERVER_COMPILE_LOAD_RUN)
{
if (ui->check_OnlineXComp->isChecked() == true)
{
//Check if online XCompiler supports this device
if (LookupDNSName() == true)
{
gnmManager->get(QNetworkRequest(QUrl(QString(WebProtocol).append("://").append(gstrResolvedServer).append("/supported.php?JSON=1&Dev=").append(remTempREM.captured(1).left(8)).append("&HashA=").append(remTempREM.captured(2)).append("&HashB=").append(remTempREM.captured(3)))));
gnmManager->get(QNetworkRequest(QUrl(QString(WebProtocol).append("://").append(gstrResolvedServer).append("/supported.php?JSON=1&Dev=").append(strDevName).append("&HashA=").append(remTempREM.captured(2)).append("&HashB=").append(remTempREM.captured(3)))));
}
}
else
Expand All @@ -1170,11 +1172,11 @@ MainWindow::readData(
//Matched and split, now start the compilation!
gtmrDownloadTimeoutTimer.stop();

//
//Split the file path up
QList<QString> lstFI = SplitFilePath(gstrTermFilename);
#ifdef _WIN32
//Windows
if (QFile::exists(QString(gpTermSettings->value("CompilerDir", DefaultCompilerDir).toString()).append((gpTermSettings->value("CompilerSubDirs", DefaultCompilerSubDirs).toBool() == true ? remTempREM.captured(1).left(8).append("/") : "")).append("XComp_").append(remTempREM.captured(1).left(8)).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe")) == true)
if (QFile::exists(QString(gpTermSettings->value("CompilerDir", DefaultCompilerDir).toString()).append((gpTermSettings->value("CompilerSubDirs", DefaultCompilerSubDirs).toBool() == true ? QString(strDevName).append("/") : "")).append("XComp_").append(strDevName).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe")) == true)
{
//XCompiler found! - First run the Pre XCompile program if enabled and it exists
if (ui->check_PreXCompRun->isChecked() == true && ui->radio_XCompPre->isChecked() == true)
Expand All @@ -1183,18 +1185,18 @@ MainWindow::readData(
RunPrePostExecutable(gstrTermFilename);
}
//Windows
gprocCompileProcess.start(QString(gpTermSettings->value("CompilerDir", DefaultCompilerDir).toString()).append((gpTermSettings->value("CompilerSubDirs", DefaultCompilerSubDirs).toBool() == true ? remTempREM.captured(1).left(8).append("/") : "")).append("XComp_").append(remTempREM.captured(1).left(8)).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe"), QStringList(gstrTermFilename));
gprocCompileProcess.start(QString(gpTermSettings->value("CompilerDir", DefaultCompilerDir).toString()).append((gpTermSettings->value("CompilerSubDirs", DefaultCompilerSubDirs).toBool() == true ? QString(strDevName).append("/") : "")).append("XComp_").append(strDevName).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe"), QStringList(gstrTermFilename));
//gprocCompileProcess.waitForFinished(-1);
}
else if (QFile::exists(QString(lstFI[0]).append("XComp_").append(remTempREM.captured(1).left(8)).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe")) == true)
else if (QFile::exists(QString(lstFI[0]).append("XComp_").append(strDevName).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe")) == true)
{
//XCompiler found in directory with sB file
if (ui->check_PreXCompRun->isChecked() == true && ui->radio_XCompPre->isChecked() == true)
{
//Run Pre-XComp program
RunPrePostExecutable(gstrTermFilename);
}
gprocCompileProcess.start(QString(lstFI[0]).append("XComp_").append(remTempREM.captured(1).left(8)).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe"), QStringList(gstrTermFilename));
gprocCompileProcess.start(QString(lstFI[0]).append("XComp_").append(strDevName).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3)).append(".exe"), QStringList(gstrTermFilename));
}
else
#endif
Expand All @@ -1203,7 +1205,7 @@ MainWindow::readData(
//XCompiler not found, try Online XCompiler
if (LookupDNSName() == true)
{
gnmManager->get(QNetworkRequest(QUrl(QString(WebProtocol).append("://").append(gstrResolvedServer).append("/supported.php?JSON=1&Dev=").append(remTempREM.captured(1).left(8)).append("&HashA=").append(remTempREM.captured(2)).append("&HashB=").append(remTempREM.captured(3)))));
gnmManager->get(QNetworkRequest(QUrl(QString(WebProtocol).append("://").append(gstrResolvedServer).append("/supported.php?JSON=1&Dev=").append(strDevName).append("&HashA=").append(remTempREM.captured(2)).append("&HashB=").append(remTempREM.captured(3)))));
ui->statusBar->showMessage("Device support request sent...", 2000);

if (gchTermMode == MODE_COMPILE)
Expand All @@ -1229,11 +1231,11 @@ MainWindow::readData(
else
{
//XCompiler not found, Online XCompiler disabled
QString strMessage = tr("Error during XCompile:\nXCompiler \"XComp_").append(remTempREM.captured(1).left(8)).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3))
QString strMessage = tr("Error during XCompile:\nXCompiler \"XComp_").append(strDevName).append("_").append(remTempREM.captured(2)).append("_").append(remTempREM.captured(3))
#ifdef _WIN32
.append(".exe")
#endif
.append("\" was not found.\r\n\r\nPlease ensure you put XCompile binaries in the correct directory (").append(gpTermSettings->value("CompilerDir", DefaultCompilerDir).toString()).append((gpTermSettings->value("CompilerSubDirs", DefaultCompilerSubDirs).toBool() == true ? remTempREM.captured(1).left(8) : "")).append(").\n\nYou can also enable Online XCompilation from the 'Config' tab to XCompile applications using Laird's online server.");
.append("\" was not found.\r\n\r\nPlease ensure you put XCompile binaries in the correct directory (").append(gpTermSettings->value("CompilerDir", DefaultCompilerDir).toString()).append((gpTermSettings->value("CompilerSubDirs", DefaultCompilerSubDirs).toBool() == true ? strDevName : "")).append(").\n\nYou can also enable Online XCompilation from the 'Config' tab to XCompile applications using Laird's online server.");
#pragma warning("Add full file path for XCompilers?")
gpmErrorForm->show();
gpmErrorForm->SetMessage(&strMessage);
Expand Down Expand Up @@ -4829,6 +4831,36 @@ MainWindow::LookupDNSName(
return true;
}

//=============================================================================
//=============================================================================
QString
MainWindow::AtiToXCompName(
QString strAtiResp
)
{
//Function to extract XCompiler name from ATI response
if (strAtiResp.length() > MaxDevNameSize)
{
//Shorten device name
strAtiResp = strAtiResp.left(MaxDevNameSize);
}

//Only allow a-z, A-Z, 0-9 and underscores in device name
int iI = 0;
while (iI < strAtiResp.length())
{
//Check each character
char cTmpC = strAtiResp.at(iI).toLatin1();
if (!(cTmpC > 47 && cTmpC < 58) && !(cTmpC > 64 && cTmpC < 91) && !(cTmpC > 96 && cTmpC < 123) && cTmpC != 95)
{
//Replace non-alphanumeric character with an underscore
strAtiResp[iI] = '_';
}
++iI;
}
return strAtiResp;
}

/******************************************************************************/
// END OF FILE
/******************************************************************************/
7 changes: 6 additions & 1 deletion UwxMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@
#define MODE_CHECK_FIRMWARE_VERSIONS 17
#define MODE_CHECK_FIRMWARE_SUPPORT 18
//Defines for version and functions
#define UwVersion "1.01" //Version string
#define UwVersion "1.02" //Version string
#define FileReadBlock 512 //Number of bytes to read per block when streaming files
#define StreamProgress 10000 //Number of bytes between streaming progress updates
#define BatchTimeout 4000 //Time (in mS) to wait for getting a response from a batch command for
#define PrePostXCompTimeout 15000 //Time (in mS) to allow a pre/post XCompilation process to execute for
#define ModuleTimeout 4000 //Time (in mS) that a download stage command/process times out (module)
#define MaxDevNameSize 8 //Size (in characters) to allow for a module device name (characters past this point will be chopped off)
//Defines for default config values
#define DefaultLogFile "UwTerminalX.log"
#define DefaultLogMode 0
Expand Down Expand Up @@ -433,6 +434,10 @@ private slots:
FinishBatch(
bool bType
);
QString
AtiToXCompName(
QString strAtiResp
);

//Private variables
bool gbTermBusy; //True when compiling or loading a program or streaming a file (busy)
Expand Down
8 changes: 4 additions & 4 deletions version.rc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <windows.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 1, 0, 0
PRODUCTVERSION 1, 1, 0, 0
FILEVERSION 1, 2, 0, 0
PRODUCTVERSION 1, 2, 0, 0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
Expand All @@ -19,12 +19,12 @@
BEGIN
VALUE "CompanyName", "Laird\0"
VALUE "FileDescription", "UwTerminalX\0"
VALUE "FileVersion", "1.1.0.0\0"
VALUE "FileVersion", "1.2.0.0\0"
VALUE "InternalName", "UwTerminalX\0"
VALUE "LegalCopyright", "Copyright 2015 by Laird\0"
VALUE "OriginalFilename", "UwTerminalX.exe\0"
VALUE "ProductName", "UwTerminalX\0"
VALUE "ProductVersion", "1.1.0.0\0"
VALUE "ProductVersion", "1.2.0.0\0"
END
END
END
Expand Down

0 comments on commit e9da867

Please sign in to comment.