PLIN API Read Hardware - Name

Windows® Compatible Software for Displaying LIN Messages
Post Reply
Kieutrang
Posts: 2
Joined: Sat 31. Aug 2019, 04:11

PLIN API Read Hardware - Name

Post by Kieutrang » Thu 10. Oct 2019, 10:07

Hello,
I want to read the hardware-name of the device "pcan-usb pro" using PLIN-API 11.01.2011 - Version 2.2.28.71.

code:

Code: Select all

Peak.Lin.TLINError lLINErr;
StringBuilder lnName = new StringBuilder();

lLINErr = Peak.Lin.PLinApi.GetHardwareParam(lwHw, Peak.Lin.TLINHardwareParam.hwpName,lnName,47);

lLINErr == errBufferInsufficient :?
What did i do wrong?

Thx!

M.Riedl
Software Development
Software Development
Posts: 34
Joined: Wed 22. Sep 2010, 13:28

Re: PLIN API Read Hardware - Name

Post by M.Riedl » Thu 10. Oct 2019, 11:33

Hello,

Could you please use the lastest version of the PLINAPI first:
https://www.peak-system.com/PLIN-API.142.0.html
https://www.peak-system.com/fileadmin/m ... in-api.zip

And install the lastest LIN device driver:
https://www.peak-system.com/quick/DrvSetup

The error code errBufferInsufficient means that the buffer size of lnName is insufficient (0 bytes).

To initialize a string buffer with 47 bytes you should use instead the following::

Code: Select all

var lnName = new StringBuilder(47)
This will fix your issue.

For more information, see also the Microsoft documentation of StringBuilder constructors:
https://docs.microsoft.com/en-us/dotnet ... lder.-ctor

Regards
M.Riedl

Post Reply