Information on Peak Can USB

This forum covers issues concerning multiple software products.

Information on Peak Can USB

Postby pilou007 » Wed 13. Dec 2017, 15:54

Hello
I am trying to get information from a peak Can USB device. Working in C++ on Qt5
First of all, I can have more than one peak can connected on my computer via USB.
I want for example the port on wich it is connected the value like 7F or FF taht I entered in with peak can view or the exemple software provided with the api.....
The only thing I can get are:

Code: Select all
#define PCAN_DEVICE_NUMBER       0x01  // PCAN-USB device number parameter
#define PCAN_5VOLTS_POWER        0x02  // PCAN-PC Card 5-Volt power parameter
#define PCAN_RECEIVE_EVENT       0x03  // PCAN receive event handler parameter
#define PCAN_MESSAGE_FILTER      0x04  // PCAN message filter parameter
#define PCAN_API_VERSION         0x05  // PCAN-Basic API version parameter
#define PCAN_CHANNEL_VERSION     0x06  // PCAN device channel version parameter
#define PCAN_BUSOFF_AUTORESET    0x07  // PCAN Reset-On-Busoff parameter
#define PCAN_LISTEN_ONLY         0x08  // PCAN Listen-Only parameter
#define PCAN_LOG_LOCATION        0x09  // Directory path for trace files
#define PCAN_LOG_STATUS          0x0A  // Debug-Trace activation status
#define PCAN_LOG_CONFIGURE       0x0B  // Configuration of the debugged information (LOG_FUNCTION_***)
#define PCAN_LOG_TEXT            0x0C  // Custom insertion of text into the log file
#define PCAN_CHANNEL_CONDITION   0x0D  // Availability status of a PCAN-Channel
#define PCAN_HARDWARE_NAME       0x0E  // PCAN hardware name parameter
#define PCAN_RECEIVE_STATUS      0x0F  // Message reception status of a PCAN-Channel

Threw the getvalue function. But the Hardware name is the same for all peak can and I cannot discriminate the device with those information, how can I get that?
Thank you very much
Last edited by M.Gerber on Wed 13. Dec 2017, 16:13, edited 1 time in total.
Reason: Inserted [code] tag for improved readability
pilou007
 
Posts: 4
Joined: Wed 13. Dec 2017, 15:48

Re: Information on Peak Can USB

Postby K.Wagner » Wed 13. Dec 2017, 16:20

Helllo,

the number you set over PCAN-View or the PCAN-basic samples is the Device-ID (or device Number) of a PCAN-USB device, for instance:

PCAN-View.PNG
PCAN-View - Device-ID
PCAN-View.PNG (87.34 KiB) Viewed 1634 times


This value can be retrieved using the Parameter "PCAN_DEVICE_NUMBER":
Code: Select all
TPCANStatus result;
unsigned int iBuffer;

result = CAN_GetValue(PCAN_USBBUS1, PCAN_DEVICE_NUMBER, (void*)&iBuffer, sizeof(iBuffer));


Remarks:
  1. If your header file only contains 15 PCAN parameters (until PCAN_RECEIVE_STATUS) then you are using an old version of PCAN-Basic. Please update your API.
  2. Please note that we do not officially support Qt, so question regarding this will be ignored.
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 621
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: Information on Peak Can USB

Postby pilou007 » Thu 14. Dec 2017, 11:51

Hello Thank for your help...
You are right, I have updated the Can API. But in the PCanBsic.h (the new one) it misses some stuf as:
Code: Select all
typedef unsigned char         BYTE;
typedef unsigned short         WORD;
typedef unsigned long                   DWORD;
typedef unsigned long long              UINT64;
typedef char*                           LPSTR;
As it is used in some fucntions...

And my issues was because I try to get all available devices and put them in a combo box. But obviously I cannot retireve the device number as long as I am not connected to it...
The only information I can get are "Harware name" (which is the same for all peak-can) and the api version....
And concerning Qt, I can use the DLL and the Lib as in VS but it's may be why the .h is not complete...
Thank for your answer
pilou007
 
Posts: 4
Joined: Wed 13. Dec 2017, 15:48

Re: Information on Peak Can USB

Postby K.Wagner » Thu 14. Dec 2017, 12:08

Hello,

typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned long long UINT64;
typedef char* LPSTR;

Those are Windows types. You need to include Windows.h somewhere in your project.
Code: Select all
#include <windows.h>


pilou007 wrote:The only information I can get are "Harware name" (which is the same for all peak-can) and the api version....

This is a limitation of the PCAN-Basic. You can do one of two things:
  • Use the PCAN-Developer package, which allow to do many more things (is also more complicated to use and you need to buy a license for it).
  • You could use the "Channel Identification" parameter which works in not connected USB devices. IN this case, you can at least let see which device is assigned to which channel.
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 621
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: Information on Peak Can USB

Postby pilou007 » Thu 14. Dec 2017, 17:51

Ok, I'll try that ..
By the way, I don't understand why we got 8 PCAN_USBBUS in a row (from 0x51 to 0x58) and the 8 after in another row from (0x509 to 0x510)... That's weird to follow the sixteen or I don't get it...
Code: Select all
#define PCAN_USBBUS1                 0x51U  // PCAN-USB interface, channel 1
#define PCAN_USBBUS2                 0x52U  // PCAN-USB interface, channel 2
#define PCAN_USBBUS3                 0x53U  // PCAN-USB interface, channel 3
#define PCAN_USBBUS4                 0x54U  // PCAN-USB interface, channel 4
#define PCAN_USBBUS5                 0x55U  // PCAN-USB interface, channel 5
#define PCAN_USBBUS6                 0x56U  // PCAN-USB interface, channel 6
#define PCAN_USBBUS7                 0x57U  // PCAN-USB interface, channel 7
#define PCAN_USBBUS8                 0x58U  // PCAN-USB interface, channel 8
#define PCAN_USBBUS9                 0x509U  // PCAN-USB interface, channel 9
#define PCAN_USBBUS10                0x50AU  // PCAN-USB interface, channel 10
#define PCAN_USBBUS11                0x50BU  // PCAN-USB interface, channel 11
#define PCAN_USBBUS12                0x50CU  // PCAN-USB interface, channel 12
#define PCAN_USBBUS13                0x50DU  // PCAN-USB interface, channel 13
#define PCAN_USBBUS14                0x50EU  // PCAN-USB interface, channel 14
#define PCAN_USBBUS15                0x50FU  // PCAN-USB interface, channel 15
#define PCAN_USBBUS16                0x510U  // PCAN-USB interface, channel 16
pilou007
 
Posts: 4
Joined: Wed 13. Dec 2017, 15:48

Re: Information on Peak Can USB

Postby K.Wagner » Fri 15. Dec 2017, 08:38

pilou007 wrote:By the way, I don't understand why we got 8 PCAN_USBBUS in a row (from 0x51 to 0x58) and the 8 after in another row from (0x509 to 0x510)...

It has to do with the internal representation of a PCAN-Channel. In older versions (max. 8 channels) a TPCANHandle was only one BYTE in length. In order to handle up to 16 channels, the length of a TPCANHandle was incremented to two bytes (WORD). The first 8 channels were not changed to guarantee backward compatibility. New channels were defined with the new format.

pilou007 wrote:That's weird to follow the sixteen or I don't get it...

If this is so weird for you, then you can use the same numeration for the first 8 channels, since the API support this:
Code: Select all
#define PCAN_USBBUS1                 0x501U  // PCAN-USB interface, channel 1
#define PCAN_USBBUS2                 0x502U  // PCAN-USB interface, channel 2
#define PCAN_USBBUS3                 0x503U  // PCAN-USB interface, channel 3
#define PCAN_USBBUS4                 0x504U  // PCAN-USB interface, channel 4
#define PCAN_USBBUS5                 0x505U  // PCAN-USB interface, channel 5
#define PCAN_USBBUS6                 0x506U  // PCAN-USB interface, channel 6
#define PCAN_USBBUS7                 0x507U  // PCAN-USB interface, channel 7
#define PCAN_USBBUS8                 0x508U  // PCAN-USB interface, channel 8
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 621
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: Information on Peak Can USB

Postby pilou007 » Fri 15. Dec 2017, 10:46

Ok,
Thantks a lot.
pilou007
 
Posts: 4
Joined: Wed 13. Dec 2017, 15:48


Return to Software



cron

This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy