Page 1 of 1

PLIN API Read Hardware - Name

Posted: Thu 10. Oct 2019, 10:07
by Kieutrang
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!

Re: PLIN API Read Hardware - Name

Posted: Thu 10. Oct 2019, 11:33
by M.Riedl
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