Microsoft Visual C++ LIN Monitor Program
Screen Layout
| Item | Description |
|---|---|
| Start button | Click to start monitoring. |
| Stop button | Click to stop monitoring. |
| Log display area (Area 1) | Displays received log information. Up to 100 logs are retained. If exceeded, oldest logs are cleared first. When monitoring is restarted after stop, previous logs are all cleared. See Log Display Details. |
Log Display Details
| Item | Description |
|---|---|
| msec | Timestamp (milliseconds). |
| usec | Timestamp (microseconds). |
| Dir | Log direction. Rx: receive log, Tx: transmit log |
| Type | Log type or error content. |
| Format | Depends on log type: Header: SyncBreak width, Wakeup: wakeup pulse width |
| ID | LIN ID in hexadecimal. |
| DL | Data length (1 to 8). |
| Data | Data (D1 to D8) in hexadecimal, comma-separated. |
| Checksum | Checksum in hexadecimal. |
Error Handling
Program terminates with an error dialog in the following cases.
- MicroPeckerX could not be recognized at program startup
- API call failed at monitoring start/stop or during monitoring
Implementation Example (Commented Source)
Source: MPXCtrl_LIN_CPP_MonSample/MPXCtrl_LIN_CPP_MonSample/Form1.h
// 1) Open
StMPXDeviceInfo devices[1] = {};
unsigned char count = 0;
ER ret = MPXOpen(devices, 1, &count);
if (ret != E_OK || count == 0) return;
unsigned long serial = devices[0].Serial;
// 2) LIN parameter setup (monitor)
StMPXLINParam lin = {};
lin.Mode = MPX_LIN_MODE_MONITOR;
lin.Revision = MPX_LIN_REV_21;
lin.Baudrate = 19200;
lin.SyncBreak = 13;
lin.Delimiter = 1;
lin.HeaderSpace = 1;
lin.ResponseSpace = 1;
lin.ByteSpace = 1;
ret = MPXLINSetParam(serial, &lin);
if (ret != E_OK) return;
// 3) Log acquisition method
MPXSetGetLogMode(serial, MPX_INNERCH_LIN, MPX_GETLOGMODE_GETLOGAPI);
// 4) Start
ret = MPXMonitorStart(serial, MPX_SYNC_MASTER);
if (ret != E_OK) return;
// 5) Periodic acquisition
StMPXLINLog logs[100];
unsigned short got = 0;
unsigned char over = 0;
ret = MPXLINGetLogEx(serial, logs, 100, &got, &over);
// 6) Stop
unsigned long mSec = 0;
unsigned short uSec = 0;
MPXMonitorStop(serial, &mSec, &uSec);
MPXClose();