PCAN_ERROR_UNKNOWN

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
Philipp2
Posts: 8
Joined: Sun 1. Oct 2023, 17:01

PCAN_ERROR_UNKNOWN

Post by Philipp2 » Mon 9. Oct 2023, 18:37

Hello,

I'm developing an interface to PCAN-Micro-FD (using Java 17), but I'm getting PCAN_ERROR_UNKNOWN and cannot find the problem.

1. Installed all dlls (for java) according to your documentation
2. Configured PCAN-Micro-FD (fig1 attached) with protocoll CAN FD
3. Connection with PCAN-View is fine (settings fig2 attached)
4. But Java
4.1 Settings of connection
PCANBasic can = null;
TPCANStatus status = null;
TPCANBitrateFD br = new TPCANBitrateFD("f_clock_mhz=80, nom_brp=5, nom_tseg1=2, nom_tseg2=1, nom_sjw=1, data_brp=2, data_tseg1=3, data_tseg2=1, data_sjw=1");
status = can.InitializeFD(TPCANHandle.PCAN_PCIBUS1, br);
-> Status: PCAN_ERROR_OK which should be fine, but
can.GetStatus(TPCANHandle.PCAN_PCIBUS1)
-> returns Status: PCAN_ERROR_UNKNOWN

I searched all documentations and this forum, but except of
"#define PCAN_BR_CLOCK __T("f_clock")
#define PCAN_BR_CLOCK_MHZ __T("f_clock_mhz")
#define PCAN_BR_NOM_BRP __T("nom_brp")
.
.
."

I found no explanation how to define TPCANBitrateFD according to the settings of the MicroMod FD?

Hopefully someone can help

best wishes Philipp
Attachments
Settings of PCAN-View, which connects
Settings of PCAN-View, which connects
2.PCanViewConnect.png (154.3 KiB) Viewed 13733 times
Settings of PCAN-MicroModFD
Settings of PCAN-MicroModFD
1.Einstellungen-MicroModFD.png (195.05 KiB) Viewed 13733 times

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: PCAN_ERROR_UNKNOWN

Post by K.Wagner » Tue 10. Oct 2023, 10:20

Hello,
Philipp2 wrote:
Mon 9. Oct 2023, 18:37
I found no explanation how to define TPCANBitrateFD according to the settings of the MicroMod FD?
The same bit rate values used with the Micro-Mod are found in PCAN-View too. You can just use PCAN-View for copying the bit rate parameter string from the connection window and use it for the PCAN-Basic initialization. The "..." button let's you see all parameters in detail, but you have to know how to handle them (advanced):
Copy bit rate parameters for SAE J2284-4
Copy bit rate parameters for SAE J2284-4
CopyBRparams.PNG (65.27 KiB) Viewed 13715 times
Regarding the ERROR_UNKNOWN with CAN_GetStatus, well this is weird. This error is normally returned, when some abnormal issue is detected; on the other hand, asking the status is quite a small and fast function that has as good as no place for such problems.

Try using the correct bit rate parameters and check again the result of the CAN_GetStatus function.
Best regards,
Keneth

Philipp2
Posts: 8
Joined: Sun 1. Oct 2023, 17:01

Re: PCAN_ERROR_UNKNOWN

Post by Philipp2 » Tue 10. Oct 2023, 12:34

Hi,

thank you very much, I got the params to connect successfully:

"f_clock=80000000,nom_brp=2,nom_tseg1=63,nom_tseg2=16,nom_sjw=16,data_brp=2,data_tseg1=15,data_tseg2=4,data_sjw=4"

now, I'll have the next problem reading the data, but I'll try to figure it out by myself first

best wishes Philipp

caspan
Posts: 1
Joined: Thu 14. Sep 2023, 16:09

Re: PCAN_ERROR_UNKNOWN

Post by caspan » Wed 11. Oct 2023, 11:58

Hello K.Wagner, if I understand correctly the higher the f_clock frequency the more the chance to receive all the data. Should we take care of the buffer size somehow (e.g. to set a FiFo logic) via the PCANBasic.py lib?

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: PCAN_ERROR_UNKNOWN

Post by K.Wagner » Wed 11. Oct 2023, 14:05

Hello,
caspan wrote:
Wed 11. Oct 2023, 11:58
the higher the f_clock frequency the more the chance to receive all the data
If you work with 8Mhz or 80MHz, it doesn't change anything in the way you have to read the messages from the queue. To get all the data you just have to periodically call CAN_Read and be sure you read the queue empty each time (until CAN_Read returns PCAN_ERROR_QRCVEMPTY). You have to do this fast enought so that the queue doesn't get full and you lost messages.

For reading you can use a timer or events. This is explained in the companion project samples.
Best regards,
Keneth

Post Reply