Can_GetValue & Can_SetValue

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
Terje
Posts: 18
Joined: Sun 27. Sep 2020, 19:04

Can_GetValue & Can_SetValue

Post by Terje » Sun 27. Sep 2020, 19:32

Hi.
I'm writing my own application in a linux computer running Ubuntu 18.04.5 64-Bit.
I have today downloaded latest driver and api from Peak-Systems online DVD.

Interface driver 1.4.6
Peak linux driver 8.10.2
Interface typ PCAN-USB IPEH-002021-303018

I can read and write data to the can-bus. No problems.
But I cannot use the SetValue & GetValue functions.

Well I can read and get a value. But cannot modify the value.

Example:

Code: Select all

	int fd;
	Status = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K, 0, 0, 0);
	printf("CAN_Initialize(%xh): Status=0x%x\n", pcan_device, (int)Status);
	if (Status)
		goto lbl_exit;
	fd=2;
	Status = CAN_SetValue(PCAN_USBBUS1, PCAN_DEVICE_NUMBER, &fd, sizeof fd);
	printf("PCAN_DEVICE_NUMBER %d - Status=0x%x\n",fd, (int)Status);


	sleep(5);
	fd=0;
	Status = CAN_GetValue(PCAN_USBBUS1, PCAN_DEVICE_NUMBER, &fd, sizeof fd);
	printf("PCAN_DEVICE_NUMBER %d - Status=0x%x\n",fd, (int)Status);

Will output:

Code: Select all

CAN_Initialize(51h): Status=0x0
PCAN_DEVICE_NUMBER 2 - Status=0x0
Error unhandled errno (19 / 0x13)
.PCAN_DEVICE_NUMBER 0 - Status=0x10000
It should result in 2 after the GetValue call.

Even the PCAN_CHANNEL_IDENTIFYING fails. No blinking except the normal flashing when communicating.
(Expect fast blinking during identification.)

I have probably done something wrong. Please help me.
I need to set some kind of ID on every PCAN-USB adapter to be able to know who is who.

/T.
Last edited by K.Wagner on Mon 28. Sep 2020, 08:25, edited 1 time in total.
Reason: Code formatting for better reading

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: Can_GetValue & Can_SetValue

Post by M.Heidemann » Mon 28. Sep 2020, 11:00

Hello,

Thank your for your request.

Are you using a VM to test this?


Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Terje
Posts: 18
Joined: Sun 27. Sep 2020, 19:04

Re: Can_GetValue & Can_SetValue

Post by Terje » Tue 29. Sep 2020, 19:23

Hi.

No. I'm running on a Lenovo ThinkPad computer. No Virtual Machine.

Anyways, I succeeded at last with Setting values.

It looks like only a sudo user can modify the values.

But still I can't get the identification method working.
The LED blinks slowly, with or without the identification method.

/Terje.

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: Can_GetValue & Can_SetValue

Post by M.Heidemann » Wed 30. Sep 2020, 16:35

Hello,

This beheaviour is fixed in a prerelease version of PCAN-Basic,
which we could send you.

Please contact us at support[at]peak-system.com

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Post Reply