Added a note about MABString should be replaced with CString in the new modern world.

This commit is contained in:
AndyWhittaker 2020-04-03 10:50:42 +01:00
parent 47e80ab30e
commit a76e71bf79
15 changed files with 133 additions and 51 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

View File

@ -31,7 +31,7 @@ CDetailDlg::CDetailDlg() : CTTPropertyPage(CDetailDlg::IDD)
//}}AFX_DATA_INIT
Enumerate(); // Build a list of available serial ports
m_pMainDlg = NULL;
m_pMainDlg = NULL;
m_bCSVFirstTime = TRUE;
m_bLogFirstTime = TRUE;

View File

@ -52,7 +52,7 @@ public:
protected:
// CUIntArray m_cuPorts; // Stores the enumerated COM Port numbers
CEnumerateSerial::CPortsArray m_cuPorts; // Stores the enumerated COM Port numbers
CEnumerateSerial m_EnumSerial;//ARW 15/01/2005 New EnumSerial Class
CEnumerateSerial m_EnumSerial;//ARW 11/06/2019 New EnumSerial Class
BOOL m_bCSVFirstTime;
BOOL m_bLogFirstTime;
int m_iModel; // Model Number

BIN
EnumSer.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

View File

@ -124,12 +124,11 @@ BEGIN
END
IDD_STATUS DIALOGEX 0, 0, 194, 236
STYLE DS_SETFONT | DS_3DLOOK | WS_POPUP | WS_CAPTION
STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Status Messages"
FONT 8, "MS Sans Serif", 0, 0, 0x1
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LISTBOX IDC_STATUS,7,7,180,212,NOT LBS_NOTIFY | LBS_WANTKEYBOARDINPUT | LBS_EXTENDEDSEL | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_HSCROLL
EDITTEXT IDC_TIME,7,219,180,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER | NOT WS_BORDER
END
@ -401,8 +400,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,2,0,1
PRODUCTVERSION 3,2,0,1
FILEVERSION 3,2,0,2
PRODUCTVERSION 3,2,0,2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -420,13 +419,13 @@ BEGIN
VALUE "Comments", "FreeScan ECU ALDL scantool."
VALUE "CompanyName", "Andy Whittaker - mail@andywhittaker.com"
VALUE "FileDescription", "Scantool for monitoring ECUs/PCMs"
VALUE "FileVersion", "3.2.0.1"
VALUE "FileVersion", "3.2.0.2"
VALUE "InternalName", "FreeScan"
VALUE "LegalCopyright", "Copyright (C) 1999-2018 Andy Whittaker, mail@andywhittaker.com"
VALUE "LegalCopyright", "Copyright (C) 1999-20198 Andy Whittaker, mail@andywhittaker.com"
VALUE "LegalTrademarks", "www.andywhittaker.com"
VALUE "OriginalFilename", "FreeScan.exe"
VALUE "ProductName", "FreeScan"
VALUE "ProductVersion", "3.2.0.1"
VALUE "ProductVersion", "3.2.0.2"
END
END
BLOCK "VarFileInfo"
@ -3966,6 +3965,11 @@ BEGIN
0
END
IDD_STATUS AFX_DIALOG_LAYOUT
BEGIN
0
END
/////////////////////////////////////////////////////////////////////////////
//
@ -3977,7 +3981,7 @@ BEGIN
IDP_OLE_INIT_FAILED "OLE initialization failed. Make sure that the OLE libraries are the correct version."
IDS_ABOUTBOX "&About FreeScan..."
IDS_TITLE "FreeScan - ECU/PCM Scantool"
IDS_VERSION "FreeScan v3.1.0.1"
IDS_VERSION "FreeScan v3.2.0.1"
END
STRINGTABLE

View File

@ -1,5 +1,19 @@
// Base code is derivitive of Zafir's CString class found on the www.CodeGuru.com site.
/* For future reference from a post from 2008 in codeguru:
Zapper, that article is 9 YEARS OLD.
The missing features referred to by the article to have long been implemented in CString.
In addition, back then CString had a dependency on MFC, but since Visual C++ 2005,
his dependency has been removed and MFC is no longer required to use CString. The underlying
CString functionality is implemented by CStringT and you just need to include "atlstr.h" to use it in your app.
You can read all about the CStringT class in msdn.
P.S. Don't use CStringT directly, just include "atlstr.h" and
use CString (including the header will properly typedef CStringT into CString for you).
*/
#include "StdAfx.h"
#include "MABString.h"
#include "math.h"
@ -243,7 +257,7 @@ int CStringEx::ReverseFind( LPCTSTR lpszSub, int startpos /*= -1*/ ) const
// startpos - Position to start looking from, in reverse dir
int CStringEx::ReverseFindNoCase(TCHAR ch, int startpos /*= -1*/ ) const
{
TCHAR a[2];
TCHAR a[3];
a[1] = ch;
a[2] = 0;
return ReverseFindNoCase( a, startpos );

View File

@ -228,7 +228,7 @@ void CFreeScanDlg::WriteLogEntry(LPCTSTR pstrFormat, ...)
void CFreeScanDlg::WriteStatusLogged(CString csText)
{
m_pStatusDlg->WriteStatusLogged(csText);
m_pStatusDlg->WriteStatusTimeLogged(csText);
}
// Starts or stops csv logging to file

View File

@ -49,7 +49,7 @@ public:
//Attributes
CStatusDlg* m_pStatusDlg; // This is the "Spy" window
CSupervisor* m_pSupervisor; // This phathoms out the data-stream
CSupervisor* m_pSupervisor; // This fathoms out the data-stream
BOOL m_bHasRun; // Has the supervisor ran at least once?
//Classes for our property pages

View File

@ -30,7 +30,7 @@ CEspritParser::CEspritParser()
memset(m_ucDTC, 0, 3);// Reset DTC buffer
CFreeScanApp* pApp = (CFreeScanApp*) AfxGetApp();
m_csCSVLogFile = pApp->GetProfileString("EspritParser", "CSV Log Filename", "");
m_csCSVLogFile = pApp->GetProfileString(_T("EspritParser"), _T("CSV Log Filename"), _T(""));
m_dwCSVRecord = 0; // Initialise the CSV record number
}
@ -57,11 +57,11 @@ void CEspritParser::WriteCSV(BOOL bTitle)
if (bTitle)
{
m_dwCSVRecord = 0;
csBuf = "Esprit Sample,Coolant Sensor V,Start Water Temp,TPS V,Des Idle,RPM,Road Speed,Crank Sensors,O2,Rich/Lean,Integrator,BLM,BLM Cell,Injector Base PW,IAC,Baro,MAP,A:F,TPS,MAT V,Knock Retard,Knock Count,BatV,Load,Spark,Coolant Temp,MAT,Wastegate DC,Secondary Injectors DC,Engine Running Time, A/C Demand, A/C Clutch, Closed Loop";
csBuf = _T("Esprit Sample,Coolant Sensor V,Start Water Temp,TPS V,Des Idle,RPM,Road Speed,Crank Sensors,O2,Rich/Lean,Integrator,BLM,BLM Cell,Injector Base PW,IAC,Baro,MAP,A:F,TPS,MAT V,Knock Retard,Knock Count,BatV,Load,Spark,Coolant Temp,MAT,Wastegate DC,Secondary Injectors DC,Engine Running Time, A/C Demand, A/C Clutch, Closed Loop");
}
else
{
csBuf.Format("%ld,%4.2f,%3.1f,%4.2f,%d,%d,%d,%d,%5.3f,%d,%d,%d,%d,%d,%d,%4.2f,%4.2f,%3.1f,%d,%4.2f,%3.1f,%d,%3.1f,%d,%3.1f,%3.1f,%3.1f,%d,%d,%d,%d,%d,%d",
csBuf.Format(_T("%ld,%4.2f,%3.1f,%4.2f,%d,%d,%d,%d,%5.3f,%d,%d,%d,%d,%d,%d,%4.2f,%4.2f,%3.1f,%d,%4.2f,%3.1f,%d,%3.1f,%d,%3.1f,%3.1f,%3.1f,%d,%d,%d,%d,%d,%d"),
m_dwCSVRecord,m_pSupervisor->m_fWaterVolts,m_pSupervisor->m_fStartWaterTemp,m_pSupervisor->m_fThrottleVolts,
m_pSupervisor->m_iDesiredIdle,m_pSupervisor->m_iRPM,m_pSupervisor->m_iMPH,m_pSupervisor->m_iCrankSensors,m_pSupervisor->m_fO2VoltsLeft,m_pSupervisor->m_iRichLeanCounterL,
m_pSupervisor->m_iIntegratorL,m_pSupervisor->m_iBLM, m_pSupervisor->m_iBLMCell,m_pSupervisor->m_iInjectorBasePWMsL,
@ -71,24 +71,24 @@ void CEspritParser::WriteCSV(BOOL bTitle)
m_pSupervisor->m_iRunTime,m_pSupervisor->m_bACRequest,m_pSupervisor->m_bACClutch,m_pSupervisor->m_bEngineClosedLoop);
m_dwCSVRecord++;
}
csBuf = csBuf + "\n"; // Line Feed because we're logging to disk
csBuf = csBuf + _T("\n"); // Line Feed because we're logging to disk
m_file.WriteString(csBuf);
}
// Starts or stops csv logging to file
BOOL CEspritParser::StartCSVLog(BOOL bStart)
{
CString csBuf = "";
CString csBuf = _T("");
if (!bStart)
{ // we want to close the logging file
if (m_file.m_hFile != CFile::hFileNull)
{
WriteStatusLogged("CSV Log has been stopped");
WriteStatusLogged(_T("CSV Log has been stopped"));
m_file.Close(); // close the logging file when we exit.
}
else
WriteStatusLogged("CSV Log is already closed");
WriteStatusLogged(_T("CSV Log is already closed"));
return FALSE;
}
@ -96,13 +96,13 @@ BOOL CEspritParser::StartCSVLog(BOOL bStart)
// We now must want to log to a file
// Construct our File Dialog
CFileDialog Dialog(FALSE, "csv",
CFileDialog Dialog(FALSE, _T("csv"),
m_csCSVLogFile,
OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT,
"log Files (*.csv)|*.csv|All Files (*.*)|*.*||", NULL);
_T("log Files (*.csv)|*.csv|All Files (*.*)|*.*||"), NULL);
// Change the title
Dialog.m_ofn.lpstrTitle = "Create/Open CSV Log";
Dialog.m_ofn.lpstrTitle = _T("Create/Open CSV Log");
// Display the dialog box
if (Dialog.DoModal() == IDOK)
@ -111,17 +111,17 @@ BOOL CEspritParser::StartCSVLog(BOOL bStart)
if (!m_file.Open(m_csCSVLogFile, CFile::modeCreate | CFile::modeReadWrite | CFile::typeText))
{
csBuf.Format("Cannot open %s", m_csCSVLogFile);
csBuf.Format(_T("Cannot open %s"), m_csCSVLogFile.GetString());
WriteStatus(csBuf);
AfxMessageBox(csBuf, MB_OK | MB_ICONSTOP );
return FALSE;
}
WriteStatusLogged("CSV Log has been opened");
WriteStatusLogged(_T("CSV Log has been opened"));
WriteCSV(TRUE); // log our data to a csv file
}
else // User pressed cancel
WriteStatus("User cancelled CSV log");
WriteStatus(_T("User cancelled CSV log"));
if (m_file.m_hFile != NULL)
return TRUE;
@ -168,14 +168,14 @@ int CEspritParser::Parse(unsigned char* buffer, int iLength)
else
{
CString temp; // write to the spy window
temp.Format("Unrecognised Mode: %02x", buffer[iIndex]);
temp.Format(_T("Unrecognised Mode: %02x"), buffer[iIndex]);
WriteStatus(temp);
}
iIndex += iPacketLength;
}
// Check CRC
if (!CheckChecksum(pPacketStart, 3 + iPacketLength))
WriteStatus("Checksum Error");
WriteStatus(_T("Checksum Error"));
break;
}
case 0x0a: // Computed Values
@ -187,7 +187,7 @@ int CEspritParser::Parse(unsigned char* buffer, int iLength)
iIndex += iPacketLength; // should be 3
// Check CRC
if (!CheckChecksum(pPacketStart, 3 + iPacketLength))
WriteStatus("Checksum Error");
WriteStatus(_T("Checksum Error"));
break;
}
case 0x05: // ADC Values
@ -199,13 +199,13 @@ int CEspritParser::Parse(unsigned char* buffer, int iLength)
iIndex += iPacketLength; // should be 10 or 58 from ECU
// Check CRC
if (!CheckChecksum(pPacketStart, 3 + iPacketLength))
WriteStatus("Checksum Error");
WriteStatus(_T("Checksum Error"));
break;
}
default:
{
CString buf;
buf.Format("%02x <- Unrecognised Header", buffer[iIndex]);
buf.Format(_T("%02x <- Unrecognised Header"), buffer[iIndex]);
WriteStatus(buf);
}
}// Switch
@ -217,14 +217,14 @@ int CEspritParser::Parse(unsigned char* buffer, int iLength)
return iLength; // Successfully parsed.
}
// Translates the incomming data stream as ADC Values
// Translates the incoming data stream as ADC Values
void CEspritParser::ParseADC(unsigned char* buffer, int len)
{
int iIndex;
if (len>10)
{
WriteStatus("Warning: F005 larger than expected, packet truncated.");
WriteStatus(_T("Warning: F005 larger than expected, packet truncated."));
len = 10;
}
else
@ -258,7 +258,7 @@ void CEspritParser::ParseAnalogues(unsigned char* buffer, int len)
if (len>3)
{
WriteStatus("Warning: F00A larger than expected, packet truncated.");
WriteStatus(_T("Warning: F00A larger than expected, packet truncated."));
len = 3;
}
// copy buffer into raw data array
@ -277,12 +277,12 @@ void CEspritParser::ParseMode1(unsigned char* buffer, int len)
if (len<10) // remember half duplex. We read our commands as well
{
WriteStatus("Received our TX command echo for mode 1.");
WriteStatus(_T("Received our TX command echo for mode 1."));
return;
}
else if (len>65)
{
WriteStatus("Warning: F001 larger than expected, packet truncated.");
WriteStatus(_T("Warning: F001 larger than expected, packet truncated."));
len = 65;
}
// copy buffer into raw data array

View File

@ -83,7 +83,7 @@ void CGMBaseFunctions::WriteLogEntry(LPCTSTR pstrFormat, ...)
void CGMBaseFunctions::WriteStatusLogged(CString csText)
{
m_pStatusDlg->WriteStatusLogged(csText);
m_pStatusDlg->WriteStatusTimeLogged(csText);
}
// Calculates and checks the CRC

View File

@ -1,5 +1,5 @@
# FreeScan
FreeScan is a ALDL Scan Tool for various GM based ALDL vehicles
FreeScan is an ALDL Scan Tool for various GM based ALDL vehicles
## Background
When I owned my Lotus Esprit GT3 MY1997, I was concerned with the lack of diagnostic scan tools available. Therefore, I took apart the ECU, unplugged the MemCal, read in the binary code, disassembled it with IDA Pro and found out how the diagnostics worked.

View File

@ -438,7 +438,7 @@ UINT CSerialPort::CommThread(LPVOID pParam)
default:
{
// All other error codes indicate a serious error has
// occured. Process this error.
// occurred. Process this error.
port->ProcessErrorMessage("WaitCommEvent()");
AfxThrowSerialException();
break;
@ -454,7 +454,7 @@ UINT CSerialPort::CommThread(LPVOID pParam)
// (which this program does not do) you will have the situation occur
// where the first byte to arrive will cause the WaitForMultipleObjects()
// function to stop waiting. The WaitForMultipleObjects() function
// resets the event handle in m_OverlappedStruct.hEvent to the non-signelead state
// resets the event handle in m_OverlappedStruct.hEvent to the non-signaled state
// as it returns.
//
// If in the time between the reset of this event and the call to
@ -496,7 +496,7 @@ UINT CSerialPort::CommThread(LPVOID pParam)
case 0:
{
// Shutdown event. This is event zero so it will be
// the higest priority and be serviced first.
// the highest priority and be serviced first.
// Tell the rest of the code that the thread is dying.
port->m_bThreadAlive = FALSE;
@ -693,6 +693,7 @@ void CSerialPort::WriteChar(CSerialPort* port)
TRACE(_T("WARNING: WriteFile() error.. Bytes Sent: %d; Message Length: %d\n"),
BytesSent, port->m_nActualWriteBufferSize);
}
}
// Character received. Inform the owner

View File

@ -103,7 +103,7 @@ void CStatusDlg::WriteStatus(CString csText)
}
//WriteStatus enters text into the list box at the end of the list with timestamp
void CStatusDlg::WriteStatusLogged(CString csText)
void CStatusDlg::WriteStatusTimeLogged(CString csText)
{
if (m_hidden) // don't write to window when hidden
return;
@ -131,12 +131,12 @@ void CStatusDlg::WriteASCII(unsigned char * buffer, int ilength)
for(iIndex=0; iIndex < ilength; iIndex++)
{
CString csTemp;
csTemp.Format("0x%02X ", buffer[iIndex]);
csTemp.Format(_T("0x%02X "), buffer[iIndex]);
cs = cs + csTemp; // concatenate string
}
// Now write the string.
WriteStatusLogged(cs);
WriteStatusTimeLogged(cs);
}
//Writes a formatted log entry to the log file
@ -175,17 +175,17 @@ void CStatusDlg::WriteLogEntry(LPCTSTR pstrFormat, ...)
// Starts or stops logging to file
BOOL CStatusDlg::StartLog(BOOL bStart)
{
CString csBuf = "";
CString csBuf = _T("");
if (!bStart)
{ // we want to close the logging file
if (m_file.m_hFile != CFile::hFileNull)
{
WriteStatusLogged(_T("Log file stopped"));
WriteStatusTimeLogged(_T("Log file stopped"));
m_file.Close(); // close the logging file when we exit.
}
else
WriteStatusLogged(_T("Log file is already closed"));
WriteStatusTimeLogged(_T("Log file is already closed"));
return FALSE;
}
@ -258,7 +258,7 @@ BOOL CStatusDlg::StartLog(BOOL bStart)
return FALSE;
}
WriteStatusLogged(_T("Log file has started"));
WriteStatusTimeLogged(_T("Log file has started"));
/*
// Construct our File Dialog
@ -385,7 +385,7 @@ BOOL CStatusDlg::Create(CWnd* pParentWnd)
return CDialog::Create(IDD, pParentWnd);
}
// This tracks the window's postition
// This tracks the window's position
void CStatusDlg::OnMove(int x, int y)
{
CDialog::OnMove(x, y);

View File

@ -24,7 +24,7 @@ public:
~CStatusDlg(); // standard destructor
void WriteStatus(CString csText);
void WriteStatusLogged(CString csText);
void WriteStatusTimeLogged(CString csText);
void WriteASCII(unsigned char * buffer, int ilength);
void WriteLogEntry(LPCTSTR pstrFormat, ...);
BOOL StartLog(BOOL bStart);

BIN
serialport.zip Normal file

Binary file not shown.