Skip to content

Update PCAN Basic to 4.6.2.753 - #1481

Merged
zariiii9003 merged 5 commits into
hardbyte:developfrom
zariiii9003:update_pcan_basic
Jan 20, 2023
Merged

zariiii9003 merged 5 commits into
hardbyte:developfrom
zariiii9003:update_pcan_basic

Conversation

@zariiii9003

Copy link
Copy Markdown
Collaborator

@lumagi Since you have a PEAK device, could you check whether "channel": channel.device_name + str(channel.controller_number) is correct?

It is used in can.detect_available_configs("pcan")

@zariiii9003 zariiii9003 added this to the Next Release milestone Jan 8, 2023
@zariiii9003 zariiii9003 self-assigned this Jan 8, 2023
@lumagi

lumagi commented Jan 8, 2023

Copy link
Copy Markdown
Collaborator

Sure, I can test it. But it's gonna have to wait until Tuesday because I won't have access to the hardware until then.

@lumagi

lumagi commented Jan 14, 2023

Copy link
Copy Markdown
Collaborator

I'm sorry to keep you waiting on this. I was planning to test this on my Windows machine (at work), but I didn't get a chance to. I have reserved some time for Monday to test this.

@zariiii9003

Copy link
Copy Markdown
Collaborator Author

I'm sorry to keep you waiting on this. I was planning to test this on my Windows machine (at work), but I didn't get a chance to. I have reserved some time for Monday to test this.

It's not urgent, don't worry

@lumagi

lumagi commented Jan 16, 2023

Copy link
Copy Markdown
Collaborator

I ran can.detect_available_configs("pcan") with a single PCAN USB FD attached. One problem I ran into is that channel.device_name is of type bytes instead of str. When I fixed that, it returned the following result:

[{'interface': 'pcan', 'channel': 'PCAN-USB FD0', 'supports_fd': True}]

It looks like channel.device_name does not return the required PCAN_USBBUS and channel.controller_number is zero-based.

@zariiii9003

Copy link
Copy Markdown
Collaborator Author

Thank you for testing this! I guess we would need to search for TPCANChannelInformation.channel_handle in PCAN_CHANNEL_NAMES, right?

@lumagi

lumagi commented Jan 16, 2023 •

Copy link
Copy Markdown
Collaborator

Yes, I agree. The channel_handle had a value of 0x51 in my case, which is the numeric equivalent of PCAN_USBBUS1. That would allow a reverse lookup. Here is the binary output of PCAN_ATTACHED_CHANNELS, i.e. TPCANChannelInformation, to allow you to write a unit test:

b'Q\x00\x05\x00\x01\x00\x00\x00PCAN-USB FD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x003"\x11\x00\x01\x00\x00\x00'

I can test it again afterwards.

@zariiii9003

Copy link
Copy Markdown
Collaborator Author

That's great, thank you!

@lumagi

lumagi commented Jan 17, 2023

Copy link
Copy Markdown
Collaborator

I tested again with:

configs = can.detect_available_configs("pcan")
print(configs)

and two interfaces attached. This is what I get:

[{'interface': 'pcan', 'channel': 'PCAN_USBBUS1', 'supports_fd': True}, {'interface': 'pcan', 'channel': 'PCAN_USBBUS2', 'supports_fd': True}]

So looks nice!

One thing that came to my mind is the device_id in TPCANChannelInformation. Could that be exported as well or would that break compatibility or some constraints for the dictionary entries in the result? Since the channel name can change between reboots or between plugging in / out some adapters, the device_id provides a means to detect a specific adapter more reliably.

@zariiii9003

Copy link
Copy Markdown
Collaborator Author

I think it should be okay as long as there are no conflicts with the arguments of the __init__ method.
I also added more info for vector:

"hw_type": channel_config.hw_type,

Do you need anything else besides device_id?

@lumagi

lumagi commented Jan 17, 2023

Copy link
Copy Markdown
Collaborator

Good question. Off the top of my head, I would say maybe device_type and channel_condition for additional inflection needs that other people might have.

@zariiii9003
zariiii9003 marked this pull request as ready for review January 17, 2023 16:52
@zariiii9003
zariiii9003 merged commit 35de98e into hardbyte:develop Jan 20, 2023
@zariiii9003
zariiii9003 deleted the update_pcan_basic branch January 20, 2023 14:50
Tbruno25 pushed a commit to Tbruno25/python-can that referenced this pull request Jan 23, 2023
* update PCAN Basic to 4.6.2.753

* faster channel detection

* fix PcanBus._detect_available_configs

* remove TODO

* add more information to pcan channel detection

Co-authored-by: zariiii9003 <zariiii9003@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants