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] = {};
uint8_t count = 0;
ER ret = MPXOpen(devices, 1, &count);
if (ret != E_OK || count == 0) return;
uint32_t 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) Start
ret = MPXMonitorStart(serial, MPX_SYNC_MASTER);
if (ret != E_OK) return;
// 4) Periodic acquisition
StMPXLINLog logs[100];
uint16_t got = 0;
uint8_t over = 0;
ret = MPXLINGetLogEx(serial, logs, 100, &got, &over);
// 5) Stop
uint32_t mSec = 0;
uint16_t uSec = 0;
MPXMonitorStop(serial, &mSec, &uSec);
MPXClose();