Analysis of the C++ MFC source code for the DDEC Interface application
DIF (DDEC Interface) is a Windows desktop application written in C++ using Microsoft Foundation Classes (MFC). It communicates directly with Detroit Diesel Electronic Control (DDEC) Engine Control Modules via the J1708/J1587 vehicle data bus protocol. It is used in test labs for engine calibration, diagnostics, and performance tuning.
| Property |
Value |
| Solution |
DIF.sln (Visual Studio 2010+ format) |
| Toolset |
v142 (Visual Studio 2019) |
| Framework |
MFC (Dynamic in Release, Static in Debug) |
| Character Set |
MultiByte |
| Platforms |
Win32, x64 |
| Configurations |
Debug, Release, Template |
| Install Path |
C:\CMC (hardcoded) |
┌──────────────────────────────────────────────────────┐
│ DIF Application │
│ │
│ ┌─────────┐ ┌──────────┐ ┌─────────────────────┐ │
│ │ GUI │ │ Task │ │ Worker Thread │ │
│ │ Thread │─>│ Manager │─>│ (Continuous Poll) │ │
│ └────┬────┘ └────┬─────┘ └────┬────────────────┘ │
│ │ │ │ │
│ v v v │
│ ┌─────────────────────────────────────┐ │
│ │ CCMC Class │ │
│ │ (Message Read/Write Abstraction) │ │
│ └──────────┬──────────┬───────────────┘ │
│ │ │ │
│ ┌───────┘ └────────┐ │
│ v v │
│ ┌─────────────┐ ┌──────────────────┐ │
│ │ CMC Card │ │ RP1210 Wrapper │ │
│ │ (MJ170832) │ │ (RP1210 DLL) │ │
│ └──────┬──────┘ └───────┬──────────┘ │
│ │ │ │
└─────────┼───────────────────┼────────────────────────┘
│ │
v v
┌───────────┐ ┌──────────────┐
│ CMC Card │ │ Serial/USB │
│ Hardware │ │ Translator │
└─────┬─────┘ └──────┬───────┘
│ │
└────────┬─────────┘
v
┌─────────────────┐
│ J1708 Serial │
│ Data Bus │
└────────┬────────┘
v
┌─────────────────┐
│ DDEC ECM │
│ (Engine) │
└─────────────────┘
| File |
Class |
Purpose |
| DIF.cpp/h |
CDIFApp |
Main application class, DLL loading, mode selection |
| MainFrm.cpp/h |
CMainFrame |
Main window frame, toolbar, status bar |
| DIFDoc.cpp/h |
CDIFDoc |
Document class (MFC SDI pattern), worker thread management |
| DIFView.cpp/h |
CDIFView |
Main view rendering |
| DIFCmdLine.cpp/h |
CDIFCmdLine |
Command-line argument parsing |
| Splash.cpp/h |
CSplash |
Splash screen on startup |
| File |
Class |
Purpose |
| CMC.cpp/h |
CCMC |
Abstraction over CMC card and RP1210. Provides Read_Message/Write_Message |
| RP1210Wrapper.cpp/h |
CRP1210Wrapper |
RP1210 protocol driver wrapper. Loads DLLs, manages sessions |
| include/MCOMM.H |
- |
Common definitions for MultiCom protocols |
| include/MJ1708.H |
- |
J1708 protocol structures and constants |
| include/MGEN.H |
- |
General MultiCom library definitions |
| File |
Class |
Purpose |
| ecmdata.cpp/h |
CEcmData, CPIDInfo, CPIDData |
ECM parameter definitions and runtime data |
| extractdata.cpp/h |
- |
J1587 message parsing, PID extraction |
| CSVFILE.cpp/h |
CCSVFile |
CSV configuration file parser |
| ptrdb.cpp/h |
- |
PowerTek Real-Time Database (RDB) interface |
| File |
Class |
Purpose |
| TaskManager.cpp/h |
CTaskManager |
Async task scheduling and retry management |
| CodesTask.cpp/h |
CCodesTask |
Diagnostic fault code operations |
| RatingTask.cpp/h |
CRatingTask |
Engine rating changes |
| GovGainTask.cpp/h |
CGovGainTask |
Governor gain adjustments |
| VSGTask.cpp/h |
CVSGTask |
Variable Speed Governor min/max settings |
| SlewingDlg.cpp/h |
CSlewingDlg |
Parameter slewing dialog |
| File |
Class |
Purpose |
| logfile.cpp/h |
CLogFile |
Message logging to ecmmsgs.dat |
| BenchMark.cpp/h |
CBenchMark |
Performance measurement |
| TimedMsgbox.cpp/h |
CTimedMsgBox |
Auto-dismissing message box |
- Serial bus communication (SAE J1708)
- Default 9600 baud (configurable up to 38400)
- Maximum message size: 26 bytes
- Checksummed frames
- Message ID (MID) identifies the ECM (128=Master, 175/183=Receivers)
- Parameter ID (PID) identifies the data parameter
- Priority-based bus access
| PID Range |
Data Size |
Description |
| 0-127 |
1 byte |
Single-byte parameters |
| 128-191 |
2 bytes |
Double-byte parameters |
| 192-253 |
Variable (1st byte = length) |
Multi-byte parameters |
| 254 |
Variable |
DDEC unique/custom parameters |
| 255 |
- |
Page selector (extends to PIDs 256-1511) |
Raw Bytes from ECM
│
v
Extract PID data (based on data type: bit, int8, uns8, int16, uns16, int32, uns32)
│
v
Apply scale factor: ScaledValue = RawValue * ScaleFactor
│
v
Apply conversion: DisplayValue = (ScaledValue * ConvMult) + ConvAdd
│
v
Write to PowerTek RDB channel
| Thread |
Role |
| GUI Thread |
User interface, task creation, dialog management |
| Worker Thread |
Continuous J1708 bus monitoring, message parsing, RDB updates |
| Timer-based retries |
Each task type has a dedicated Windows timer for timeout handling |
- Critical sections (
CComAutoCriticalSection) protect shared data
- Task list uses
CObList with synchronized access
- Windows messages (WM_*_ACK) communicate from worker -> GUI thread
| File |
Purpose |
| DDECParm.txt |
EDMS parameter names to monitor from PowerTek TDEF |
| DDEC2.csv, DDEC3.csv, DDEC4.csv |
PID definitions per ECM type |
| Codes.csv |
Diagnostic fault code definitions |
| Channel.csv |
Channel configuration |
| MAPxxyyz.csv |
Memory map tables for calibration editing |
| RP121032.INI |
RP1210 driver configuration (Windows directory) |
| ECM |
MID |
Generation |
| Master (EC1) |
128 |
DDEC II/III/IV/V |
| Receiver 1 (EC2) |
129/175 |
Multi-ECM engines |
| Receiver 2 (EC3) |
130/183 |
Multi-ECM engines |
| Interface |
Driver DLL |
Description |
| CMC MultiCom-II |
MGen32.dll + MJ170832.dll |
PCI/ISA card for direct bus access |
| Dearborn (Beige) |
DD121032.dll |
Serial port translator |
| Dearborn Multilink |
DM121032.dll |
Serial port translator |
| Library |
Source |
Purpose |
| MGen32.lib |
CMC (Computer Methods Corporation) |
General hardware functions |
| MJ170832.lib |
CMC |
J1708 protocol functions |
| REMOTEDB.lib |
PowerTek |
Real-Time Database integration |
| RP1210 DLLs |
Various vendors |
Standard vehicle comm protocol |
struct J1708MSG {
FPULONG fpulTimeStamp; // 4 bytes - message timestamp
BYTE bMID; // 1 byte - ECM Message ID
FPBYTE fpbData; // N bytes - data payload
BYTE bChecksum; // 1 byte - J1587 checksum
BYTE bPriority; // 1 byte - bus priority
USHORT usSize; // 2 bytes - data length
ULONG ulMsgControl; // 4 bytes - status/control flags
};
class CPIDInfo {
int m_nPID; // J1587 Parameter ID (0-1511)
CString m_EDMSname; // PowerTek EDMS name (e.g., "EC1_RPM")
int m_dataType; // bit, int8, uns8, int16, uns16, int32, uns32
float m_fScaleFactor; // Raw-to-engineering scaling
int m_nBitOffset; // For bit-level extraction
int m_nBitSize; // For bit-level extraction
float m_fConvMult; // Unit conversion multiplier
float m_fConvAdd; // Unit conversion offset
};
class CPIDData {
union { int nVal; float fVal; } m_nDataVal; // Raw value
float m_fScaledValue; // Engineering units
int m_nRDBHandle; // PowerTek DB handle
time_t m_tLastTimeUpdated; // Staleness detection
};
The DIF application reveals how the DRS (Dealer Reprogramming System) client communicates with DDEC ECMs. Key findings for the DDEC migration project:
The DDEC system uses the older J1708 serial bus protocol. This means:
- Communication is serial, not CAN bus
- RP1210 is the standard API for PC-to-bus communication
- Multiple ECMs share the same bus (Master + Receivers)
- The 6N4 numbering system (6N4C, 6N4D, 6N4M) is directly read from ECM PIDs
DDEC Web Server -> Download calibration file (ZIP)
|
v
DRS Client -> Decrypt (XOR) -> Decompress (PKWARE DCL) -> Parse segments
|
v
Write to ECM via J1708/J1587
|
v
ECM stores in EEPROM/Flash
ECM -> J1708 Bus -> RP1210 Adapter -> DIF Application
|
+-> PowerTek RDB -> iTest Display
+-> CSV Log Files
+-> ECMCOMM (mailslot automation)
+-> APT_INJ -> TOPFLITE Mainframe
- Protocol library needed: Any new client must implement RP1210 or use existing RP1210 DLLs
- J1587 PID definitions are critical: The CSV files define the data dictionary
- Password security: ECM operations require multi-level passwords
- Multi-ECM support: Must handle Master + up to 2 Receiver ECMs
- Real-time requirements: Worker thread must continuously poll the bus
- Calibration table format: MAP files define memory layout for table editing