Skip to main content
Version: 4.00

Microsoft Visual C++ LIN Monitor Program

Screen Layout​

C++ LIN Monitor Program
ItemDescription
Start buttonClick to start monitoring.
Stop buttonClick 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​

ItemDescription
msecTimestamp (milliseconds).
usecTimestamp (microseconds).
DirLog direction.
Rx: receive log, Tx: transmit log
TypeLog type or error content.
FormatDepends on log type:
Header: SyncBreak width, Wakeup: wakeup pulse width
IDLIN ID in hexadecimal.
DLData length (1 to 8).
DataData (D1 to D8) in hexadecimal, comma-separated.
ChecksumChecksum 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();