WP_Query Object
(
    [query] => Array
        (
            [paged] => 9
            [pagename] => about-us/news
        )

    [query_vars] => Array
        (
            [paged] => 9
            [pagename] => about-us/news
            [error] => 
            [m] => 
            [p] => 0
            [post_parent] => 
            [subpost] => 
            [subpost_id] => 
            [attachment] => 
            [attachment_id] => 0
            [name] => 
            [page_id] => 0
            [second] => 
            [minute] => 
            [hour] => 
            [day] => 0
            [monthnum] => 0
            [year] => 0
            [w] => 0
            [category_name] => 
            [tag] => 
            [cat] => 
            [tag_id] => 
            [author] => 
            [author_name] => 
            [feed] => 
            [tb] => 
            [meta_key] => 
            [meta_value] => 
            [preview] => 
            [s] => 
            [sentence] => 
            [title] => 
            [fields] => 
            [menu_order] => 
            [embed] => 
            [category__in] => Array
                (
                )

            [category__not_in] => Array
                (
                    [0] => 1047
                )

            [category__and] => Array
                (
                )

            [post__in] => Array
                (
                )

            [post__not_in] => Array
                (
                )

            [post_name__in] => Array
                (
                )

            [tag__in] => Array
                (
                )

            [tag__not_in] => Array
                (
                )

            [tag__and] => Array
                (
                )

            [tag_slug__in] => Array
                (
                )

            [tag_slug__and] => Array
                (
                )

            [post_parent__in] => Array
                (
                )

            [post_parent__not_in] => Array
                (
                )

            [author__in] => Array
                (
                )

            [author__not_in] => Array
                (
                )

            [orderby] => date
            [post_type] => Array
                (
                    [0] => post
                    [1] => developer_blog
                )

            [post_status] => publish
            [order] => DESC
            [tax_query] => Array
                (
                    [0] => Array
                        (
                            [taxonomy] => blog-group
                            [field] => slug
                            [terms] => Array
                                (
                                    [0] => public
                                )

                            [operator] => IN
                        )

                    [1] => Array
                        (
                            [taxonomy] => blog-group
                            [field] => slug
                            [terms] => Array
                                (
                                    [0] => general-user
                                    [1] => technical-asociate
                                    [2] => qualified-sales-representative
                                    [3] => kvaser-internal
                                )

                            [operator] => NOT IN
                        )

                )

            [ignore_sticky_posts] => 
            [suppress_filters] => 
            [cache_results] => 1
            [update_post_term_cache] => 1
            [lazy_load_term_meta] => 1
            [update_post_meta_cache] => 1
            [posts_per_page] => 10
            [nopaging] => 
            [comments_per_page] => 50
            [no_found_rows] => 
            [taxonomy] => blog-group
            [term] => public
        )

    [tax_query] => WP_Tax_Query Object
        (
            [queries] => Array
                (
                    [0] => Array
                        (
                            [taxonomy] => blog-group
                            [terms] => Array
                                (
                                    [0] => public
                                )

                            [field] => slug
                            [operator] => IN
                            [include_children] => 1
                        )

                    [1] => Array
                        (
                            [taxonomy] => blog-group
                            [terms] => Array
                                (
                                    [0] => general-user
                                    [1] => technical-asociate
                                    [2] => qualified-sales-representative
                                    [3] => kvaser-internal
                                )

                            [field] => slug
                            [operator] => NOT IN
                            [include_children] => 1
                        )

                    [2] => Array
                        (
                            [taxonomy] => category
                            [terms] => Array
                                (
                                    [0] => 1047
                                )

                            [field] => term_id
                            [operator] => NOT IN
                            [include_children] => 
                        )

                )

            [relation] => AND
            [table_aliases:protected] => Array
                (
                    [0] => wp_term_relationships
                )

            [queried_terms] => Array
                (
                    [blog-group] => Array
                        (
                            [terms] => Array
                                (
                                    [0] => public
                                )

                            [field] => slug
                        )

                )

            [primary_table] => wp_posts
            [primary_id_column] => ID
        )

    [meta_query] => WP_Meta_Query Object
        (
            [queries] => Array
                (
                )

            [relation] => 
            [meta_table] => 
            [meta_id_column] => 
            [primary_table] => 
            [primary_id_column] => 
            [table_aliases:protected] => Array
                (
                )

            [clauses:protected] => Array
                (
                )

            [has_or_relation:protected] => 
        )

    [date_query] => 
    [queried_object] => WP_Post Object
        (
            [ID] => 1277
            [post_author] => 38
            [post_date] => 2014-11-21 12:03:40
            [post_date_gmt] => 2013-12-19 15:28:51
            [post_content] => 
            [post_title] => News
            [post_excerpt] => 
            [post_status] => publish
            [comment_status] => open
            [ping_status] => open
            [post_password] => 
            [post_name] => news
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2021-08-12 09:14:30
            [post_modified_gmt] => 2021-08-12 09:14:30
            [post_content_filtered] => 
            [post_parent] => 23
            [guid] => https://www.kvaser.com/?page_id=1277
            [menu_order] => 5
            [post_type] => page
            [post_mime_type] => 
            [comment_count] => 0
            [filter] => raw
        )

    [queried_object_id] => 1277
    [request] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1  AND ( 
  wp_term_relationships.term_taxonomy_id IN (1026) 
  AND 
  wp_posts.ID NOT IN (
				SELECT object_id
				FROM wp_term_relationships
				WHERE term_taxonomy_id IN (1025,1027,1028,1029)
			) 
  AND 
  wp_posts.ID NOT IN (
				SELECT object_id
				FROM wp_term_relationships
				WHERE term_taxonomy_id IN (1058)
			)
) AND wp_posts.post_type IN ('post', 'developer_blog') AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 80, 10
    [posts] => Array
        (
            [0] => WP_Post Object
                (
                    [ID] => 36950
                    [post_author] => 38400
                    [post_date] => 2022-01-21 14:23:23
                    [post_date_gmt] => 2022-01-21 14:23:23
                    [post_content] => [vc_row][vc_column][vc_single_image image="36956"][/vc_column][vc_column][vc_column_text]Rensselaer Formula Hybrid is a student led club that designs, builds, and races an all electric formula style race car for the annual Formula Hybrid competition in Loudon, New Hampshire. We design and manufacture the majority of our parts in house, which allows us to gain valuable engineering experience.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_single_image image="36957"][/vc_column][vc_column width="1/2"][vc_column_text]A large subsystem of the car is its electronics, which include the high voltage battery and power for the motor and also lower voltage safety and telemetry systems. As the team’s knowledge has grown, we’ve started designing and programming custom printed circuit boards to meet system requirements instead of buying off the shelf models. This year, we’ve decided to use CAN communication protocols between our boards, as it’s an industry standard. This also allows us to use less wires on the car itself, increases the amount of data we can send, and reduces noise in the signal, especially when travelling from one end of the car to the other. [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="2/3"][vc_column_text]We would like to thank Kvaser for their generous donation of a Kvaser Leaf Light HS v2, which is a CAN to USB interface. This system allows us to connect our circuit board CAN signals to a laptop, as it comes with a 9 pin D-SUB to USB connector with galvanic isolation as protection. With its high speed and accurate sampling, we can test our circuit boards, and ensure that each board can both send and receive all the data needed for the race car. The Leaf Light HS v2 also comes with a software suite, programming interface, and documentation, which will allow us to debug and test easily, and will also allow us to build team knowledge of how to use the software for CAN interfaces. [/vc_column_text][/vc_column][vc_column width="1/3"][vc_single_image image="36959"][/vc_column][/vc_row]
                    [post_title] => Rensselaer Formula Hybrid use Kvaser to test custom circuit boards
                    [post_excerpt] => 
                    [post_status] => publish
                    [comment_status] => closed
                    [ping_status] => closed
                    [post_password] => 
                    [post_name] => rensselaer-formula-hybrid-use-kvaser-to-test-custom-circuit-boards
                    [to_ping] => 
                    [pinged] => 
                    [post_modified] => 2022-07-22 22:56:47
                    [post_modified_gmt] => 2022-07-22 22:56:47
                    [post_content_filtered] => 
                    [post_parent] => 0
                    [guid] => https://www.kvaser.com/?p=36950
                    [menu_order] => 0
                    [post_type] => post
                    [post_mime_type] => 
                    [comment_count] => 0
                    [filter] => raw
                )

            [1] => WP_Post Object
                (
                    [ID] => 38144
                    [post_author] => 23
                    [post_date] => 2021-12-21 21:56:23
                    [post_date_gmt] => 2021-12-21 21:56:23
                    [post_content] => [vc_row][vc_column][vc_column_text]

This is the second of two articles that introduce Kvaser CANlib and the Python CANlib Wrapper.

In this article, we will introduce some typical scenarios involving CAN, learn about different commands and functions while using CAN and gain a wider understanding of CAN, canlib and Kvaser Interfaces.

Writer: Anton Carlsson,  Software Developer

Cowriter: L-G Fredriksson, Field Application Engineer

Version: 2021-08-09A

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649371866326{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h4" header="Who should read this?"][vc_column_text]

This guide has been written for those who want to set up and use a Kvaser CAN interface with CANlib and the Python CANlib package/wrapper.

To use this guide, the user needs to be somewhat familiar with (or able to look up) the following:

[/vc_column_text][vc_column_text]
  • Some knowledge about the operating system that will be used. More knowledge is needed when using Linux rather than Windows.
  • How to open and use the basic commands in a command-line application, such as the Command Prompt or Windows PowerShell.
  • Knowledge of how programming works is not necessary but will help. Additionally, any experience with Python will greatly simplify the process.
[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Prepare Python for CANlib"][vc_column_text]

Please read the paper: Kvaser CANlib & Python Part 1, Initial setup

Please note: Some of the samples are written for three interfaces.

[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Quick start procedure, reminder"][vc_column_text]

If you have taken a break or just forgotten the used commands/procedure, please use this little list of powerful commands and instructions.

[/vc_column_text][vc_column_text]
  • Start Windows Powershell:   powershell.exe
  • Move to desired directory where you have your Python script: cd (if you already have a virtual environment and permission to run it, skip the next two steps)
  • Create a virtual environment:  py -3 -m venv .venv --prompt.
  • If you are using a new computer or a new user without permission: Set-ExecutionPolicy Unrestricted -Scope CurrentUser
  • Activate the virtual environment:  .\.venv\Scripts\activate
  • If you have not already installed canlib in this virtual environment do so: pip install canlib
  • ...
  • Run script: py check_ch.py”(check_ch.py is always good to run once to make sure the wanted interfaces are connected)
  • Start editor: python -m idlelib python -m idlelib check_ch.py
  • ...
  • Deactivate the virtual environment:  deactivate
[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Send a CAN message"][vc_column_text]

(This information is a copy from the paper:Kvaser CANlib & Python Part 1, First setup)

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649377624425{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Simple approach"][vc_column_text]

To send a basic CAN message, create a script named send_msg.py containing the following code (make sure that the script is located within the same folder as the virtual environment):

[/vc_column_text][vc_code_raket language="python" code="JTIzc2VuZF9tc2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hpcC4lMjBUbyUyMGRvJTIwdGhpcyUyMGNhbGwlMjAuYnVzT2ZmJTI4JTI5JTIwb24lMjBib3RoJTIwY2hhbm5lbHMlMjB0aGF0JTIwd2VudCUyMC5idXNPbiUyOCUyOSUwQWNoX2EuYnVzT2ZmJTI4JTI5JTBBY2hfYi5idXNPZmYlMjglMjklRTIlODAlQTglMEElMjMlMjBMYXN0bHklMkMlMjBjbG9zZSUyMGFsbCUyMGNoYW5uZWxzJTIwd2l0aCUyMGNsb3NlJTI4JTI5JTIwdG8lMjBmaW5pc2glMjB1cC4lMEFjaF9hLmNsb3NlJTI4JTI5JTBBY2hfYi5jbG9zZSUyOCUyOSUwQSUwQSUyMyUyMERlcGVuZGluZyUyMG9uJTIwdGhlJTIwc2l0dWF0aW9uJTIwaXQlMjBpcyUyMG5vdCUyMGFsd2F5cyUyMG5lY2Vzc2FyeSUyMG9yJTIwcHJlZmVyYWJsZSUyMHRvJTIwZ28lMjBvZiUwQSUyMyUyMHRoZSUyMGJ1cyUyMHdpdGglMjB0aGUlMjBjaGFubmVscyUyMGFuZCUyQyUyMGluc3RlYWQlMjBvbmx5JTIwdXNlJTIwY2xvc2UlMjglMjkuJTIwQnV0JTIwdGhpcyUyMHdpbGwlMjBiZSUwQSUyMyUyMHRhbGtlZCUyMG1vcmUlMjBhYm91dCUyMGxhdGVyLg=="][vc_column_text]

To run the previous program, activate your virtual environment and run the script using powershell. Running the program will result in something like the following:

[/vc_column_text][vc_code_raket language="t" code="JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTI4cHlwcm9qJTI5JTNFJTIwcHklMjBzZW5kX21zZy5weSUwQUZyYW1lJTI4aWQlM0QxMjMlMkMlMjBkYXRhJTNEYnl0ZWFycmF5JTI4YiUyN0hFTExPJTIxJTI3JTI5JTJDJTIwZGxjJTNENiUyQyUyMGZsYWdzJTNEJTNDTWVzc2FnZUZsYWcuU1REJTNBJTIwMiUzRSUyQyUyMHRpbWVzdGFtcCUzRDklMjk="][/vc_column][/vc_row][vc_row css=".vc_custom_1649377610352{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Simple approach using virtual interfaces"][vc_column_text]

If we want to use the virtual interface and the virtual channels, we need to change the openchannel commands. Firstly we need to change the numbers from 0 and 1 to 2 and 3 to represent the virtual channels. Then we need to add a flag (another input) that says ACCEPT_VIRTUAL to define that a virtual channel will be used and accepted. The command will now look like:

[/vc_column_text][vc_code_raket language="t" code="JTA5Y2FubGliLm9wZW5DaGFubmVsJTI4Y2hhbm5lbCUzRDIlMkMlMjBmbGFncyUzRGNhbmxpYi5vcGVuLkFDQ0VQVF9WSVJUVUFMJTI5"][vc_column_text]

If we do not add the ACCEPT_VIRTUAL flag we will receive a Specified device not found (-3). It is also important to note that a virtual channel can only communicate with another virtual channel.

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649377601710{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="A more Pythonic way"][vc_column_text]

The code used in send a CAN message is a very standard and straightforward way to write the script we want. Using Python however we can write the code in a more “Pythonic way”. This will lead to the following script names send_msg_pyt.py:

[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwc2VuZF9tc2dfcHl0JTBBZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUyQyUyMEZyYW1lJTBBJTBBJTIzJTIwaW5zdGVhZCUyMG9mJTIwb3BlbmluZyUyMHRoZSUyMHR3byUyMGNoYW5uZWxzJTIwYW5kJTIwY2xvc2luZyUyMHRoZW0lMjBvbmUlMjBieSUyMG9uZSUyQyUyMHdlJTIwd2lsbCUyMHVzZSUyMGElMEElMjMlMjB3aXRoJTIwc3RhdGVtZW50LiUyMFVzaW5nJTIwdGhlJTIwd2l0aCUyMHN0YXRlbWVudCUyMHRvJTIwb3BlbiUyMG9uZSUyMG9yJTIwbW9yZSUyMGNoYW5uZWxzJTIwd2l0aCUwQSUyMyUyMGNhbmxpYi5vcGV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GNoLmJ1c09uJTI4JTI5JTBBJTBBJTIwJTIwJTIwJTIwZnJhbWUlMjAlM0QlMjBGcmFtZSUyOGlkXyUzRDEyMyUyQyUyMGRhdGElM0QlNUI3MiUyQyUyMDY5JTJDJTIwNzYlMkMlMjA3NiUyQyUyMDc5JTJDJTIwMzMlNUQlMjklMEElMjAlMjAlMjAlMjBjaF9hLndyaXRlJTI4ZnJhbWUlMjklMEElMEElMjAlMjAlMjAlMjBtc2clMjAlM0QlMjBjaF9iLnJlYWQlMjh0aW1lb3V0JTNENTAwJTI5JTBBJTIwJTIwJTIwJTIwcHJpbnQlMjhtc2clMjklMEElMEElMjMlMjBBZnRlciUyMHdlJTIwcnVuJTIwb3V0JTIwb2YlMjBjb2RlJTIwd2l0aGluJTIwdGhlJTIwd2l0aCUyMHN0YXRlbWVudCUyMGFuZCUyMGV4aXQlMjBpdCUyQyUyMHdlJTIwZG9uJUUyJTgwJTk5dCUwQSUyMyUyMG5lZWQlMjB0byUyMG1hbnVhbGx5JTIwY2xvc2UlMjBpdCUyMG9yJTIwZ28lMjBvZmYlMjBidXMuJTIwVGhlJTIwY2hhbm5lbHMlMjB0aGF0JTIwd2VyZSUyMG9wZW4lMjB1c2luZyUwQSUyMyUyMHRoZSUyMHdpdGglMjBzdGF0ZW1lbnQlMjB3aWxsJTIwYmUlMjBhdXRvbWF0aWNhbGx5JTIwY2xvc2VkJTJDJTIwYW5kJTIwd2l0aCUyMHRoZSUyMGNoYW5uZWxzJTIwYmVpbmclMEElMjMlMjBjbG9zZWQlMjB0aGV5JTIwYWxzbyUyMHdlbnQlMjBvZmYlMjB0aGUlMjBidXMu"][/vc_column][/vc_row][vc_row css=".vc_custom_1649377592106{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Wait"][vc_column_text]

While writing several messages, we might want to confirm that they were received properly. To do this we will make use of the command writeWait(). writeWait does the same as write when it comes to sending a message, but it also gives a timeout limit for how long it will wait for the message to be sent. The command may look like writeWait(frame, timeout=500), this will send a message with the details given by frame and wait 500 milliseconds for it to be sent before returning an error message Timeout occurred (-7). WriteWait can be used when sending one or multiple messages. When sending several messages we can use writeWait on every message, but this will take time to execute and is not very efficient. Instead we can use write on all messages, apart from the last one which will be writeWait. If one message fails to be sent properly, all after will fail and the timeout error Timeout occured (-7) will be raised by writeWait.

To test writeWait, we will make two scripts called send_msg_wait.py and send_msgs_wait.py which will be based on the send message code but with some changes. The first script send_msg_wait.py will send a message using writeWait to send one successful message and one unsuccessful message:

[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwc2VuZF9tc2dfd2FpdCUwQWZyb20lMjBjYW5saWIlMjBpbXBvcnQlMjBjYW5saWIlMkMlMjBGcmFtZSUwQSUwQSUyMyUyMFdlJTIwd2lsbCUyMG5vdyUyMG9wZW4lMjB0aHJlZSUyMGNoYW5uZWxzJTJDJTIwdHdvJTIwZnJvbSUyMHRoZSUyMFVTQmNhbiUyMGFuZCUyMG9uZSUyMG9uJTBBJTIzJTIwdGhlJTIwbGVhZiUyMHBybyUyMHdoaWNoJTIwd2UlMjB3aWxsJTIwbm90JTIwY29ubmVjdCUyMHRvJTIwdGhlJTIwVC1jYW5uZWN0b3IuJTIwV2UlMjB3aWxsJTIwdXNlJTIwdGhlJTBBJTIzJTIwbGVhZiUyMHBybyUyMGNoYW5uZWwlMjBjaF9jJTIwdG8lMjBzZW5kJTIwZXJyb3JmcmFtZXMuJTBBd2l0aCUyMGNhbmxpYi5vcGVuQ2hhbm5lbCUyODIlMjklMjBhcyUyMGNoX2ElMkMlMjBjYW5saWIub3BlbkNoYW5uZWwlMjgzJTI5JTIwYXMlMjBjaF9iJTJDJTIwY2FubGliLm9wZW5DaGFubmVsJTI4NCUyOSUyMGFzJTIwY2hfYyUzQSUwQSUyMCUyMCUyMCUyMGZvciUyMGNoJTIwaW4lMjAlNUJjaF9hJTJDJTIwY2hfYiUyQyUyMGNoX2MlNUQlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjaC5idX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wJTIwcHJpbnQlMjhtc2clMjk="][vc_column_text]

In the next script send_msgs_wait-py we will send multiple messages and using waitWrite to make sure that the messages were sent:

[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwc2VuZF9tc2dzX3dhaXQlMEFmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwY2FubGliJTJDJTIwRnJhbWUlMEElMEElMjMlMjBXZSUyMHdpbGwlMjBub3clMjBvcGVuJTIwdGhyZWUlMjBjaGFubmVscyUyQyUyMHR3byUyMGZyb20lMjB0aGUlMjBVU0JjYW4lMjBhbmQlMjBvbmUlMjBvbiUyMHRoZSUwQSUyMyUyMGxlYWYlMjBwcm8lMjB3aGljaCUyMHdlJTIwd2lsbCUyMG5vdCUyMGNvbm5lY3QlMjB0byUyMHRoZSUyMFQtY2FubmVjdG9yLiUyMFdlJTIwd2lsbCUyMHVzZSUyMHRoZSUwQSUyMyUyMGxlYWYlMjBwcm8lMjBjaGFubmVsJTIwY2hfYyUyMHRvJTIwc2VuZCUyMGVycm9yZnJhbWVzLiUwQXdpdGglMjBjYW5saWIub3BlbkNoYW5uZWwlMjgyJTI5JTIwYXMlMjBjaF9hJTJDJTIwY2FubGliLm9wZW5DaGFubmVsJTI4MyUyOSUyMGFzJTIwY2hfYiUyQyUyMGNhbmxpYi5vcGVuQ2hhbm5lbCUyODQlMjklMjBhcyUyMGNoX2MlM0ElMEElMjAlMjAlMjAlMjBmb3IlMjBjaCUyMGluJTIwJTVCY2hfYSUyQyUyMGNoX2IlMkMlMjBjaF9jJTVEJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwY2guYnVzT24lMjglMjklMEElMEElMjAlMjAlMjAlMjBmcmFtZSUyMCUzRCUyMEZyYW1lJTI4aWRfJTNEMTIzJTJDJTIwZGF0YSUzRCU1QjcyJTJDJTIwNjklMkMlMjA3NiUyQyUyMDc2JTJDJTIwNzklMkMlMjAzMyU1RCUyOSUwQSUyMCUyMCUyMCUyMCVFMiU4MCVBOCUyM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DAlMjklMEElMEElMjAlMjAlMjAlMjBtc2clMjAlM0QlMjBjaF9iLnJlYWQlMjh0aW1lb3V0JTNENTAwJTI5JTBBJTIwJTIwJTIwJTIwcHJpbnQlMjhtc2clMjk="][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Required hardware"][vc_column_text]

For part two of this guide we will need at least three channels, so if the device we used for Part One does not have three channels, we need another device. In this guide a Kvaser Leaf Pro HS v2 will be used, in addition to the Kvaser USBcan Pro 2xHS v2.

[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Silent mode"][vc_column_text]

While receiving messages with CANlib using the CAN channels that are onbus (channels that have gone on bus with busOn), there are two possible modes to choose from. The two modes are Normal and Silent mode and are called bus modes. To set the bus driver mode use “Channel.setBusOutputControl”. 

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649377491870{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Normal mode"][vc_column_text]

Normal mode is the default mode for Kvaser interfaces and can be manually set to “canlib.canlib.Driver.NORMAL” using setBusOutputControl. Normal mode means that the driver is a standard push-pull, which means that it can both send (push) and receive (pull) messages on the bus.

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649377486241{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Silent mode"][vc_column_text]

Silent mode is supported by some controllers and can be set to “canlib.canlib.driver.SILENT” using setBusOutputControl. While in silent mode, the driver will be set to receive only. This means that the controller will not transmit anything on the bus, not even ack (acknowledgement) bits. This can be useful when listening to a CAN bus without wanting to interfere in any way. The silent channel can still be used when calling .write, but the message will not be sent properly. Instead the messages will go into the “transmit queue” without being sent. This will become apparent when there are too many messages in the transmit queue and we get a Transmit buffer overflow error.

Note that not all devices support silent mode. However when we try to set a device that does not support silent mode, we will not receive any indication that the device did not change its mode. Instead, the device will send messages and act like a device on normal mode. This can be a problem if we switch around the devices, without changing their channels. Therefore, before setting a channel to silent mode we want to make sure that the channel/device supports silent mode. There are two ways of doing this. Either we can get the user guide from the Kvaser website, go to Technical data and look in the table to see if it is supported or not, or more preferable, use channel_data. To get the capabilities of the channel, use channel_data.channel_cap. Then create an if statement to see if ChannelCap.SILENT_MODE (silent mode) is included in channel_data.channel_cap.

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649377478737{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Example"][vc_column_text]

To show how silent mode is used we will reuse the example for sending a CAN message and add to it. The comments used previously have been removed and new comments have been added for the new code. 

The first example shows that the silent channel does not interfere with a sent message from another channel. Use the following code in a script:

[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwc2lsZW50X21vZGUlMEFmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwY2FubGliJTJDJTIwRnJhbWUlMEElMEFjaF9hJTIwJTNEJTIwY2FubGliLm9wZW5DaGFubmVsJTI4Y2hhbm5lbCUzRDAlMjklMEFjaF9iJTIwJTNEJTIwY2FubGliLm9wZW5DaGFubmVsJTI4Y2hhbm5lbCUzRDElMjklMEElMEElMjMlMjBVc2luZyUyMHRoZSUyMHNldEJ1c091dHB1dENvbnRyb2wlMjBtZXRob2QlMjB3ZSUyMHNldCUyMGNoX2ElMjAlMjhjaGFubmVsJTIwMCUyOSUyMHRvJTIwbm9ybWFsLiUyMFRoaXMlMjAlMEElMjMlMjBsaW5lJTIwaXMlMjBub3QlMjBuZWNlc3NhcnklMkMlMjBhcyUyMG5vcm1hbCUyMGlzJTIwdGhlJTIwZGVmYXVsdCUyMG1vZGUlMkMlMjBidXQlMjBmb3IlMjB0aGUlMjBzYWtlJTIwb2YlMEElMjMlMjBjbGFyaXR5JTIwd2UlMjB3aWxsJTIwYWRkJTIwaXQlMjBhbnl3YXkuJTIwVGhlbiUyMHdlJTIwZG8lMjB0aGUlMjBzYW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klMkMlMjAzMyU1RCUyOSUwQWNoX2Eud3JpdGUlMjhmcmFtZSUyOSUwQSUwQW1zZyUyMCUzRCUyMGNoX2IucmVhZCUyOHRpbWVvdXQlM0Q1MDAlMjklMEFwcmludCUyOG1zZyUyOSUwQSUwQWNoX2EuYnVzT2ZmJTI4JTI5JTBBY2hfYi5idXNPZmYlMjglMjklMEElMEFjaF9hLmNsb3NlJTI4JTI5JTBBY2hfYi5jbG9zZSUyOCUyOQ=="][vc_column_text]

Running this silent_mode script results in the following error frame (CAN error message):

[/vc_column_text][vc_code_raket language="t" code="JTI4cHlwcm9qJTI5JTNFJTIwcHklMjBzaWxlbnRfbW9kZS5weSUwQUZyYW1lJTI4aWQlM0QwJTJDJTIwZGF0YSUzRGJ5dGVhcnJheSUyOGIlMjclMjclMjklMkMlMjBkbGMlM0QwJTJDJTIwZmxhZ3MlM0QlM0NNZXNzYWdlRmxhZy5FUlJPUl9GUkFNRSUzQSUyMDMyJTNFJTJDJTIwdGltZXN0YW1wJTNEMTUlMjklMEE="][vc_column_text]

The message (frame) is sent by the channel ch_a but during the message send, it is turned into an error message (error frame). This meant that no other channel received the message and therefore the acknowledgement bit was not added. This shows that even though the channel ch_b read the message, it did not add an acknowledgement bit, which proves that a silent channel will not interfere with any traffic that is sent on the bus.

The next test is to send a message with a silent channel and observe the CAN interface. This time we will not write a script but instead use the python interpreter. To launch the python interpreter and send a message, type the following into powershell: 

[/vc_column_text][vc_code_raket language="t" code="JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTI4cHlwcm9qJTI5JTIwUFMlMjBDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiUzRSUyMHB5JTBBUHl0aG9uJTIwMy45LjUlMjAlMjh0YWdzJTJGdjMuOS41JTNBMGE3ZGNiZCUyQyUyME1heSUyMCUyMDMlMjAyMDIxJTJDJTIwMTclM0EyNyUzQTUyJTI5JTIwJTVCTVNDJTIwdi4xOTI4JTIwNjQlMjBiaXQlMjAlMjhBTUQ2NCUyOSU1RCUyMG9uJTIwd2luMzIlMEFUeXBlJTIwJTIyaGVscCUyMiUyQyUyMCUyMmNvcHlyaWdodCUyMiUyQyUyMCUyMmNyZWRpdHMlMjIlMjBvciUyMCUyMmxpY2Vuc2UlMjIlMjBmb3IlMjBtb3JlJTIwaW5mb3JtYXRpb24uJTBBJTNFJTNFJTNFJTIwZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUyQyUyMEZyYW1lJTBBJTNFJTNFJTNFJTIwY2glMjAlM0QlMjBjYW5saWIub3BlbkNoYW5uZWwlMjhjaGFubmVsJTNEMSUyOSUwQSUzRSUzRSUzRSUyMGNoLnNldEJ1c091dHB1dENvbnRyb2wlMjhjYW5saWIuRHJpdmVyLlNJTEVOVCUyOSUwQSUzRSUzRSUzRSUyMGNoLmJ1c09uJTI4JTI5JTBBJTNFJTNFJTNFJTIwZnJhbWUlMjAlM0QlMjBGcmFtZSUyOGlkXyUzRDEyMyUyQyUyMGRhdGElM0QlNUI3MiUyQyUyMDY5JTJDJTIwNzYlMkMlMjA3NiUyQyUyMDc5JTJDJTIwMzMlNUQlMjklMEElM0UlM0UlM0UlMjBjaC53cml0ZSUyOGZyYW1lJTI5"][vc_column_text]

This will not result in any errors in the python interpreter, but if we look at the Kvaser CAN interface, the channel led will flash red indicating an error (see the picture below, which led that flashes depends on which channel encountered the error). When we are finished looking at the flashing light, go off the bus and close it with the following:

[/vc_column_text][vc_code_raket language="python" code="JTNFJTNFJTNFJTIwY2guYnVzT2ZmJTI4JTI5JTBBJTNFJTNFJTNFJTIwY2guY2xvc2UlMjglMjk="][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_single_image image="38145"][/vc_column][vc_column width="1/2"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

A Kvaser CAN interface connected to a computer (indicated by the green light for PWR) receiving an error on its second channel (indicated by the red light flashing on CAN 2).

To receive an error within the interpreter we need to send more messages at once. To do this we will surround the write() command with a for-loop (still using the Python interpreter within powershell):

[/vc_column_text][vc_code_raket language="t" code="JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTI4cHlwcm9qJTI5JTIwUFMlMjBDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiUzRSUyMHB5JTBBUHl0aG9uJTIwMy45LjUlMjAlMjh0YWdzJTJGdjMuOS41JTNBMGE3ZGNiZCUyQyUyME1heSUyMCUyMDMlMjAyMDIxJTJDJTIwMTclM0EyNyUzQTUyJTI5JTIwJTVCTVNDJTIwdi4xOTI4JTIwNjQlMjBiaXQlMjAlMjhBTUQ2NCUyOSU1RCUyMG9uJTIwd2luMzIlMEFUeXBlJTIwJTIyaGVscCUyMiUyQyUyMCUyMmNvcHlyaWdodCUyMiUyQyUyMCUyMmNyZWRpdHMlMjIlMjBvciUyMCUyMmxpY2Vuc2UlMjIlMjBmb3IlMjBtb3JlJTIwaW5mb3JtYXRpb24uJTBBJTNFJTNFJTNFJTIwZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUyQyUyMEZyYW1lJTBBJTNFJTNFJTNFJTIwY2glMjAlM0QlMjBjYW5saWIub3BlbkNoYW5uZWwlMjhjaGFubmVsJTNEMSUyOSUwQSUzRSUzRSUzRSUyMGNoLnNldEJ1c091dHB1dENvbnRyb2wlMjhjYW5saWIuRHJpdmVyLlNJTEVOVCUyOSUwQSUzRSUzRSUzRSUyMGNoLmJ1c09uJTI4JTI5JTBBJTNFJTNFJTNFJTIwZnJhbWUlMjAlM0QlMjBGcmFtZSUyOGlkXyUzRDEyMyUyQyUyMGRhdGElM0QlNUI3MiUyQyUyMDY5JTJDJTIwNzYlMkMlMjA3NiUyQyUyMDc5JTJDJTIwMzMlNUQlMjklMEElM0UlM0UlM0UlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSUyODIwMDAlMjklM0ElMEEuLi4lMjAlMjAlMjAlMjAlMjBjaC53cml0ZSUyOGZyYW1lJTI5JTBBVHJhY2ViYWNrJTIwJTI4bW9zdCUyMHJlY2VudCUyMGNhbGwlMjBsYXN0JTI5JTNBJTBBJTIwJTIwRmlsZSUyMCUyMiUzQ3N0ZGluJTNFJTIyJTJDJTIwbGluZSUyMDIlMkMlMjBpbiUyMCUzQ21vZHVsZSUzRSUwQSUyMCUyMEZpbGUlMjAlMjJDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiU1Qy52ZW52JTVDbGliJTVDc2l0ZS1wYWNrYWdlcyU1Q2NhbmxpYiU1Q2NhbmxpYiU1Q2NoYW5uZWwucHklMjIlMkMlMjBsaW5lJTIwNzE4JTJDJTIwaW4lMjB3cml0ZSUwQSUyMCUyMCUyMCUyMGRsbC5jYW5Xcml0ZSUyOHNlbGYuaGFuZGxlJTJDJTIwZnJhbWUuaWQlMkMlMjBieXRlcyUyOGZyYW1lLmRhdGElMjklMkMlMjBmcmFtZS5kbGMlMkMlMjBmcmFtZS5mbGFncyUyOSUwQSUyMCUyMEZpbGUlMjAlMjJDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiU1Qy52ZW52JTVDbGliJTVDc2l0ZS1wYWNrYWdlcyU1Q2NhbmxpYiU1Q2NhbmxpYiU1Q2RsbC5weSUyMiUyQyUyMGxpbmUlMjAxNzclMkMlMjBpbiUyMF9lcnJvcl9jaGVjayUwQSUyMCUyMCUyMCUyMHJhaXNlJTIwY2FuX2Vycm9yJTI4cmVzdWx0JTI5JTBBY2FubGliLmNhbmxpYi5leGNlcHRpb25zLkNhbkdlbmVyYWxFcnJvciUzQSUyMFRyYW5zbWl0JTIwYnVmZmVyJTIwb3ZlcmZsb3clMjAlMjgtMTMlMjk="][vc_column_text]

Once again, remember to go off the bus and close the channel when finished.

[/vc_column_text][vc_code_raket language="python" code="JTNFJTNFJTNFJTIwY2guYnVzT2ZmJTI4JTI5JTBBJTNFJTNFJTNFJTIwY2guY2xvc2UlMjglMjk="][vc_column_text]

For the next example we need to add a third channel to be able to send a message as well as reading it with a silent channel. Note that to be able to have a silent channel, there must be at least two other channels that can send and receive the message normally. In this guide we will add a Kvaser Leaf Pro HS v2, but any other CAN interface with at least one channel will do. To see that more than two channels are available, run the script check_ch once more, which for this example results in:

[/vc_column_text][vc_code_raket code="JTA5JTI4cHlwcm9qJTI5JTNFJTIwcHklMjBjaGVja19jaC5weSUwQSUwOUZvdW5kJTIwNSUyMGNoYW5uZWxzJTBBJTA5MC4lMjBLdmFzZXIlMjBVU0JjYW4lMjBQcm8lMjAyeEhTJTIwdjIlMjAlMjhjaGFubmVsJTIwMCUyOSUyMCUyODAwNzUyLTklM0ExMzQwNiUyRjAlMjklMEElMDkxLiUyMEt2YXNlciUyMFVTQmNhbiUyMFBybyUyMDJ4SFMlMjB2MiUyMCUyOGNoYW5uZWwlMjAxJTI5JTIwJTI4MDA3NTItOSUzQTEzNDA2JTJGMSUyOSUwQSUwOTIuJTIwS3Zhc2VyJTIwTGVhZiUyMFBybyUyMEhTJTIwdjIlMjAlMjhjaGFubmVsJTIwMCUyOSUyMCUyODAwODQzLTQlM0ExMDAxMiUyRjAlMjklMEElMDkzLiUyMEt2YXNlciUyMFZpcnR1YWwlMjBDQU4lMjBEcml2ZXIlMjAlMjhjaGFubmVsJTIwMCUyOSUyMCUyODAwMDAwLTAlM0EwJTJGMCUyOSUwQSUwOTQuJTIwS3Zhc2VyJTIwVmlydHVhbCUyMENBTiUyMERyaXZlciUyMCUyOGNoYW5uZWwlMjAxJTI5JTIwJTI4MDAwMDAtMCUzQTAlMkYxJTI5JTBB"][vc_column_text]

Compared to the previous time we ran check_ch, the virtual channels have dropped down from 2 and 3 to 3 and 4. The CAN channel 2 has been taken over by the new Kvaser Leaf Pro CAN interface that was added.

The next step is to send a message with two normal channels and listen with a third silent channel. Once again we will go back to the CAN message example and add code, this script will be called silent_listen:

[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwc2lsZW50X2xpc3Rlbi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J1c09uJTI4JTI5JTBBJTBBZnJhbWUlMjAlM0QlMjBGcmFtZSUyOGlkXyUzRDEyMyUyQyUyMGRhdGElM0QlNUI3MiUyQyUyMDY5JTJDJTIwNzYlMkMlMjA3NiUyQyUyMDc5JTJDJTIwMzMlNUQlMjklMEFjaF9hLndyaXRlJTI4ZnJhbWUlMjklMEElMEElMjMlMjBBZGQlMjBjaF9jJTIwdG8lMjByZWFkJTIwdGhlJTIwbWVzc2FnZSUyMGFzJTIwdGhlJTIwc2lsZW50JTIwY2hhbm5lbCUyMHRvJTIwcmVhZCUyMHRoZSUyMG1lc3NhZ2UuJTBBbXNnX2MlMjAlM0QlMjBjaF9jLnJlYWQlMjh0aW1lb3V0JTNENTAwJTI5JTBBbXNnX2IlMjAlM0QlMjBjaF9iLnJlYWQlMjh0aW1lb3V0JTNENTAwJTI5JTBBJTBBJTIzJTIwUHJpbnQlMjBib3RoJTIwbWVzc2FnZXMlMjB0byUyMGNvbXBhcmUlMjB0aGVtLiUwQXByaW50JTI4JTIybXNnJTIwYyUzQSVFMiU4MCU5RCUyOSUwQXByaW50JTI4bXNnX2MlMjklMEFwcmludCUyOCUyMm1zZyUyMGIlM0ElRTIlODAlOUQlMjklMEFwcmludCUyOG1zZ19iJTI5JTBBJTBBJTIzJTIwR28lMjBvZmYlMjBidXMlMjB3aXRoJTIwYWxsJTIwdGhyZWUlMjBjaGFubmVscy4lMEFjaF9hLmJ1c09mZiUyOCUyOSUwQWNoX2IuYnVzT2ZmJTI4JTI5JTBBY2hfYy5idXNPZmYlMjglMjklMEElMEElMjMlMjBMYXN0bHklMkMlMjBjbG9zZSUyMGFsbCUyMGNoYW5uZWxzLiUwQWNoX2EuY2xvc2UlMjglMjklMEFjaF9iLmNsb3NlJTI4JTI5JTBBY2hfYy5jbG9zZSUyOCUyOQ=="][vc_column_text]

Running the script in powershell will result in the following:

[/vc_column_text][vc_code_raket language="t" code="JTI4cHlwcm9qJTI5JTNFJTIwcHklMjBzaWxlbnRfbGlzdGVuLnB5JTBBbXNnJTIwYyUzQSUwQUZyYW1lJTI4aWQlM0QxMjMlMkMlMjBkYXRhJTNEYnl0ZWFycmF5JTI4YiUyN0hFTExPJTIxJTI3JTI5JTJDJTIwZGxjJTNENiUyQyUyMGZsYWdzJTNEJTNDTWVzc2FnZUZsYWcuU1REJTNBJTIwMiUzRSUyQyUyMHRpbWVzdGFtcCUzRDIlMjklMEFtc2clMjBiJTNBJTBBRnJhbWUlMjhpZCUzRDEyMyUyQyUyMGRhdGElM0RieXRlYXJyYXklMjhiJTI3SEVMTE8lMjElMjclMjklMkMlMjBkbGMlM0Q2JTJDJTIwZmxhZ3MlM0QlM0NNZXNzYWdlRmxhZy5TVEQlM0ElMjAyJTNFJTJDJTIwdGltZXN0YW1wJTNENSUyOQ=="][vc_column_text]

We can now see that the silent channel ch_c can read the message, and with ch_b also reading the message it no longer becomes an error message. In this example the silent channel is not necessary but it is still an example on how we can use it.

[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Setting bus parameters"][vc_column_text]

There are multiple ways to set bus parameters that can be set on the bus. In this guide we will only focus on setting, checking and changing the CAN Bitrate of the channels using predefined bus parameters, for a list of all predefined parameters go to pycanlib.readthedocs canlib.canlib.Bitrate. To set the bitrate use setBusParams() and canlib.Bitrate.BITRATE_xK as the input, where x is the bitrate wanted. Before setting the bitrate we will use getBusParams() before to get the standard parameters and after to see that the parameters have changed.

Note that both the transmitting and receiving channel must use the same bitrate. Otherwise we will receive an error message and the red light will start to flash. In the following example script we will use the send message example, add the setBusParams function and call it change_bitrate.

[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwY2hhbmdlX2JpdHJhdGUlMEFmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwY2FubGliJTJDJTIwRnJhbWUlMEElMEFjaF9hJTIwJTNEJTIwY2FubGliLm9wZW5DaGFubmVsJTI4Y2hhbm5lbC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JTI4JTI5JTI5JTBBJTBBY2hfYS5idXNPbiUyOCUyOSUwQWNoX2IuYnVzT24lMjglMjklMEElMEFmcmFtZSUyMCUzRCUyMEZyYW1lJTI4aWRfJTNEMTIzJTJDJTIwZGF0YSUzRCU1QjcyJTJDJTIwNjklMkMlMjA3NiUyQyUyMDc2JTJDJTIwNzklMkMlMjAzMyU1RCUyOSUwQWNoX2Eud3JpdGUlMjhmcmFtZSUyOSUwQSUwQW1zZyUyMCUzRCUyMGNoX2IucmVhZCUyOHRpbWVvdXQlM0Q1MDAlMjklMEFwcmludCUyOG1zZyUyOSUwQSUwQWNoX2EuYnVzT2ZmJTI4JTI5JTBBY2hfYi5idXNPZmYlMjglMjklMEElMEFjaF9hLmNsb3NlJTI4JTI5JTBBY2hfYi5jbG9zZSUyOCUyOQ=="][vc_column_text]

Launching this script within the virtual environment will result in the following:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTA5JTI4cHlwcm9qJTI5JTNFJTIwcHklMjBjaGFuZ2VfYml0cmF0ZS5weSUwQSUwOSUyODUwMDAwMCUyQyUyMDQlMkMlMjAzJTJDJTIwMSUyQyUyMDElMkMlMjAxJTI5JTBBJTA5JTI4NTAwMDAwJTJDJTIwNCUyQyUyMDMlMkMlMjAxJTJDJTIwMSUyQyUyMDElMjklMEElMDklMjgxMDAwMDAlMkMlMjAxMSUyQyUyMDQlMkMlMjAxJTJDJTIwMyUyQyUyMDElMjklMEElMDklMjgxMDAwMDAlMkMlMjAxMSUyQyUyMDQlMkMlMjAxJTJDJTIwMyUyQyUyMDElMjklMEElMDlGcmFtZSUyOGlkJTNEMTIzJTJDJTIwZGF0YSUzRGJ5dGVhcnJheSUyOGIlMjdIRUxMTyUyMSUyNyUyOSUyQyUyMGRsYyUzRDYlMkMlMjBmbGFncyUzRCUzQ01lc3NhZ2VGbGFnLlNURCUzQSUyMDIlM0UlMkMlMjB0aW1lc3RhbXAlM0QzJTI5"][vc_column_text]

We can now clearly see that both channels have the same preset parameters before changing and then after the change they still have the same parameters. Normally the bitrate is not changed, so as a shortcut the bitrate can be set whilst calling openChannel as seen here:

[/vc_column_text][vc_code_raket language="t" code="Y2hfYSUyMCUzRCUyMGNhbmxpYi5vcGVuQ2hhbm5lbCUyOGNoYW5uZWwlM0QyJTJDJTIwYml0cmF0ZSUzRGNhbmxpYi5CaXRyYXRlLkJJVFJBVEVfMTAwSyUyOSUwQQ=="][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="LEDs"][vc_column_text]

All Kvaser interfaces have LEDs that are used to indicate when the interface is working or having errors. We can test these LEDs with flashLeds and different actions and LEDs. The actions include turning all LeDs on and off or turning all LEDs on or off. For a full list of available actions go to pycanlib.readthedocs canlib.canlic.LEDAction. Note that not all actions will work on all Kvaser interfaces since the interfaces have different numbers of LEDs and channels. We will use a Kvaser USBcan pro 2xHS v2 to test flashLeds with a python interpreter running the following commands (make sure to look at the CAN interface when executing the flashLed commands to see the LEDs):

[/vc_column_text][vc_code_raket code="JTA5JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTA5JTI4cHlwcm9qJTI5JTNFJTIwcHklMEElMDlQeXRob24lMjAzLjkuNSUyMCUyOHRhZ3MlMkZ2My45LjUlM0EwYTdkY2JkJTJDJTIwTWF5JTIwJTIwMyUyMDIwMjElMkMlMjAxNyUzQTI3JTNBNTIlMjklMjAlNUJNU0MlMjB2LjE5MjglMjA2NCUyMGJpdCUyMCUyOEFNRDY0JTI5JTVEJTIwb24lMjB3aW4zMiUwQSUwOVR5cGUlMjAlMjJoZWxwJTIyJTJDJTIwJTIyY29weXJpZ2h0JTIyJTJDJTIwJTIyY3JlZGl0cyUyMiUyMG9yJTIwJTIybGljZW5zZSUyMiUyMGZvciUyMG1vcmUlMjBpbmZvcm1hdGlvbi4lMEElMDklM0UlM0UlM0UlMjBmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwY2FubGliJTBBJTA5JTNFJTNFJTNFJTIwY2glMjAlM0QlMjBjYW5saWIub3BlbkNoYW5uZWwlMjhjaGFubmVsJTNEMCUyOSUwQSUwOSUzRSUzRSUzRSUyMGNoLmZsYXNobGVkcyUyOGNhbmxpYi5MRURBY3Rpb24uQUxMX0xFRFNfT04lMkMlMjAxMDAwMCUyOSUwQSUwOSUzRSUzRSUzRSUyMGNoLmZsYXNobGVkcyUyOGNhbmxpYi5MRURBY3Rpb24uQUxMX0xFRFNfT0ZGJTJDJTIwMTAwMDAlMjklMEE="][vc_column_text]

In the previous code we executed the actions 0 and 1. The action 0 turns on all LEDs while action 1 turns off all LEDs. How long the LEDs “flash” depends on the second integer. In this example we have 10000 which represents 10000 ms which is 10 seconds. This gives us enough time to clearly see that the LEDs function correctly. 

Next we will turn on one LED at a time. Doing this we will show that each “hole” for the LEDs has two LEDs with different colours. In the picture below we can see the different LEDs (the ones in white) as they look on the circuit board inside the cover.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="2/3"][vc_single_image image="38146"][/vc_column][vc_column width="1/3"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

The inside of a Kvaser CAN interface where we can see the six LEDs on this particular interface that has two channels (two LED pair’s per channel and two PWR LEDs). The designated number for each LED is shown in the picture.

In this example we will turn on LED 0 and 3 which are the two LEDs for CAN 1, these two LEDs are the LED 2 and 3, with the colours red and yellow respectively. Use the following code in the python interpreter:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2guZmxhc2hMZWRzJTI4Y2FubGliLkxFREFjdGlvbi5MRURfMl9PTiUyQyUyMDEwMDAwJTI5JTBBJTA5JTNFJTNFJTNFJTIwY2guZmxhc2hMZWRzJTI4Y2FubGliLkxFREFjdGlvbi5MRURfM19PTiUyQyUyMDEwMDAwJTI5JTBB"][vc_column_text]

If we instead were to use the LEDs for the PWR the colours would be green and yellow (LED_0_ON and LED_1_ON respectively).

[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Finding device"][vc_column_text]

Within canlib there is a class called “Device” that can be used to find and keep track of a physical device. The device class represents a physical device regardless of whether it is currently connected or not, and on which channel it is connected. If the device is connected, use Device.find to find a device and get a device object. To search for the device both EAN and the serial number can be used. Open the virtual environment, start the python interpreter and run the following:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTA5JTI4cHlwcm9qJTI5JTNFJTIwcHklMEElMDklM0UlM0UlM0UlMjBmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwRGV2aWNlJTJDJTIwRUFOJTBBJTA5JTNFJTNFJTNFJTIwRGV2aWNlLmZpbmQlMjhlYW4lM0RFQU4lMjglMjc3My0zMDEzMC0wMDc1Mi05JTI3JTI5JTI5JTBBJTA5RGV2aWNlJTI4ZWFuJTNEJTNDRUFOJTNBJTIwNzMtMzAxMzAtMDA3NTItOSUzRSUyQyUyMHNlcmlhbCUzRDEzNDA2JTI5JTBBJTA5JTNFJTNFJTNFJTIwRGV2aWNlLmZpbmQlMjhzZXJpYWwlM0QxMzQwNiUyOSUwQSUwOURldmljZSUyOGVhbiUzRCUzQ0VBTiUzQSUyMDczLTMwMTMwLTAwNzUyLTklM0UlMkMlMjBzZXJpYWwlM0QxMzQwNiUyOQ=="][vc_column_text]

Device.find will search for, and return the first device that matches the input arguments. In the previous example we searched for the first device with an EAN of 73-30130-00752-9 and the serial number 13406.

If the wanted device is not currently connected, a device object can be created with their EAN and serial number (the minimal information needed to uniquely identify a specific device). With the EAN number only the last six numbers are necessary, since the first seven are default and the same on all interfaces. To create a device run the following code in the python interpreter:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwZGV2JTIwJTNEJTIwRGV2aWNlJTI4ZWFuJTNERUFOJTI4JTI3Njc4OTAtMSUyNyUyOSUyQyUyMHNlcmlhbCUzRDQyJTI5"][vc_column_text]

After the new device has been created and connected to the PC via a USB we can get its (or any other devices) information with probe_info:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwcHJpbnQlMjhkZXYucHJvYmVfaW5mbyUyOCUyOSUyOSUwQSUwOUNBTmxpYiUyMENoYW5uZWwlM0ElMjAyJTBBJTA5Q2FyZCUyME51bWJlciUyMCUyMCUyMCUzQSUyMDAlMEElMDlEZXZpY2UlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlM0ElMjBLdmFzZXIlMjBVU0JjYW4lMjBQcm8lMjAyeEhTJTIwdjIlMjAlMjhjaGFubmVsJTIwMCUyOSUwQSUwOURyaXZlciUyME5hbWUlMjAlMjAlMjAlM0ElMjBrY2FueTBhJTBBJTA5RUFOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwNzMtMzAxMzAtMDA3NTItOSUwQSUwOUZpcm13YXJlJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwMy4yNS4wLjc1MyUwQSUwOVNlcmlhbCUyME51bWJlciUyMCUzQSUyMDEzNDA2"][vc_column_text]

Device.find can also be used to open a channel on a specific connected interface irregardless of on which CANlib channel number it was assigned. To do this call on Device.find and then open_channel. This will automatically open the first local channel on the interface:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwZGV2JTIwJTNEJTIwRGV2aWNlLmZpbmQlMjhlYW4lM0RFQU4lMjglRTIlODAlOTgwMDc1Mi05JUUyJTgwJTk5JTI5JTI5JTBBJTA5JTNFJTNFJTNFJTIwY2glMjAlM0QlMjBkZXYub3Blbl9jaGFubmVsJTI4JTI5"][vc_column_text]

Ch can now be used the same way as any other channel opened with canlib.openChannel(channel=x).

When opening the channel we can simultaneously specify which channel on the interface to use. This is done with chan_no_on_card, which specifies the local channel on the interface. Make sure that the chan_no_on_card integer is less than the number of CANs on the interface (if there are two channels the integer should be 0 or 1).

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2glMjAlM0QlMjBkZXYub3Blbl9jaGFubmVsJTI4Y2hhbl9ub19vbl9jYXJkJTNEMSUyOQ=="][vc_column_text]

And the last step is to set the bitrate at the same time as opening the channel.

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2glMjAlM0QlMjBkZXYub3Blbl9jaGFubmVsJTI4Y2hhbl9ub19vbl9jYXJkJTNEMSUyQyUyMGJpdHJhdGUlM0RjYW5saWIuQml0cmF0ZS5CSVRSQVRFXzEwMEslMjk="][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Channel and handle data"][vc_column_text]

Probe_info can be used on a device object to get information about a connected interface. Probe_info uses the ChannelData function which we can use directly, such as we did in the check_ch script. Along with ChannelData we can also use two more ways of getting information about a device or interface.

The first way we can use to get the channel data is to use canlib.ChannelData(x) where x is the channel we want data about. To run this command we need to start the virtual environment and the python interpreter before starting the ChannelData. In this example we will get the data from channel 0:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTA5JTI4cHlwcm9qJTI5JTNFJTIwcHklMEElMDlQeXRob24lMjAzLjkuNSUyMCUyOHRhZ3MlMkZ2My45LjUlM0EwYTdkY2JkJTJDJTIwTWF5JTIwJTIwMyUyMDIwMjElMkMlMjAxNyUzQTI3JTNBNTIlMjklMjAlNUJNU0MlMjB2LjE5MjglMjA2NCUyMGJpdCUyMCUyOEFNRDY0JTI5JTVEJTIwb24lMjB3aW4zMiUwQSUwOVR5cGUlMjAlMjJoZWxwJTIyJTJDJTIwJTIyY29weXJpZ2h0JTIyJTJDJTIwJTIyY3JlZGl0cyUyMiUyMG9yJTIwJTIybGljZW5zZSUyMiUyMGZvciUyMG1vcmUlMjBpbmZvcm1hdGlvbi4lMEElMDklM0UlM0UlM0UlMjBmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwY2FubGliJTBBJTA5JTNFJTNFJTNFJTIwZGF0JTIwJTNEJTIwY2FubGliLkNoYW5uZWxEYXRhJTI4MCUyOSUwQQ=="][vc_column_text]

After the data object has been created and named dat, we can use that to get any information we want from channeldata. For a full list of available data go to pycanlib readthedocs canlib.canlib.ChannelData.

Using canlib.ChannelData however requires that we know which channel the interface is connected to. This can become problematic since when removing and inserting interfaces they will most likely change channel numbers. So if we do not know the channel we can not use ChannelData. Instead there are two other ways to get the data object. One way is to find or create a device named dev and using dev.channel_dev(), and the other is opening a channel and using ch.channel_data(). Both ways use the Python interpreter:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwZGV2JTIwJTNEJTIwRGV2aWNlLmZpbmQlMjhlYW4lM0RFQU4lMjglRTIlODAlOTgwMDc1Mi05JUUyJTgwJTk5JTI5JTI5JTBBJTA5JTNFJTNFJTNFJTIwZGF0JTIwJTNEJTIwZGV2LmNoYW5uZWxfZGF0YSUyOCUyOSUwQSUwQSUwOSUzRSUzRSUzRSUyMGNoJTIwJTNEJTIwY2FubGliLm9wZW5DaGFubmVsJTI4Y2hhbm5lbCUzRDAlMjklMjAlMEElMDklM0UlM0UlM0UlMjBkYXQlMjAlM0QlMjBjaC5jaGFubmVsX2RhdGElMjglMjk="][vc_column_text]

Out of these two options dev.channel is always right and easiest to use. Getting dat through openChannel has the same result as the script check_ch.py script used earlier.

[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Enumerate"][vc_column_text]

Once we have imported canlib.canlib, which enumerates the connected Kvaser CAN devices, we can call getNumberOfChannels to get the number of enumerated channels in our system. If we are connecting and disconnecting interfaces simultaneously while running programs, a problem can arise. Inside of the program we use the channels when referring to CAN channels and interfaces. But if we add or remove  any of the interfaces whilst the program is running, the changes won’t affect the program. Or alternatively the wrong interface will be used when referencing a certain channel. Note that the following is only necessary if devices are continuously being connected and disconnected while the code is running.

To fix this problem we will manually enumerate the available CAN channels. The function is canlib.enumerate_hardware and is used to create a completely new set of CANlib channel numbers based on all currently connected devices. The currently opened channel handles are still valid and usable. However, with using this function we need to stop referring to devices based on CANlib channel number, and instead use the channel class. Since the number will change every time enumerate_hardware is called. Instead to retrieve information about a specific channel. Use Channel.channel_data.

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649377393731{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Adding a device"][vc_column_text]

If we connect a device while a program is being run, the program will simply not recognise that a new device was connected. We can see this by using canlib.getNumberOfChannels inside of the virtual environment and the python interpreter (in this example we have a USBcan connected and will connect a leaflight):

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTA5JTI4cHlwcm9qJTI5JTNFJTIwcHklMEElMDlQeXRob24lMjAzLjkuNSUyMCUyOHRhZ3MlMkZ2My45LjUlM0EwYTdkY2JkJTJDJTIwTWF5JTIwJTIwMyUyMDIwMjElMkMlMjAxNyUzQTI3JTNBNTIlMjklMjAlNUJNU0MlMjB2LjE5MjglMjA2NCUyMGJpdCUyMCUyOEFNRDY0JTI5JTVEJTIwb24lMjB3aW4zMiUwQSUwOVR5cGUlMjAlMjJoZWxwJTIyJTJDJTIwJTIyY29weXJpZ2h0JTIyJTJDJTIwJTIyY3JlZGl0cyUyMiUyMG9yJTIwJTIybGljZW5zZSUyMiUyMGZvciUyMG1vcmUlMjBpbmZvcm1hdGlvbi4lMEElMDklM0UlM0UlM0UlMjBmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwY2FubGliJTBBJTA5JTNFJTNFJTNFJTIwY2FubGliLmdldE51bWJlck9mQ2hhbm5lbHMlMjglMjklMEElMDk0"][vc_column_text]

Next connect the leaflight and run the getNumberOfChannels again:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2FubGliLmdldE51bWJlck9mQ2hhbm5lbHMlMjglMjklMEElMDk0"][vc_column_text]

If we now manually run enumerate_hardware and then run getNumberOfChannels we get:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2FubGliLmVudW1lcmF0ZV9oYXJkd2FyZSUwQSUwOTUlMEElMDklM0UlM0UlM0UlMjBjYW5saWIuZ2V0TnVtYmVyT2ZDaGFubmVscyUyOCUyOSUwQSUwOTU="][vc_column_text]

We can now see that without restarting the program, the new channel was recognised and can now be used.

[/vc_column_text][/vc_column][/vc_row][vc_row css=".vc_custom_1649377358498{margin-top: 25px !important;}"][vc_column][vc_header_raket header_type="h3" header="Removing a device"][vc_column_text]

If we remove a device we will encounter some issues. Firstly, as when connecting a device, the program will not recognise that a device was removed with getNumberOfChannels until the connected devices have been re-enumerated (enumerate has been run):

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2FubGliLmdldE51bWJlck9mQ2hhbm5lbHMlMjglMjklMEElMDk1JTBBJTA5JTNFJTNFJTNFJTIwY2FubGliLmVudW1lcmF0ZV9oYXJkd2FyZSUwQSUwOTQlMEElMDklM0UlM0UlM0UlMjBjYW5saWIuZ2V0TnVtYmVyT2ZDaGFubmVscyUyOCUyOSUwQSUwOTQ="][vc_column_text]

If a channel was opened to the device before the device was removed, the program will still attempt to interact with the device using the commands run by the program. Running most of these commands will result in an error, however there are a couple of commands that will still work. To show this we will now attempt to write and read with an interface we remove after opening the channels. Before running both the read and write command the setup code needs to be run in the Python interpreter:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUyQyUyMEZyYW1lJTBBJTA5JTNFJTNFJTNFJTIwY2hfYSUyMCUzRCUyMGNhbmxpYi5vcGVuQ2hhbm5lbCUyODAlMjklMEElMDklM0UlM0UlM0UlMjBjaF9hLmJ1c09uJTI4JTI5JTBBJTA5JTNFJTNFJTNFJTIwY2hfYiUyMCUzRCUyMGNhbmxpYi5vcGVuQ2hhbm5lbCUyODElMjklMEElMDklM0UlM0UlM0UlMjBjaF9iLmJ1c09uJTI4JTI5JTBBJTA5JTNFJTNFJTNFJTIwZnJhbWUlMjAlM0QlMjBGcmFtZSUyOGlkXyUzRDEyMyUyQyUyMGRhdGElM0QlNUI3MiUyQyUyMDY5JTJDJTIwNzYlMkMlMjA3NiUyQyUyMDc5JTJDJTIwMzMlNUQlMjk="][vc_column_text]

If we now disconnect the CAN interface and attempt to write a frame with one of the removed channels, we will get a hardware error exception:

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2hfYS53cml0ZSUyOGZyYW1lJTI5JTBBJTA5VHJhY2ViYWNrJTIwJTI4bW9zdCUyMHJlY2VudCUyMGNhbGwlMjBsYXN0JTI5JTNBJTBBJTA5JTIwJTIwRmlsZSUyMCUyMiUzQ3N0ZGluJTNFJTIyJTJDJTIwbGluZSUyMDElMkMlMjBpbiUyMCUzQ21vZHVsZSUzRSUwQSUwOSUyMCUyMEZpbGUlMjAlMjJDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiU1Qy52ZW52JTVDbGliJTVDc2l0ZS1wYWNrYWdlcyU1Q2NhbmxpYiU1Q2NhbmxpYiU1Q2NoYW5uZWwucHklMjIlMkMlMjBsaW5lJTIwNzE4JTJDJTIwaW4lMjB3cml0ZSUwQSUwOSUyMCUyMCUyMCUyMGRsbC5jYW5Xcml0ZSUyOHNlbGYuaGFuZGxlJTJDJTIwZnJhbWUuaWQlMkMlMjBieXRlcyUyOGZyYW1lLmRhdGElMjklMkMlMjBmcmFtZS5kbGMlMkMlMjBmcmFtZS5mbGFncyUyOSUwQSUwOSUyMCUyMEZpbGUlMjAlMjJDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiU1Qy52ZW52JTVDbGliJTVDc2l0ZS1wYWNrYWdlcyU1Q2NhbmxpYiU1Q2NhbmxpYiU1Q2RsbC5weSUyMiUyQyUyMGxpbmUlMjAxNzclMkMlMjBpbiUyMF9lcnJvcl9jaGVjayUwQSUwOSUyMCUyMCUyMCUyMHJhaXNlJTIwY2FuX2Vycm9yJTI4cmVzdWx0JTI5JTBBJTA5Y2FubGliLmNhbmxpYi5leGNlcHRpb25zLkNhbkdlbmVyYWxFcnJvciUzQSUyMEElMjBoYXJkd2FyZSUyMGVycm9yJTIwd2FzJTIwZGV0ZWN0ZWQlMjAlMjgtMTUlMjk="][vc_column_text]

To attempt to read a message with a removed channel we need to run the setup code once more before removing the interface and running the read code.

[/vc_column_text][vc_code_raket language="t" code="JTA5JTNFJTNFJTNFJTIwY2hfYS5yZWFkJTI4JTI5JTBBJTA5VHJhY2ViYWNrJTIwJTI4bW9zdCUyMHJlY2VudCUyMGNhbGwlMjBsYXN0JTI5JTNBJTBBJTA5JTIwJTIwRmlsZSUyMCUyMiUzQ3N0ZGluJTNFJTIyJTJDJTIwbGluZSUyMDElMkMlMjBpbiUyMCUzQ21vZHVsZSUzRSUwQSUwOSUyMCUyMEZpbGUlMjAlMjJDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiU1Qy52ZW52JTVDbGliJTVDc2l0ZS1wYWNrYWdlcyU1Q2NhbmxpYiU1Q2NhbmxpYiU1Q2NoYW5uZWwucHklMjIlMkMlMjBsaW5lJTIwNzE4JTJDJTIwaW4lMjB3cml0ZSUwQSUwOSUyMCUyMCUyMCUyMGRsbC5jYW5Xcml0ZSUyOHNlbGYuaGFuZGxlJTJDJTIwZnJhbWUuaWQlMkMlMjBieXRlcyUyOGZyYW1lLmRhdGElMjklMkMlMjBmcmFtZS5kbGMlMkMlMjBmcmFtZS5mbGFncyUyOSUwQSUwOSUyMCUyMEZpbGUlMjAlMjJDJTNBJTVDVXNlcnMlNUNleHRhYyU1Q1B5cHJvaiU1Qy52ZW52JTVDbGliJTVDc2l0ZS1wYWNrYWdlcyU1Q2NhbmxpYiU1Q2NhbmxpYiU1Q2RsbC5weSUyMiUyQyUyMGxpbmUlMjAxNzclMkMlMjBpbiUyMF9lcnJvcl9jaGVjayUwQSUwOSUyMCUyMCUyMCUyMHJhaXNlJTIwY2FuX2Vycm9yJTI4cmVzdWx0JTI5JTBBJTA5Y2FubGliLmNhbmxpYi5leGNlcHRpb25zLkNhbkdlbmVyYWxFcnJvciUzQSUyMEElMjBoYXJkd2FyZSUyMGVycm9yJTIwd2FzJTIwZGV0ZWN0ZWQlMjAlMjgtMTUlMjk="][vc_column_text]

När man stoppar i ny enhet syns den inte om man redan startatt programmet

Istället för att starta om, använd enumerate

Visa att Canlib channel number “hoppar” men ch fungerar fortfarande.

[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Custom channel name"][vc_column_text]

When we are using several interfaces with several channels it may become difficult to remember which channel is which. To help with this problem we can rename channels and give them a custom name. To give the channels the custom name we need to use the Kvaser Device Guide. Inside of the Kvaser Device Guide right-click the channel we want to apply the custom name to, and click Edit Channel Name. A window will pop up where the channel name can be imputed, to apply the name click the “ok” button. To remove the name, simply open the change channel name window again and remove the inserted name. Note that the change will affect all programs that use the channel name to identify a device. The device will also reboot to set the name.

The next step is to get the custom name and use it via Python. To get the name use canlib.getChannelData().custom_name. We will now create a script called get_cus_name.py to get the custom name from all connected devices. Within the script write the following code:

[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwZ2V0X2N1c19uYW1lLnB5JTBBZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUwQSUwQW51bV9jaGFubmVscyUyMCUzRCUyMGNhbmxpYi5nZXROdW1iZXJPZkNoYW5uZWxzJTI4JTI5JTBBZm9yJTIwY2glMjBpbiUyMHJhbmdlJTI4bnVtX2NoYW5uZWxzJTI5JTNBJTBBJTIwJTIwJTIwJTIwY2hkJTIwJTNEJTIwY2FubGliLkNoYW5uZWxEYXRhJTI4Y2glMjklMEElMjAlMjAlMjAlMjBwcmludCUyOGYlMjIlN0JjaCU3RC4lMjAlN0JjaGQuY2hhbm5lbF9uYW1lJTdEJTJDJTIwQ3VzdG9tJTIwbmFtZSUzQSUyMCU3QmNoZC5jdXN0b21fbmFtZSU3RCUyMiUyOQ=="][vc_column_text]

Which will result in the following if a Kvaser CANusb is installed with channel 0 having the custom name “Green” and channel 1 the custom name “Red”:

[/vc_column_text][vc_code_raket language="t" code="MC4lMjBLdmFzZXIlMjBVU0JjYW4lMjBQcm8lMjAyeEhTJTIwdjIlMjAlMjhjaGFubmVsJTIwMCUyOSUyQyUyMEN1c3RvbSUyMG5hbWUlM0ElMjBHcmVlbiUwQTEuJTIwS3Zhc2VyJTIwVVNCY2FuJTIwUHJvJTIwMnhIUyUyMHYyJTIwJTI4Y2hhbm5lbCUyMDElMjklMkMlMjBDdXN0b20lMjBuYW1lJTNBJTIwUmVkJTBBMi4lMjBLdmFzZXIlMjBWaXJ0dWFsJTIwQ0FOJTIwRHJpdmVyJTIwJTI4Y2hhbm5lbCUyMDAlMjklMkMlMjBDdXN0b20lMjBuYW1lJTNBJTBBMy4lMjBLdmFzZXIlMjBWaXJ0dWFsJTIwQ0FOJTIwRHJpdmVyJTIwJTI4Y2hhbm5lbCUyMDElMjklMkMlMjBDdXN0b20lMjBuYW1lJTNB"][vc_column_text]

We can also use the custom name to open a specific channel. To do this write the following script called open_channel_by_name, which will include the function of the same name and a test to make sure it works properly. Within this test we have a kvaser USBcan with the custom name USBone and a leaflight with the custom name My leaf. Within the script write the following code:

[/vc_column_text][vc_code_raket language="python" code="JTIzb3Blbl9fY2hhbm5lbF9ieV9uYW1lJTBBZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUyQyUyMEZyYW1lJTBBJTB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TIwd2UlMjB0cnklMjB0byUwQSUyMyUyMG9wZW4lMjBhJTIwY2hhbm5lbCUyMHdpdGglMjBhJTIwY3VzdG9tJTIwbmFtZSUyMHRoYXQlMjBkb2VzJTIwbm90JTIwZXhpc3QuJTBBY2hfYSUyMCUzRCUyMG9wZW5fY2hhbm5lbF9ieV9uYW1lJTI4JTIyVVNCb2UlMjIlMjk="][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Troubleshooting, basic errors"][vc_column_text]

While working with Python canlib and CAN interfaces, there are multiple errors and problems we can be faced with. We will now go through a couple of common error messages and problems:

[/vc_column_text][vc_column_text]
  • Blinking red light: A fast blinking red CAN light indicates that several errorframe has been received, which means that a problem could have occurred while the message was being transmitted. Three possible problems may be that:
    1. Only one channel connected to the CAN bus (connected to the T-cannector).
    2. Only one channel is bus on (the channel has gone busOn()).
    3. The receiving or transmitting bus was in silent mode. 

    To fix this, firstly go offbus with the channel that received the error to stop the blinking red light. Then make sure there are at least two channels connected to the T-cannector and on bus in normal mode, one to send the message and one to receive it.

  • No messages available (-2): An error that occurs when we call on read() without a message being sent or being sent incorrectly, for example having the wrong bitrate. This may have been caused by write() not being called or the transmitting channel being on silent mode, which would cause the message to not be sent. To fix this problem make sure that write() was called correctly with a frame and that the transmitting channel is on normal mode and using the same bitrate as the receiving channel.
  • Transmit buffer overflow (-13): When we try to send a lot of messages that all fail, they will be “queued” in the transmit buffer. This will cause all later messages to also fail despite being done correctly, if the channel is on bus the LED will start blinking red. This can be caused by sending a lot of messages using a silent device or sending messages with a device that is not onbus. If the channel was onbus but silent, the red light will start blinking. To fix this problem start with going off- and onbus to clear the transmit buffer (the device can also be disconnected and reconnected to the computer). If this doesn’t fix the problem, make sure all busses are onbus. Either using .busOn() or by checking if the interface is connected to the T-Cannector.
  • A hardware error was detected (-15): If we try to interact with a device that is not connected we will receive this error. Most likely the device was not connected with the USB, removed after starting the program or a line of code somewhere called on the wrong device. To fix this, dubble check that all devices are connected with the USB and if this does not work dubble check all code used to identify a device.
  • Timeout occurred (-7): Timeout is an error raised when  we as the user give a timeout limit for how long the program will wait for something to happen. If it takes too long the error will be raised and we will know something prior went wrong. To fix it we need to go through the used code to find the problem.  The problem could for example be the writing channel was not onbus or in silent mode.
[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Where do I find information"][vc_column_text]

When looking for information there are multiple ways to obtain the information needed. The first and best way to get direct information about canlib and commands used with canlib is pycanlib.readthedocs.io. If readthedocs does not work, then on Kvasers website Kvaser.com there are multiple blogs aimed at explaining canlib. To access the blogs go to Kvaser.com blogs and search for the topic of interest. On the Kvaser website we can also find more information under the support heading and in the canlib webhelp. For example we can find basic resources to get started with Kvaser hardware, documentation such as use guides, developer tools and lastly calculators for calculating bitrate available or easy use. If you do not find what you are looking for anywhere in the above then support is always available, just email your issues, problems and questions to [email protected].

For example, in the previous script we want to read a message. But we do not want to move on to the next line until the message has been properly received and read. Furthermore we also want the program to stop and return an error message if the message could not be read. To find the best way to accomplish this we need to look up the documentation at pycanlib.readthedocs.

To find the right documentation we first expand the “Using canlib” tab, since we are using canlib. Next step is how we are using it and what for. Currently we want to send a message and luckily there is a tab called “Send and Receive”, so we can expand it. Next we see that Reading Messages is also a heading so we click on it to go directly to that heading. While reading under the “read“ heading we eventually come to a list of functions. One of these states the following: “If you want to wait until a message arrives (or a timeout occurs) and then read it, call read with a timeout”. This sounds like what we are looking for. To read more about the function we can go directly to the “read” function by clicking the link labeled “read”. We can now see that “read” has a parameter called “timeout” which is an integer. This integer dictates how many milliseconds the program will wait for the message to be delivered before returning a timeout error. We have now found what we were looking for and can enter this into our code as channel.read(timeout = 500) for the program to wait 500 milliseconds.

[/vc_column_text][/vc_column][/vc_row] [post_title] => KVASER CANlib and Python Part 2: Tests and Samples [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvaser-canlib-and-python-part-2-tests-and-samples [to_ping] => [pinged] => [post_modified] => 2023-08-21 22:35:55 [post_modified_gmt] => 2023-08-21 22:35:55 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=38144 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [2] => WP_Post Object ( [ID] => 36500 [post_author] => 40108 [post_date] => 2021-12-14 20:47:27 [post_date_gmt] => 2021-12-14 20:47:27 [post_content] => [vc_row][vc_column][vc_column_text]This is the first of two articles introducing Kvaser CANlib SDK and the Python package canlib. In this part of the guide we will go through the setup needed to begin understanding and working with the Python CANlib Wrapper. This includes downloading the required software, connecting the necessary hardware and the basic coding used while sending messages with Kvaser interfaces.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Writer: Anton Carlsson, Software Developer Cowriter: L-G Fredriksson, Field Application Engineer Version: 2021-08-09A[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]With this step-by-step tutorial, we will guide you through sending and receiving messages using Python, Kvaser CAN interfaces and the Python package lib. Kvaser CANlib allows you to control most aspects of any Kvaser CAN interface. The canlib package is a Python wrapper that allows the user to use Kvaser CANlib with Python. This guide will be limited to Windows and Linux where Kvaser CANlib is supported. A command-line application will often be used, and in this guide we will use Windows PowerShell, which is automatically installed on Windows 7 SP1 and Windows Server 2008 R2 SP1 or any later versions. If you want to use another application instead of PowerShell, you are welcome to do so.   [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="Who should read this?"][vc_column_text]This guide has been written for those who want to set up and use a Kvaser CAN interface with CANlib and the Python CANlib package/wrapper.  To use this guide, the user needs to be somewhat familiar with (or able to look up) the following:
  • Some knowledge about the operating system that will be used. More knowledge is needed when using Linux rather than Windows.
  • How to open and use the basic commands in a command-line application, such as the Command Prompt or Windows PowerShell.
  • Knowledge of how programming works is not necessary but will help. Additionally, any experience with Python will greatly simplify the process.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="1 Prepare Python for CANlib"][vc_header_raket header_type="h3" header="1.1 Required hardware"][vc_column_text]To complete the first step of this guide, sending and receiving a CAN message, we need the following hardware:
  • A computer with Windows or Linux (for Linux, preferably Ubuntu flavour) operating system (OS).
  • Two CAN channels are needed so we can use either a CAN interface with two channels or two interfaces with one channel each. I will use a Kvaser USBcan Pro 2xHS v2 (00752-9).
  • Virtual interfaces can be used during step one if an interface is not available.
  • A correctly terminated CAN bus. I will use a T-Connector v2 (00776-5), set to 60 ohm resistance.
  • Depending on the number of interfaces that will be used and available USB ports, a USB Hub may be necessary to connect all devices to the computer.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="1.2 Computer software changes"][vc_column_text]We will need to make changes to the computer and download software. The following changes need to be done to the computer:
  • You must have administrator privileges for your computer so that you can make the changes necessary.
  • The latest version (or at least version 3.7+) Python.
  • The CANlib Software Development Kit software.
  • Kvaser CANlib drivers.
  • Any eventual text editor of your choice (Idle will be automatically installed with Python and will mostly be used in this guide).
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="1.3 Windows"][vc_column_text]If you are using the Windows operating system, the following section will describe how to download the required software specifically for Windows. If you have the Linux OS, go to the next section.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.3.1 Download and install Python (Windows)"][vc_column_text]The first step is to install Python. For a detailed guide on how to install Python, visit RealPython.com installing python. The following is a concise version of how to install Python for Windows:[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.3.1.1 Check Python version (Windows)"][vc_column_text]Before installing Python, check if it is already installed. Open PowerShell (by selecting the windows key and search for “powershell”) and type either: > py --version Or > py -V  (--version and -V are interchangeable) If Python is already installed the output will show (Python 3.9.5 is the latest version as of 06-15-2021): Python 3.9.5  If Python is not installed, the output will be something like: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. Or ‘Py’ is not recognized as an internal or external command, operable program or batch file. If Python was not installed or too old a version was installed, then we need to install a newer version. If an acceptable version of Python (3.7+) is already installed, skip the next section.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.3.1.2 Installing Python (Windows)"][vc_column_text]The Python version we need is v3.7 or above. In this guide we will only explore one way to install Python. First download the installer (For more details on installing Python for Windows visit realpython.com):
  1. Open Python.org downloads page for windows.
  2. Under “Download the latest version for Windows”, click the download Python button to download the latest version of Python. 
[/vc_column_text][vc_column_text]When the installer has finished downloading, run it by double-clicking it. A dialog box will appear. There are four things to notice about the box:
    1. Default install path is in the AppData/directory of the current Windows user.
    2. The Customize installation button can customize the installation location and eventual additional features to install.
  • Install launcher for all users (recommended) is checked as default. This means every user on the machine will have access to the py.exe launcher.
  • The Add Python to path checkbox is unchecked by default. This is not necessary as py already gets a path automatically after installation.
You have now installed Python. To make sure the installation was successful, run the following command in PowerShell: > py --version Which should result in something like: Python 3.9.5[/vc_column_text][vc_single_image image="36510"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.3.2 Using virtual environments (Windows)"][vc_column_text]To easily run Python, a virtual environment is recommended. For a more detailed description of what the virtual environment is, why it is needed and how to install it visit RealPython.com python virtual environments. Virtual environments are needed to help with storing directories and receiving site packages such as canlib. To create a virtual environment in windows run the following in powershell: > py -3 -m venv .venv --prompt . “py -3“ dictates that Windows will launch the latest version of Python 3, for more information about the launcher check the documentation. “-m” dictates that you want to run a module and “venv” is the name of the module. “.venv” decides the name of the directory where the virtual environment will be created. “--prompt” changes the name of the virtual environment when it is activated and “.” dictates that the name should be the same as the current directory.[/vc_column_text][vc_column_text]To activate the virtual environment run the following in powershell, this will result in something like: > .\.venv\Scripts\activate (pyproj)> This code runs the activate script (a script is a file with Python code). The script is located in the Scripts directory in the .venv directory. If we are running in PowerShell and get the error message: cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. Then we need to give ourself permission to run scripts. Either we can run: > Set-ExecutionPolicy Unrestricted -Scope Process In powershell to gain permission for this session, or we can run: > Set-ExecutionPolicy Unrestricted -Scope CurrentUser In powershell to gain permission for the current user over all later sessions. Now we can use the environment, its packages and resources in isolation. To deactivate the virtual environment type the following in powershell: > deactivate[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.3.3 Download and install CANlib driver and SDK (Windows)"][vc_column_text]On Windows, firstly we need to install the CANlib driver by downloading and running “Kvaser Drivers for Windows” which can be found on the Kvaser Download page or directly from kvaser_drivers_setp.exe. Kvaser CANlib SDK also needs to be downloaded from the same Kvaser page or directly from canlib.exe and installed if more than just the basic canlib library will be used. This will install the rest of the supported library dll’s. The two packages, “Kvaser Drivers for Windows” and “Kvaser CANlib SDK”, contain both 32 and 64 bit versions of the included dll’s. To make sure the driver was installed correctly, press the windows button and search for Kvaser Device Guide. If Kvaser Device Guide exists the installation was successful.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="1.4 Linux"][vc_column_text]If you are using the Linux operating system, the following sections will explain how to download the software specifically needed for Linux. If you have the Windows operating system, go to the previous section.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.4.1 Download and install Python (Linux)"][vc_column_text]The first step is to install Python. For a detailed guide on different methods to install Python, visit RealPython.com installing python. The following is a short insight into how to install Python for Linux:[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.4.1.1 Check Python version (Linux)"][vc_column_text]Before installing Python on Linux check if it is already installed and which version. Open a terminal and try the following: $ python --version $ python3 --version # Used by most Linux system to invoke python v3+ If Python is installed, one or both of these commands will return the following (Python 3.9.5 is the latest version as off 06-15-2021): Python 3.9.5 If Python was not installed or a too old version was installed, go to the next section for installing a newer version of Python.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.4.1.2 Installing Python (Linux)"][vc_column_text]If an acceptable version of Python (3.7+) is already installed, skip this section, otherwise install Python. In this guide we will use the operating system’s package manager. Note that some operating systems do not have a package manager - to read more visit realpython.com. We will only go through how to install on Ubuntu 18.04, Ubuntu 20.04 and above. For further instructions on the different operating systems, visit RealPython installing Python on linux. For Ubuntu, first run the following to determine the local Ubuntu version: $ lsb_release -a Then if the release number is 18.04 or 20.04 and above do the following: $ sudo apt-get update $ sudo apt-get install python3 python3-pip Once installation is complete, run Python with python3 command and pip with pip3 command. Run Python3 --version again to make sure the installation was successful.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.4.2 Using virtual environments (Linux)"][vc_column_text]To easily run Python, a virtual environment is recommended. For a more detailed description of what the virtual environment is, why it is needed and how to install it visit RealPython.com python virtual environments. Virtual environments are needed to help with storing directories and receiving site packages such as canlib. [/vc_column_text][vc_column_text]Before creating a virtual environment, we need to create a file/directory where we want our virtual environment and projects that will use the environment. In this example the name of the file created is env. Firstly, make a new directory and go into it using: $ mkdir python-virtual-environments && cd python-virtual-environments Then install the python virtual environment with: $ sudo apt-get install python3-venv To create a virtual environment in Linux run the following: $ python3 -m venv .venv --prompt pyproj “python3” dictates that Linux will launch the latest version of Python 3, “-m” dictates that we want to run a module and “venv” is the name of the module. “.venv” decides the name of the directory where the virtual environment will be created. “--prompt” changes the name of the virtual environment prompt when it is activated and “pyproj” dictates that the name should be “pyproj”. To activate the virtual environment we need to run the following: $ source .venv/bin/activate (pyproj) $ This is a path that dictates the source through .venv to bin and lastly activate. Now we can use the environment, its packages and resources in isolation. To deactivate the virtual environment, type: (pyproj) $ deactivate  [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="1.4.3 Download and install CANlib driver and SDK (Linux)"][vc_column_text]In Linux, first install CANlib by downloading and installing “Kvaser LINUX Driver and SDK” which can be found on the Kvaser Download page or directly from linuxcan.tar.gz. If more than just the basic canlib library will be used, the rest of the supported libraries will be available by downloading and installing “Linux SDK library” kvlibsdk.tar.gz. To check it is correctly installed run listChannels which should result in something like: (pyproj)$ /usr/doc/canlib/examples/listChannels CANlib version 5.36 Found 4 channel(s). ch 0: Kvaser USBcan Pro 2xHS v2 73-30130-00752-9, s/n 13406, v3.25.753 (mhydra v8.36.575) ch 1: Kvaser USBcan Pro 2xHS v2 73-30130-00752-9, s/n 13406, v3.25.753 (mhydra v8.36.575) ch 2: Kvaser Virtual CAN 0-00000-00000-0, s/n 1, v0.0.0 (kvvirtualcan v8.36.575) ch 3: Kvaser Virtual CAN 0-00000-00000-0, s/n 1, v0.0.0 (kvvirtualcan v8.36.575)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="2 Install Python canlib package"][vc_column_text]To install the Python package canlib using pip, activate the virtual environment via PowerShell and run the following command:
.\.venv\Scripts\activate (pyproj)> pip install canlib
To make sure that canlib was installed correctly, run the following code in a Python interpreter. To open a Python interpreter simply type python or py into PowerShell. To read more about Python interpreters visit Python documentation: (pyproj)> python Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from canlib import canlib >>> canlib.prodversion() Which should result in something like: VersionNumber(major=5, minor=36, release=None, build=None) After canlib has been downloaded, if the following message is shown: WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available. You should consider upgrading via the ' C:\Users\extac\Pyproj\.venv\scripts\python.exe -m pip install --upgrade pip' command. Simply run the command in PowerShell as suggested:
C:\Users\extac\Pyproj\.venv\scripts\python.exe -m pip install --upgrade pip
This will upgrade the pip version to the latest version.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="3 Install Hardware"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="3.1 Installing Kvaser CAN interfaces"][vc_column_text](It is possible to use any single, dual or quad Kvaser CAN interface. A Kvaser Memorator can also be used in interface mode.) The hardware used in this guide includes a Kvaser USBcan Pro 2xHS v2 and a Kvaser T-cannector v2. Before plugging the hardware together, make sure that the T-cannector is set to 60 ohm (using the switch on the box). The internal termination needed depends on the number of nodes. A load of 60 Ohm will result in a proper recessive level for any number nodes connected to the bus. To read more about termination visit Kvaser.com termination. To install the USBcan, simply plug it into the computer and the hardware will do the rest. Both CAN contacts need to be plugged into the T-cannector, otherwise channels will not be able to send messages between each other. After the message is sent, any CAN controller that received the message correctly adds an acknowledgement bit at the end of the message. If the message is not acknowledged, the sender will resend the message until it is acknowledged. Therefore, to be able to correctly send a message, it needs to be received. To read more about acknowledgement and CAN messages visit Kvaser.com can messages.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="3.2 Installing virtual interfaces"][vc_column_text]If no hardware is available, then virtual interfaces can be used for the first part of this guide. Two virtual channels are installed automatically on Windows when installing the Kvaser drivers. If you want to read more on how to install additional virtual channels visit Kvaser.com canlib help. In Linux, to download virtual devices, go to linuxcan\virtualcan\virtualcan.h and edit the define statements: #define NR_CHANNELS       2 #define NR_VIRTUAL_DEV    1 You can read more about installing virtual interfaces at Kvaser.com install Linux, if you want to read more about virtual busses in general, visit Kvaser.com virtual device channel. How to use the virtual interface will be presented later in the guide.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="4 Verify the installation"][vc_column_text]To test that all of the software and hardware has been installed correctly, write the following code in the code editor of your choice, making sure the file is located in the same directory as the virtual environment. If you do not have a code editor, idle will have been installed with Python on Windows. To use idle with the virtual environment run the following command in PowerShell: (pyproj)> python -m idlelib This will open an idle window in which you can open your code file and run the code with f5, or via the run tab. If we instead open idle by right-clicking the .py file and choosing edit with idle,  we will not be able to run the code directly with f5 or via the run tab.  The script we need to run within the virtual environment is check_ch and includes the following code:[/vc_column_text][vc_code_raket code="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FjaCUyMHNwZWNpZmljJTIwY2hhbm5lbCUyMGlzJTIwc2F2ZWQlMjBpbiUyMGNoZC4lMEElMjAlMjAlMjAlMjBjaGQlMjAlM0QlMjBjYW5saWIuQ2hhbm5lbERhdGElMjhjaCUyOSUwQSUyMyUyMExhc3RseSUyMHRoZSUyMGNoYW5uZWwlMkMlMjBjaGFubmVsJTIwbmFtZSUyQyUyMHByb2R1Y3QlMjBudW1iZXIlMkMlMjBzZXJpYWwlMjBudW1iZXIlMkMlMjBhbmQlMjBsb2NhbCUyMCUwQSUyMyUyMGNoYW5uZWwlMjBudW1iZXIlMjBvbiUyMHRoZSUyMGRldmljZSUyMGFyZSUyMHByaW50ZWQuJTBBJTIwJTIwJTIwJTIwcHJpbnQlMjhmJTIyJTdCY2glN0QuJTIwJTdCY2hkLmNoYW5uZWxfbmFtZSU3RCUyMCUyOCU3QmNoZC5jYXJkX3VwY19uby5wcm9kdWN0JTI4JTI5JTdEJTNBJTdCY2hkLmNhcmRfc2VyaWFsX25vJTdEJTJGJTdCY2hkLmNoYW5fbm9fb25fY2FyZCU3RCUyOSUyMiUyOSUwQQ=="][vc_single_image image="36519"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]To run the code from PowerShell, go to the directory where the file and virtual environment are located. Start the virtual environment and launch the script called check_ch.py with:
.\.venv\Scripts\activate (pyproj)> py check_ch.py
This should result in 

Found 4 channels 0. Kvaser USBcan Pro 2xHS v2 (channel 0) (00752-9:13406/0) 1. Kvaser USBcan Pro 2xHS v2 (channel 1) (00752-9:13406/1) 2. Kvaser Virtual CAN Driver (channel 0) (00000-0:0/0) 3. Kvaser Virtual CAN Driver (channel 1) (00000-0:0/1)

Assuming that all of the software and hardware was installed correctly, 0-3 are the channels available on the CANusb. In this example, we will only use channel 0 and 1. On Linux there will be no virtual channel by default. The Kvaser Device Guide can also be used. Simply open the application and we should see something like the following:[/vc_column_text][vc_single_image image="36520"][vc_column_text]In this window we can see that the Kvaser USBcan Pro 2xHS v2 we plugged in appears at the top of the list.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="5 Send a CAN message"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.1 Simple approach"][vc_column_text]To send a basic CAN message, create a script named send_msg.py containing the following code (make sure that the script is located within the same folder as the virtual environment):[/vc_column_text][vc_code_raket code="JTIzc2VuZF9tc2clMEElMjMlMjBUaGUlMjBDQU5saWIlMjBsaWJyYXJ5JTIwaXMlMjBpbml0aWFsaXplZCUyMHdoZW4lMjB0aGUlMjBjYW5saWIlMjBtb2R1bGUlMjBpcyUyMGltcG9ydGVkLiUyMFRvJTIwYmUlMEElMjMlMjBhYmxlJTIwdG8lMjBzZW5kJTIwYSUyMG1lc3NhZ2UlMkMlMjBGcmFtZSUyMGFsc28lMjBuZWVkcyUyMHRvJTIwYmUlMjBpbnN0YWxsZWQuJTBBZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUyQyUyMEZyYW1lJTBBJTBBJTIzJTIwRmlyc3RseSUyQyUyMG9wZW4lMjB0d28lMjBDQU4lMjBjaGFubmVscyUyQyUyMG9uZSUyMHRvJTIwc2VuZCUyMHRoZSUyMG1lc3NhZ2UlMjBhbmQlMjBvbmUlMjB0byUyMHJlY2VpdmUuJTBBJTIzJTIwTm90ZSUyMHRoYXQlMjB0aGVyZSUyMG5lZWRzJTIwdG8lMjBiZSUyMGElMjBjaGFubmVsJTIwdG8lMjByZWNlaXZlJTJDJTIwYXMlMjBvdGhlcndpc2UlMjB0aGUlMjBtZXNzYWdlJTBBJTIzJTIwY2FuJTIwbm90JTIwYmUlMjBzZW50LiUyMEluJTIwdGhpcyUyMGV4YW1wbGUlMjB0aGUlMjBjaGFubmVscyUyMGFyZSUyMG5hbWVkJTIwY2hfYSUyMGFuZCUyMGNoX2IuJTIwVG8lMEElMjMlMjBvcGVuJTIwdGhlJTIwY2hhbm5lbHMlMjBjYWxsJTIwb24lMjB0aGUlMjBv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lMEFtc2clMjAlM0QlMjBjaF9iLnJlYWQlMjh0aW1lb3V0JTNENTAwJTI5JTBBcHJpbnQlMjhtc2clMjklMEElMEElMjMlMjBBZnRlciUyMHRoZSUyMG1lc3NhZ2UlMjBoYXMlMjBiZWVuJTIwc2VudCUyQyUyMHJlY2VpdmVkJTIwYW5kJTIwcmVhZCUyMGl0JTIwaXMlMjB0aW1lJTIwdG8lMjBpbmFjdGl2YXRlJTBBJTIzJTIwdGhlJTIwQ0FOJTIwY2hpcC4lMjBUbyUyMGRvJTIwdGhpcyUyMGNhbGwlMjAuYnVzT2ZmJTI4JTI5JTIwb24lMjBib3RoJTIwY2hhbm5lbHMlMjB0aGF0JTIwd2VudCUyMC5idXNPbiUyOCUyOSUwQWNoX2EuYnVzT2ZmJTI4JTI5JTBBY2hfYi5idXNPZmYlMjglMjklMEElMEElMjMlMjBMYXN0bHklMkMlMjBjbG9zZSUyMGFsbCUyMGNoYW5uZWxzJTIwd2l0aCUyMGNsb3NlJTI4JTI5JTIwdG8lMjBmaW5pc2glMjB1cC4lMEFjaF9hLmNsb3NlJTI4JTI5JTBBY2hfYi5jbG9zZSUyOCUyOSUwQSUwQSUyMyUyMERlcGVuZGluZyUyMG9uJTIwdGhlJTIwc2l0dWF0aW9uJTIwaXQlMjBpcyUyMG5vdCUyMGFsd2F5cyUyMG5lY2Vzc2FyeSUyMG9yJTIwcHJlZmVyYWJsZSUyMHRvJTIwZ28lMjBvZiUwQSUyMyUyMHRoZSUyMGJ1cyUyMHdpdGglMjB0aGUlMjBjaGFubmVscyUyMGFuZCUyQyUyMGluc3RlYWQlMjBvbmx5JTIwdXNlJTIwY2xvc2UlMjglMjkuJTIwQnV0JTIwdGhpcyUyMHdpbGwlMjBiZSUwQSUyMyUyMHRhbGtlZCUyMG1vcmUlMjBhYm91dCUyMGxhdGVyLiUwQSUwQQ=="][vc_column_text]To run the previous program, activate your virtual environment and run the script using powershell. Running the program will result in something like the following:[/vc_column_text][vc_code_raket code="JTNFJTIwLiU1Qy52ZW52JTVDU2NyaXB0cyU1Q2FjdGl2YXRlJTBBJTI4cHlwcm9qJTI5JTNFJTIwcHklMjBzZW5kX21zZy5weSUwQUZyYW1lJTI4aWQlM0QxMjMlMkMlMjBkYXRhJTNEYnl0ZWFycmF5JTI4YiUyN0hFTExPJTIxJTI3JTI5JTJDJTIwZGxjJTNENiUyQyUyMGZsYWdzJTNEJTNDTWVzc2FnZUZsYWcuU1REJTNBJTIwMiUzRSUyQyUyMHRpbWVzdGFtcCUzRDklMjk="][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="5.1.1 Opening virtual interfaces"][vc_column_text]If we want to use the virtual interface and the virtual channels, we need to change the openchannel commands. Firstly we need to change the numbers from 0 and 1 to 2 and 3 to represent the virtual channels. Then we need to add a flag (another input) that says ACCEPT_VIRTUAL to define that a virtual channel will be used and accepted. The command will now look like: canlib.openChannel(channel=2, flags=canlib.open.ACCEPT_VIRTUAL) If we do not add the ACCEPT_VIRTUAL flag we will receive a Specified device not found (-3). It is also important to note that a virtual channel can only communicate with another virtual channel.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.2 A more Pythonic way"][vc_column_text]The code used in send a CAN message is a very standard and straightforward way to write the script we want. Using Python, however, we can write the code in a more “Pythonic way”. This will lead to the following script names send_msg_pyt.py:[/vc_column_text][vc_code_raket code="JTIzJTIwc2VuZF9tc2dfcHl0JTBBZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGNhbmxpYiUyQyUyMEZyYW1lJTBBJTBBJTIzJTIwaW5zdGVhZCUyMG9mJTIwb3BlbmluZyUyMHRoZSUyMHR3byUyMGNoYW5uZWxzJTIwYW5kJTIwY2xvc2luZyUyMHRoZW0lMjBvbmUlMjBieSUyMG9uZSUyQyUyMHdlJTIwd2lsbCUyMHVzZSUyMGElMEElMjMlMjB3aXRoJTIwc3RhdGVtZW50LiUyMFVzaW5nJTIwdGhlJTIwd2l0aCUyMH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MCUyMCUyMCUyMGZvciUyMGNoJTIwaW4lMjAlNUJjaF9hJTJDJTIwY2hfYiU1RCUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGNoLmJ1c09uJTI4JTI5JTBBJTBBJTIwJTIwJTIwJTIwZnJhbWUlMjAlM0QlMjBGcmFtZSUyOGlkXyUzRDEyMyUyQyUyMGRhdGElM0QlNUI3MiUyQyUyMDY5JTJDJTIwNzYlMkMlMjA3NiUyQyUyMDc5JTJDJTIwMzMlNUQlMjklMEElMjAlMjAlMjAlMjBjaF9hLndyaXRlJTI4ZnJhbWUlMjklMEElMEElMjAlMjAlMjAlMjBtc2clMjAlM0QlMjBjaF9iLnJlYWQlMjh0aW1lb3V0JTNENTAwJTI5JTBBJTIwJTIwJTIwJTIwcHJpbnQlMjhtc2clMjklMEElMEElMjMlMjBBZnRlciUyMHdlJTIwcnVuJTIwb3V0JTIwb2YlMjBjb2RlJTIwd2l0aGluJTIwdGhlJTIwd2l0aCUyMHN0YXRlbWVudCUyMGFuZCUyMGV4aXQlMjBpdCUyQyUyMHdlJTIwZG9uJTI3dCUwQSUyMyUyMG5lZWQlMjB0byUyMG1hbnVhbGx5JTIwY2xvc2UlMjBpdCUyMG9yJTIwZ28lMjBvZmYlMjBidXMuJTIwVGhlJTIwY2hhbm5lbHMlMjB0aGF0JTIwd2VyZSUyMG9wZW4lMjB1c2luZyUwQSUyMyUyMHRoZSUyMHdpdGglMjBzdGF0ZW1lbnQlMjB3aWxsJTIwYmUlMjBhdXRvbWF0aWNhbGx5JTIwY2xvc2VkJTJDJTIwYW5kJTIwd2l0aCUyMHRoZSUyMGNoYW5uZWxzJTIwYmVpbmclMEElMjMlMjBjbG9zZWQlMjB0aGV5JTIwYWxzbyUyMHdlbnQlMjBvZmYlMjB0aGUlMjBidXMuJTBBJTBB"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.3 Using WriteWait"][vc_column_text]While writing several messages, we might want to confirm that they were sent properly. To do this we will make use of the command writeWait(). writeWait does the same as write when it comes to sending a message, but it also gives a timeout limit for how long it will wait for the message to be sent. The command may look like writeWait(frame, timeout=500), which will send a message with the details given by frame and wait 500 milliseconds for it to be sent before returning an error message Timeout occurred (-7). WriteWait can be used when sending one or several messages. When sending several messages we can use writeWait on every message, but this will take some time to execute and is not very efficient. Instead we can use write on all messages apart from the last one which will be writeWait. If one message fails to be sent properly, all after will fail and the timeout error Timeout occured (-7) will be raised by writeWait.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]To test writeWait we will make two scripts called send_msg_wait.py and send_msgs_wait.py which will be based on the send message code but with some changes. The first script send_msg_wait.py will send a message using writeWait to send one successful message and one unsuccessful message:[/vc_column_text][vc_code_raket code="JTIzJTIwc2VuZF9tc2dfd2FpdCUwQWZyb20lMjBjYW5saWIlMjBpbXBvcnQlMjBjYW5saWIlMkMlMjBGcmFtZSUwQSUwQSUyMyUyMFdlJTIwd2lsbCUyMG5vdyUyMG9wZW4lMjB0aHJlZSUyMGNoYW5uZWxzJTJDJTIwdHdvJTIwZnJvbSUyMHRoZSUyMFVTQmNhbiUyMGFuZCUyMG9uZSUyMG9uJTBBJTIzJTIwdGhlJTIwbGVhZiUyMHBybyUyMHdoaWNoJTIwd2UlMjB3aWxsJTIwbm90JTIwY29ubmVjdCUyMHRvJTIwdGhlJTIwVC1jYW5uZWN0b3IuJTIwV2UlMjB3aWxsJTIwdXNlJTIwdGhlJTBBJTIzJTIwbGVhZiUyMHBybyUyMGNoYW5uZWwlMjBjaF9jJTIwdG8lMjBzZW5kJTIwZXJyb3JmcmFtZXMuJTBBd2l0aCUyMGNhbmxpYi5vcGVuQ2hhbm5lbCUyODIlMjklMjBhcyUyMGNoX2ElMkMlMjBjYW5saWIub3BlbkNoYW5uZWwlMjgzJTI5JTIwYXMlMjBjaF9iJTJDJTIwY2FubGliLm9wZW5DaGFubmVsJTI4NCUyOSUyMGFzJTIwY2hfYyUzQSUwQSUyMCUyMCUyMC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2FubmVjdG9yLiUyMFRoaXMlMjBzaG91bGQlMjByZXN1bHQlMjBpbiUyMGElMjB0aW1lb3V0JTIwZXJyb3IuJTBBJTIwJTIwJTIwJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UlMjgxOTklMjklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjaF9jLndyaXRlJTI4ZnJhbWUlMjklMEElMjAlMjAlMjAlMjBjaF9jLndyaXRlV2FpdCUyOGZyYW1lJTJDJTIwdGltZW91dCUzRDEwMCUyOSUwQSUwQSUyMCUyMCUyMCUyMG1zZyUyMCUzRCUyMGNoX2IucmVhZCUyOHRpbWVvdXQlM0Q1MDAlMjklMEElMjAlMjAlMjAlMjBwcmludCUyOG1zZyUyOSUwQSUwQQ=="][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="6 Troubleshooting, basic errors"][vc_column_text]While working with Python canlib and CAN interfaces, there are multiple errors and problems we can be faced with. We will now go through a couple of common error messages and problems:
  • Blinking red light: A fast blinking red CAN light indicates that several error frames have been received, which means that a problem could have occurred while the message was being transmitted. Three possible problems may be that:
  1. Only one channel is connected to the CAN bus (connected to the T-cannector).
  2. Only one channel is bus on (the channel has gone busOn()).
  3. The receiving or transmitting bus was in silent mode
To fix this, firstly go offbus with the channel that received the error to stop the blinking red light. Then make sure there are at least two channels connected to the T-cannector and on bus in normal mode, one to send the message and one to receive it.
  • No messages available (-2): An error that occurs when we call on read() without a message being sent or being sent incorrectly, for example, because it has the wrong bitrate. This may have been caused by write() not being called or the transmitting channel being on silent mode, which would cause the message to not be sent. To fix this problem, make sure that write() was called correctly with a frame and that the transmitting channel is on normal mode, and that the bitrate is the same as that used by the receiving channel.
  • Transmit buffer overflow (-13): When we try to send a lot of messages that all fail, they will be “queued” in the transmit buffer. This will cause all later messages to also fail, despite being sent correctly. If the channel is on bus, the LED will start blinking red. This can be caused by sending a lot of messages using a silent device or sending messages with a device that is not on bus. If the channel was on bus but silent, the red light will start blinking. To fix this problem, start by going off- and on bus to clear the transmit buffer (the device can also be disconnected and reconnected to the computer). If this doesn’t fix the problem, make sure all busses are on bus, either by using .busOn(), or by checking if the interface is connected to the T-cannector.
  • A hardware error was detected (-15): If we try to interact with a device that is not connected we will receive this error. Most likely the device was not connected with the USB, removed after starting the program, or a line of code somewhere called on the wrong device. To fix this, dubble check that all devices are connected with the USB and if this does not work, double-check all code used to identify a device.
  • Timeout occurred (-7): Timeout is an error raised when the user sets a timeout limit for how long the program will wait for something to happen. If it takes too long, an error will be raised and we will know something went wrong. To fix it we need to go through the code to find the problem. The problem might be that the writing channel was not on bus or in silent mode.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="7 Where do I find information"][vc_column_text]There are multiple ways to find information about CANlib. The best source of information about canlib and commands used with canlib is pycanlib.readthedocs.io. If readthedocs does not work, then there are multiple blogs that explain different aspects of canlib on Kvaser’s website, Kvaser.com.. On the Kvaser website we can also find more information under the support heading and in the canlib webhelp. For example, there are basic resources to get started with Kvaser hardware, documentation such as user guides, developer tools and lastly calculators for calculating bitrate. If you do not find what you are looking for, support is always available. Simply email your issues, problems and questions to [email protected]. For example, in the previous script we want to read a message. But we do not want to move on to the next line until the message has been properly received and read. Furthermore we also want the program to stop and return an error message if the message could not be read. To find the best way to accomplish this, see the documentation at pycanlib.readthedocs.[/vc_column_text][vc_column_text]To find the right documentation we first expand the “Using canlib” tab, since we are using canlib. Next step is how we are using it and what for. Currently we want to send a message and luckily there is a tab called “Send and Receive”, so this can be expanded. Next we see that Reading Messages is also a heading so we click on it to go directly to reading messages. While reading under the “read“ heading we eventually come to a list of functions. One of these states the following: “If you want to wait until a message arrives (or a timeout occurs) and then read it, call read with a timeout”. This sounds like what we are looking for. To read more about the function we can go directly to the “read” function by clicking the link labeled “read”. We can now see that “read” has a parameter called “timeout” which is an integer. This integer dictates how many milliseconds the program will wait for the message to be delivered before returning a timeout error. We have now found what we were looking for and can enter this into our code as channel.read(timeout = 500) for the program to wait 500 milliseconds.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="8 Quick start procedure, reminder"][vc_column_text]If you have taken a break or just forgotten the used commands/procedures, please use this little list of powerful commands and instructions.
    • Start Windows Powershell:   powershell.exe
    • Move to desired directory where you have your Python script: cd (if you already have a virtual environment and permission to run it skip the next two steps)
    • Create a virtual environment:  py -3 -m venv .venv --prompt .
    • If you are using a new computer or a new user without permission: Set-ExecutionPolicy Unrestricted -Scope CurrentUser
    • Activate the virtual environment:  .\.venv\Scripts\activate
    • If you have not already installed canlib in this virtual environment do so: pip install canlib
  • ...
  • Run script: py check_ch.py (check_ch.py is always good to run once to make sure the wanted interfaces are connected)
  • Start editor: python -m idlelib python -m idlelib check_ch.py
  • ...
  • Deactivate the virtual environment:  deactivate
[/vc_column_text][/vc_column][/vc_row] [post_title] => KVASER CANlib and Python Part 1: Initial setup [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvaser-canlib-and-python-part-1-initial-setup [to_ping] => [pinged] => [post_modified] => 2023-04-25 13:25:27 [post_modified_gmt] => 2023-04-25 13:25:27 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=36500 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [3] => WP_Post Object ( [ID] => 36390 [post_author] => 38400 [post_date] => 2021-11-29 10:01:24 [post_date_gmt] => 2021-11-29 10:01:24 [post_content] => [vc_row][vc_column][vc_header_raket header_type="h3" header="Configuration-free wireless CAN bridge with M12 connector achieves predictable CAN communication in situations where wired CAN connection is challenging"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text] Mölndal, Sweden – 29th November 2021 – Kvaser, a global leader in CAN (Controller Area Network) development, is pleased to introduce the Kvaser Air Bridge Light HS M12, a high-performance wireless CAN bridge with dust and water-resistant M12 connectors.[/vc_column_text][vc_column_text]Comprising a preconfigured pair of wireless units with integrated antennas and rugged housings, the Kvaser Air Bridge Light HS M12 reliably exchanges raw CAN data between two networks when a wired CAN connection is challenging. Released originally with 9-pin D-SUB connectors, this variant meets the increasing demand from environmentally-challenged applications, such as those requiring an optical cable replacement or an alternative to CAN cables that experience high abrasion.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]The Kvaser Air Bridge facilitates the job of the system integrator in situations that make wired connection unsuitable or challenging, such as when two moving parts are connected by CAN. Employing a proprietary 2.4GHz radio and frequency hopping mechanism, the Kvaser Air Bridge controls the data rate, radio packet format, output power, and pairing method to achieve predictable latencies without sacrificing stability or range. This configuration makes the Kvaser Air Bridge effective in infrastructure and control applications, where accurate message delivery times are essential. The transmission range is as much as 70 m, with a maximum data rate of 1200 messages per second and a packet latency of 4.8 ms.[/vc_column_text][vc_column_text]Kvaser Air Bridge Light HS M12 is the second model in Kvaser’s Air Bridge product line. This model offers a 5-pin National Marine Electronics Association* (NMEA) compatible CAN connector replacing the 9-pin D-SUB connector on the Kvaser Air Bridge Light HS. Improvements have been made to the firmware to further enhance the Kvaser Air Bridge Light HS M12’s wireless performance, with increased interference immunity and enhanced coexistence mechanisms to increase the co-location capacity of Air Bridge pairs.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]The Kvaser Air Bridge Light HS M12 has achieved regulatory compliance and is optimized for use in the European Union (01141-0) and the United States (01148-9). Both models share the same functionality yet have different radio transmission schemes to address regulatory differences.[/vc_column_text][vc_column_text]For more information about the new Kvaser Air Bridge product line, visit https://www.kvaser.com/airbridge/. Kvaser Air Bridge Light HS M12 can be ordered directly from Kvaser or through one of the company’s authorized sales representatives.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]* Please note that this product is not an NMEA 2000® Certified Product that complies with the NMEA’s current test procedures. ‘NMEA’ in this context refers simply to the type of CAN connector used.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][/vc_column][/vc_row] [post_title] => Kvaser’s wireless CAN bridge replaces CAN cables in marine and other extreme environments [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvasers-wireless-can-bridge-replaces-can-cables-in-marine-and-other-extreme-environments [to_ping] => [pinged] => [post_modified] => 2021-11-30 09:38:45 [post_modified_gmt] => 2021-11-30 09:38:45 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=36390 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [4] => WP_Post Object ( [ID] => 36202 [post_author] => 23 [post_date] => 2021-11-15 00:03:54 [post_date_gmt] => 2021-11-15 00:03:54 [post_content] => [vc_row][vc_column][vc_single_image image="36212"][vc_column_text]Cybersecurity and functional safety have become major topics and focuses of development in most transportation-related industries lately. Many organizations are working to take advantage of the ever-increasing connectivity available today, while working to secure the vehicles from malicious intruders. If you add to this the fact that electronic control systems are responsible for more of the vehicle every year, with Electronic Control Units (ECUs) routinely connected to the accelerator, brakes, and steering, it is easy to understand why vehicle cybersecurity has become so important.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Secure On-board Communications (SecOC) is one aspect of cybersecurity that focuses upon securing communications between ECUs within the vehicle. Security is about denying the intruders access, but neither do you want to leave the valuables lying around for easy picking if intruders do get in. [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Organizations such as the Society of Automotive Engineers (SAE), CAN in Automation (CiA) and the International Organization for Standardization (ISO) are integrating these security mechanisms in existing vehicle standards in ways that will impact the Controller Area Network (CAN) system. Taking Heavy Duty (HD) trucking and the SAE J1939 standard as an example, the transition from classic CAN to CAN with Flexible Data rate (CAN FD) has in large part been driven by a demand for extra bandwidth for cybersecurity purposes. With the eight-byte data limit in classic CAN, there wasn’t room to add significant cybersecurity content in messages. The HD trucking industry is now moving to CAN FD with the publication of the SAE J1939-22, CAN FD Data Link Layer document in March 2021. [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]In addition to cybersecurity, SAE J1939-22 takes into consideration a second path to securing a vehicle’s electronics: Functional Safety (FuSa). FuSa involves preventing and detecting safety-related failures in vehicles and there are different standards already published and in development related to it. The Task Force that created the SAE J1939-22 l standard set aside space to be used by yet-undefined security/safety services. We didn’t define this information as part of the standard; this was left to other task forces and other documents. [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]With space allocated in the standardized message and ways this space can be used to provide security and safety on the network, truck standards are adopting key automotive strategies to secure communications. The ongoing task is to define how to use encryption to secure the communications, how to incorporate a freshness counter and how to do key management to make SecOC and FuSa a reality on a truck near you. Since the technologies for hacking are advancing as fast as the technologies for securing the communications, this is an aspect of vehicle development that won’t be slowing down any time soon.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column width="1/4"][vc_single_image image="36209"][/vc_column][vc_column width="3/4"][vc_header_raket header_type="h3" header="Bryan Hennessy"][vc_column_text]Bryan Hennessy is an Applications Engineer with extensive experience in SAE J1939 and NMEA 2000, as well as the physical and datalink layers of CAN. He is a member of the SAE Truck Bus Control and Communications Network Committee (AKA J1939 Committee), Chairman for the SAE J1939 Next Generation Task Force, and recently completed an update to the SAE J1939-21 datalink layer specification. Bryan has over thirty-five years of experience with digital communications and holds a BSEE from Florida Institute of Technology.[/vc_column_text][/vc_column][/vc_row] [post_title] => How the heavy-duty trucking industry is securing on-board communications [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => how-the-heavy-duty-trucking-industry-is-securing-on-board-communications [to_ping] => [pinged] => [post_modified] => 2021-11-24 00:07:14 [post_modified_gmt] => 2021-11-24 00:07:14 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=36202 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [5] => WP_Post Object ( [ID] => 36188 [post_author] => 5 [post_date] => 2021-11-12 13:04:05 [post_date_gmt] => 2021-11-12 13:04:05 [post_content] => Kvaser will be present on the Warwick Control Technologies’ stand (03.314) at the METSTRADE Show between 16 and 18th November. Come and meet the mind behind CANtegrity, the signal analysis solution that can identify problems in a CAN network that all other error identifications systems will miss! Kent Lennartsson, Kvaser’s Research Manager and Michael Odälv, director of business development, will show how CANtegrity can bring value to critical reliability applications. They will also introduce attendees to our many CAN products suited to marine environments. [post_title] => Meet with Kvaser and Warwick Control Technologies staff at METS! [post_excerpt] => Come and meet the mind behind CANtegrity [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => meet-with-kvaser-and-warwick-control-technologies-staff-at-mets [to_ping] => [pinged] => [post_modified] => 2021-11-12 13:05:38 [post_modified_gmt] => 2021-11-12 13:05:38 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=36188 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [6] => WP_Post Object ( [ID] => 35926 [post_author] => 38 [post_date] => 2021-10-27 16:44:33 [post_date_gmt] => 2021-10-27 16:44:33 [post_content] => [vc_row][vc_column][vc_single_image image="35929"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Congratulations to the winner of this past weekend’s Indy Autonomous Challenge: TUM Autonomous Motorsport from the Technische Universität München (TUM)! TUM took the grand prize during the first ever autonomous race at the famed Indianapolis Motor Speedway. For the Indy Autonomous Challenge, 21 universities from around the world formed into 10 teams and were tasked with programming Dallara AV-21 racecars to win the $1.5M in prizes. The ultimate goal: to autonomously race an Indy car. Kvaser was delighted to provide the teams with the USB-to-CAN interfaces, joining a long list of proud sponsors, including Kvaser Associates New Eagle, AutonomouStuff, and Schaeffler.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_gallery type="image_grid" images="35933,35932,35931,35930" img_size="400x300"][/vc_column][/vc_row] [post_title] => Congratulations to Indy Autonomous Challenge Winners - TUM Autonomous Motorsport [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => congratulations-to-indy-autonomous-challenge-winners-tum-autonomous-motorsport [to_ping] => [pinged] => [post_modified] => 2022-04-15 09:18:46 [post_modified_gmt] => 2022-04-15 09:18:46 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=35926 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [7] => WP_Post Object ( [ID] => 35851 [post_author] => 4840 [post_date] => 2021-10-26 19:57:41 [post_date_gmt] => 2021-10-26 19:57:41 [post_content] => [vc_row][vc_column][vc_column_text]In this document I will show how to use a Kvaser DINRail as a CAN FD to CAN translator. I will use a database with defined signals and show how to use them in a t-program. The new Kvaser DIN Rail SE410S-X10 allows a standalone CAN translation unit to be created that does not need an additional computer to run. All information and tools needed to follow this document are license free and can be found on our homepage www.kvaser.com. All code samples and models mentioned in this document are free to use.  Any Kvaser multi-channel devices with t programming capability can be used for testing and debugging. I will use the “Kvaser DIN Rail SE410S-X10”.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Please feel free to contact us if you have any questions about this document. Just send questions or comments to : [email protected][/vc_column_text][vc_dd_contact_person _name="Lars-Göran Fredriksson" _role="Field Application Engineer, Kvaser AB" _email="[email protected]" profile_images="35883"][/vc_column][vc_column][vc_column_text] [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="1 The test model"][vc_column_text]I do not have a physical network to play around with, so I need to create one. I have decided to have one CAN FD network and one standard CAN network:[/vc_column_text][vc_single_image image="35925"][vc_column_text]I must admit, this is a very beautiful picture. What I try to illustrate are two well-terminated CAN-bus, connected to a DINRail SE410 interface.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="1.1 My CAN FD network"][vc_column_text]On my FD network (the one connected to channel 1 and 2) is a magical device that sends and receives the message TEST_MSG_101. It is a CAN FD frame with the ID 101 and contains eight different signals: Latitude, Longitude, Altitude, Speed over ground, Course over ground, Roll, Pitch and Heading. These are typical values that might come from a combined GPS/Gyro sensor.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="1.2 My (standard) CAN network"][vc_column_text]On my standard CAN network (the one connected to channel 3 and 4), I have three magical devices that send and receive the messages TEST_MSG_201, TEST_MSG_202 and TEST_MSG_203.   The first message handles the signals Roll, Pitch and Heading. The second handles Latitude, Longitude and Altitude. The third handles Speed over ground and Course over ground. (Please check Appendix A for a description of the DBC file and the signals) Why did I invent a non-existent network? Most times when working with DBC files, the communication protocol follows the J1939 standard. J1939 is a standard owned by SAE and I am not allowed to publish any of their protocols or signal id. On the DINRail I will use channels 1 and 3 for the t-script. Channels 2 and 4 will be used as debugging channels so I can emulate my magical devices. (I will use Kvaser CANKing software to send and receive text messages on channels 2 and 4.)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="2 The t-script"][vc_column_text](For information on how to use t-script. Please see section 5.4) (You can find the complete listing for the t-script and DBC file in appendix A and B.)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.1 Basic Setup"][vc_code_raket code="dmFyaWFibGVzJTIwJTdCJTBBJTIwJTIwY29uc3QlMjBpbnQlMjBNeUNBTkZEY2glM0QwJTNCJTBBJTIwJTIwY29uc3QlMjBpbnQlMjBNeUNBTmNoJTNEMiUzQiUwQSU3RCUwQSUwQW9uJTIwc3RhcnQlMjAlN0IlMEElMjAlMjBwcmludGYlMjglMjJTY3JpcHQlMjBzdGFydGVkLi4uJTVDbiUyMiUyOSUzQiUwQSUwQSUyMCUyMGNhbkJ1c09mZiUyOE15Q0FORkRjaCUyOSUzQiUwQSUyMCUyMGNhbkJ1c09mZiUyOE15Q0FOY2glMjklM0IlMEElMEElMjAlMjAlMkYlMkZTZXQlMjBGaXJzdCUyMGNoYW5uZWwlMjAlMjhGRCUyOSUwQSUyMCUyMGNhblNldEJpdHJhdGUlMjhNeUNBTkZEY2glMkNjYW5GRF9CSVRSQVRFXzUwMEtfODBQJTI5JTNCJTBBJTIwJTIwY2FuU2V0QnVzT3V0cHV0Q29udHJvbCUyOE15Q0FORkRjaCUyQyUyMGNhbkRSSVZFUl9OT1JNQUwlMjklM0IlMEElMEElMjAlMjBjYW5TZXRCaXRyYXRlRmQlMjhNeUNBTkZEY2glMkNjYW5GRF9CSVRSQVRFXzJNXzgwUCUyOSUzQiUwQSUyMCUyMGNhblNldENvbW11bmljYXRpb25Nb2RlJTI4TXlDQU5GRGNoJTJDJTIwY2FuTU9ERV9DQU5fRkQlMjklM0IlMEElMEElMjAlMjAlMkYlMkZTZXQlMjBTZWNvbmQlMjBjaGFubmVsJTIwJTI4U1REJTI5JTBBJTIwJTIwY2FuU2V0Qml0cmF0ZSUyOE15Q0FOY2glMkNjYW5CSVRSQVRFXzI1MEslMjklM0IlMEElMjAlMjBjYW5TZXRCdXNPdXRwdXRDb250cm9sJTI4TXlDQU5jaCUyQyUyMGNhbkRSSVZFUl9OT1JNQUwlMjklM0IlMEElMEElMEElMjAlMjBjYW5CdXNPbiUyOE15Q0FORkRjaCUyOSUzQiUwQSUyMCUyMGNhbkJ1c09uJTI4TXlDQU5jaCUyOSUzQiUwQSU3RCUwQSUwQW9uJTIwc3RvcCUyMCU3QiUwQSUyMCUyMGNhbkJ1c09mZiUyOE15Q0FORkRjaCUyOSUzQiUwQSUyMCUyMGNhbkJ1c09mZiUyOE15Q0FOY2glMjklM0IlMEFwcmludGYlMjglMjJTY3JpcHQlMjBzdG9wcGVkLi4uJTVDbiUyMiUyOSUzQiUwQSU3RA=="][vc_column_text]This script does almost nothing, except for the most important part, starting up the two CAN channels. The first channel is set up as a 500kbit/2Mbit CAN FD channel and the second is set up as a 250kbit standard CAN channel. If we compile and run this script in TRX, we will see that the script starts and stops. OK, exactly what we wanted, but no magic yet.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.2 Adding the file DB_FD.DBC"][vc_single_image image="35874"][vc_column_text]Open the menu: Project, select: Add Database A dialog box will show and you will be able to add a DBC file to your project.[/vc_column_text][vc_single_image image="35875"][vc_column_text]Important: Make sure that you save your PROJECT. If you use FILE/SAVE then you will only save the t-file. Instead use PROJECT/Save Project As …[/vc_column_text][vc_single_image image="35876"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.3 Using DBC messages as variables"][vc_column_text]When we have added the DBC file to the PROJECT, it is possible for us to create message and signal variables. One of the defined CAN Messages in the DBC file is:TEST_MSG_101 I will now create a GLOBAL variable (FD_GPS) of this type. In the BLOCK: Variables {}, add the line: CanMessageFd_TEST_MSG_101 FD_GPS;[/vc_column_text][vc_column_text]Add the text “CanMessageFD_” to MessageName and TRX will understand that it shall look for it in the DBC file.[/vc_column_text][vc_code_raket code="dmFyaWFibGVzJTIwJTdCJTBBJTIwJTIwY29uc3QlMjBpbnQlMjBNeUNBTkZEY2glMjAlM0QwJTNCJTBBJTIwJTIwY29uc3QlMjBpbnQlMjBNeUNBTmNoJTIwJTIwJTIwJTNEMiUzQiUwQSUwQSUyMCUyMENhbk1lc3NhZ2VGZF9URVNUX01TR18xMDElMjBGRF9HUFMlM0IlMEElMEElMEElMjAlMjBpbnQlMjBGRF9HUFNfVEVTVCUzRDAlM0IlMEElMEElN0QlMEE="][vc_column_text]Now I have a global variable to play with. [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.4 Using DBC messages as identifiers"][vc_code_raket code="b24lMjBDYW5NZXNzYWdlRmQlMjAlM0NNeUNBTkZEY2glM0UlMjBURVNUX01TR18xMDElMjAlN0IlMEElMjAlMjBwcmludGYlMjglMjJEZXRlY3RlZCUyMFRFU1RfTVNHXzEwMSUyMCUzQSUyNWQlNUNuJTIyJTJDJTIwdGhpcy5pZCUyOSUzQiUwQSU3RA=="][vc_column_text]This HOOK will be activated every time there is a message with the ID 101 on the CAN FD bus.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Now comes the magic: we can use the physical values of the signals, without any strange and advanced calculations.[/vc_column_text][vc_code_raket code="b24lMjBDYW5NZXNzYWdlRmQlMjAlM0NNeUNBTkZEY2glM0UlMjBURVNUX01TR18xMDElMjAlN0IlMEElMjAlMjBwcmludGYlMjglMjJEZXRlY3RlZCUyMFRFU1RfTVNHXzEwMSUyMCUzQSUyNWQlNUNuJTIyJTJDJTIwdGhpcy5pZCUyOSUzQiUwQSUwQSUyMCUyMHByaW50ZiUyOCUyMkxBVCUyMFAlM0ElMjVmJTVDbiUyMiUyQyUyMHRoaXMuU18xMDFfTEFULlBoeXMlMjklM0IlMEElMjAlMjBwcmludGYlMjglMjJMQVQlMjBSJTNBJTI1ZCU1Q24lMjIlMkMlMjB0aGlzLlNfMTAxX0xBVC5SYXclMjklM0IlMEElN0Q="][vc_single_image image="35877"][vc_column_text]Running the above script, and detecting a “101” message. We can directly address the data in the SIGNAL S_101_LAT. We can access it as Physical values or Raw values. In the output above we can see that a value of 1800000 is equivalent to 0.000 degrees. (OK, it prints 0.000015, but that is very close to 0.000)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.5 Adding one CanMessageFd hook"][vc_code_raket code="b24lMjBDYW5NZXNzYWdlRmQlMjAlM0NNeUNBTkZEY2glM0UlMjBURVNUX01TR18xMDElMjAlN0IlMEElMjAlMjBDYW5NZXNzYWdlX1RFU1RfTVNHXzIwMSUyMCUyMCUyMFNURF9HUFNfUlBIJTNCJTBBJTIwJTIwQ2FuTWVzc2FnZV9URVNUX01TR18yMDIlMjAlMjAlMjBTVERfR1BTX0xhdExvbkFsdCUzQiUwQSUyMCUyMENhbk1lc3NhZ2VfVEVTVF9NU0dfMjAzJTIwJTIwJTIwU1REX0dQU19Tb2dDb2clM0IlMEElMEElMkYlMkYlMjAlMjBwcmludGYlMjglMjJEZXRlY3RlZCUyMFRFU1RfTVNHXzEwMSUyMCUzQSUyNWQlNUNuJTIyJTJDJTIwdGhpcy5pZCUyOSUzQiUwQSUyRiUyRiUyMCUyMHByaW50ZiUyOCUyMkxBVCU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UyMCUyMCUyMCUyMCUzRHRoaXMuU18xMDFfQ09HLlBoeXMlM0IlMEElMjAlMjBjYW5Xcml0ZSUyOE15Q0FOY2glMkNTVERfR1BTX1NvZ0NvZyUyOSUzQiUwQSU3RA=="][vc_column_text]The FD message “101” will be split into three standard CAN messages. The signals in the 201, 202 and 203 messages have less resolution in their values, but we do not need to worry about that. The t-script will take care of the translation of the logical bits and bytes.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.6 Adding three CanMessage hooks"][vc_code_raket code="b24lMjBDYW5NZXNzYWdlJTIwJTNDTXlDQU5jaCUzRSUyMFRFU1RfTVNHXzIwMSUyMCU3QiUwQSUwQSUyMCUyMEZEX0dQUy5TXzEwMV9ST0xMLlBoeXMlMjAlMjAlMjAlMjAlM0R0aGlzLlNfMjAxX1JPTEwuUGh5cyUzQiUwQSUyMCUyMEZEX0dQUy5TXzEwMV9QSVRDSC5QaHlzJTIwJTIwJTIwJTNEdGhpcy5TXzIwMV9QSVRDSC5QaHlzJTNCJTBBJTIwJTIwRkRfR1BTLlNfMTAxX0hFQURJTkcuUGh5cyUyMCUzRHRoaXMuU18yMDFfSEVBRC5QaHlzJTNCJTBBJTBBJTIwJTIwRkRfR1BTX1RFU1QlM0QlMjAlMjhGRF9HUFNfVEVTVCUyMCU3QyUyMDElMjklM0IlMjAlMjAlMEElMEElMjAlMjBpZiUyMCUyOEZEX0dQU19URVNUJTNFJTNENyUyOSUyMCU3QiUwQSUyMCUyMCUyMCUyMGNhbldyaXRlJTI4TXlDQU5GRGNoJTJDRkRfR1BTJTI5JTNCJTBBJTIwJTIwJTIwJTIwRkRfR1BTX1RFU1QlM0QwJTNCJTBBJTIwJTIwJTdEJTBBJTdE"][vc_code_raket code="b24lMjBDYW5NZXNzYWdlJTIwJTNDTXlDQU5jaCUzRSUyMFRFU1RfTVNHXzIwMiUyMCU3QiUwQSUwQSUyMCUyMEZEX0dQUy5TXzEwMV9MQVQuUGh5cyUy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yNiUyMCUyODElMkIyJTJCMCUyOSUyOSUzQiUwQSUyMCUyMCU3RCUwQSU3RA=="][vc_column_text]We must wait until we get all three messages before we retransmit the “101” message.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="3 Storing the t-program in the memory"][vc_column_text]The Kvaser DIN Rail SE410S-X10 has a battery backed up 16GB non-replaceable memory. It uses the battery to make sure that all uncommitted changes are saved properly before a shutdown. The memory area can be used for storing local data and t-script. It can be modified via SDK (CANlib), t-script or via the filehandler in Kvaser Device Guide(1)(2). (1) 2020-12-20 The version with the filehandler is not yet released. Is planned to be released with version 5.36. (2) If you read this before CANlib SDK 5.36 is released, and want to test the file handler, please send me an email and I will send it to you. ([email protected]) See Appendix C for some detailed memory restrictions[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="3.1 Autostart t programs"][vc_column_text](This information can also be found in the USER GUIDE) Kvaser DIN Rail SE410S-X10 can automatically load and run up to four t programs from memory at power on. This is done by entering the names of the t programs into a special file, autoexec.txt, and copying the compiled t programs (*.TXE) and AUTOEXEC.TXT to the memory. To stop the t programs from being started at power on, simply delete AUTOEXEC.TXT from flash storage or edit the AUTOEXEC.TXT file.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="3.2 AUTOEXEC.TXT"][vc_column_text]This is a special text file that Kvaser DIN Rail SE410S-X10 tries to read from flash storage at power on. Each line must have the following format:  filename, channel, slot [/vc_column_text][vc_header_raket header_type="h4" header="3.2.1 Filename"][vc_column_text]Filename is the name of the compiled t program. It has the extension TXE.[/vc_column_text][vc_header_raket header_type="h4" header="3.2.2 Channel"][vc_column_text]Channel is the CAN channel that the t program will use by default. (We are not using the default channel in our script) (see Kvaser t Programming Language guide for further details.)[/vc_column_text][vc_header_raket header_type="h4" header="3.2.3 Slot"][vc_column_text]Slot is one of four slots numbered 0 to 3 that are available for t programs in Kvaser DIN Rail SE410S-X10.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="3.3 Our AUTOEXEC.TXT file"][vc_column_text]I named my t-script: T-DEM-FD.t Compiled name: T-DEM-FD.TXE Let us create a file named “autoexec.txt” with the line: T-DEM-FD.TXE, 0, 0 Start T-DEM-FD, use default channel 0 and start it in slot 0. [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="4 Conclusion"][vc_column_text]Using a DBC file in a t program is simple. Handling message ID and signals is much easier when they are defined in a DBC file. We must still create the logic of how to transfer data and how to convert between different signals, but we do not need to work with raw data. The t-program does not check for data loss because of differences in precision and range. This must be prepared for when creating the script. I hope the info in this document will help you. Comments and questions are welcome![/vc_column_text][vc_dd_contact_person _name="Lars-Göran Fredriksson" _role="Field Application Engineer, Kvaser AB" _email="[email protected]" profile_images="35883"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="5 Helpful references and tools"][vc_header_raket header_type="h3" header="5.1 The fileT-DEMO-FD.t"][vc_column_text]This is a text file containing the t program code used in this document, please check appendix B for a complete listing.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.2 The file DB_FD.DBC"][vc_column_text]Please check Appendix A. This file contains the messages and signals used in this document.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.3 Kvaser SDK and Drivers"][vc_column_text]To be able to use the softwares mentioned in this document, you must download and install Kvaser Drivers and SDK. https://www.kvaser.com/download/?utm_source=software&utm_ean=7330130980013&utm_status=latest https://www.kvaser.com/download/?utm_source=software&utm_ean=7330130980150&utm_status=latest[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.4 The Kvaser t Programming Language"][vc_column_text]From the user guide: The Kvaser t programming language is event oriented and modeled after C. It can be used to customize the behavior of the Kvaser Eagle and other Kvaser t capable devices. A t program is invoked via hooks, which are entry points that are executed at the occurrence of certain events. These events can be, for example, the arrival of specific CAN messages, timer expiration, or external input. The addition of t programs running directly on a Kvaser Device makes it possible to react much quicker to CAN bus events (for example to speed up file transfer protocols or to simulate missing hardware). Some Kvaser devices can also operate completely autonomously, e.g. the Kvaser Memorator. I will not cover the basics of Kvaser t Programming, please check the user guide: The Kvaser t Programming Language. https://www.kvaser.com/download/?utm_source=software&utm_ean=7330130980327&utm_status=latest There is also some Blogs on our homepage: https://www.kvaser.com/developer_category/t-script/[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.5 The software TRX"][vc_column_text]Kvaser TRX, a lightweight IDE for developing t programs for supported Kvaser devices. https://www.kvaser.com/resource/trx-guide/ This software is installed when installing Kvaser SDK.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.6 The Kvaser Database Editor 3"][vc_column_text]I will not cover how to create, use and maintain a signal database. Kvaser has a free tool: ”Kvaser Database Editor 3 With this tool you can view, create and edit *.DBC files. https://www.kvaser.com/download/?utm_source=software&utm_ean=7330130981942&utm_status=latest We do have some Blogs on our homepage: https://www.kvaser.com/developer_category/dbc/ https://www.kvaser.com/developer_category/database/[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="5.7 Kvaser CANKing"][vc_column_text]A free of charge, general-purpose CAN bus monitor. It works with all CAN interfaces from Kvaser and also with the virtual CAN bus. https://www.kvaser.com/download/utm_source=software&utm_ean=7330130980686&utm_status=latest[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="6 Appendix A, the file DB_FD.DBC"][vc_column_text]Please note that the signals in the CAN FD message (101) have much higher resolution than the signals in the CAN messages (201,202 and 203). The purpose with that is to show that it is easy to convert values of the signals in a t-program. I will not analyze the loss of precision this will create.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="6.1 Messages in DB_FD.DBC"][vc_header_raket header_type="h4" header="6.1.1 TEST_MSG_101"][vc_single_image image="35879"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="6.1.2 TEST_MSG_201"][vc_single_image image="35880"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="6.1.3 TEST_MSG_202"][vc_single_image image="35881"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="6.1.4 TEST_MSG_203"][vc_single_image image="35882"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="6.2 Database DB_FD.DBC source code"][vc_column_text]Please copy and paste the information below, to a text file and name it: DB_FD.DBC VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX SG_ NewSignal_0008 : 0|0@1+ (1,0) [0|0] "" Vector__XXX BO_ 101 TEST_MSG_101: 32 Vector__XXX SG_ S_101_LAT : 0|32@1+ (0.001,-180) [-180|180] "deg" Vector__XXX SG_ S_101_LON : 32|32@1+ (0.001,-180) [-180|180] "deg" Vector__XXX SG_ S_101_ALT : 64|32@1+ (0.001,-1000) [-1000|20000] "m" Vector__XXX SG_ S_101_SOG : 96|32@1+ (0.001,0) [0|1000] "m/s" Vector__XXX SG_ S_101_COG : 128|32@1+ (0.001,0) [0|360] "deg" Vector__XXX SG_ S_101_ROLL : 160|32@1+ (0.001,-180) [-180|180] "deg" Vector__XXX SG_ S_101_PITCH : 192|32@1+ (0.001,-180) [-180|180] "deg" Vector__XXX SG_ S_101_HEADING : 224|32@1+ (0.001,-180) [-180|180] "deg" Vector__XXX BO_ 201 TEST_MSG_201: 6 Vector__XXX SG_ S_201_ROLL : 0|16@1+ (0.1,-180) [-180|180] "deg" Vector__XXX SG_ S_201_PITCH : 16|16@1+ (0.1,-180) [-180|180] "deg" Vector__XXX SG_ S_201_HEAD : 32|16@1+ (0.1,-180) [-180|180] "deg" Vector__XXX BO_ 202 TEST_MSG_202: 6 Vector__XXX SG_ S_202_LAT : 0|16@1+ (0.1,-180) [-180|180] "deg" Vector__XXX SG_ S_202_LON : 16|16@1+ (0.1,-180) [-180|180] "deg" Vector__XXX SG_ S_202_ALT : 32|16@1+ (0.1,-1000) [-1000|20000] "m" Vector__XXX BO_ 203 TEST_MSG_203: 4 Vector__XXX SG_ S_203_SOG : 0|16@1+ (0.1,0) [0|1000] "m/s" Vector__XXX SG_ S_203_COG : 16|16@1+ (0.1,0) [0|360] "deg" Vector__XXX BA_DEF_ BO_ "CANFD_BRS" ENUM "0","1"; BA_DEF_ "BusType" STRING ; BA_DEF_ BU_ "ECU" STRING ; BA_DEF_ BO_ "VFrameFormat" ENUM "StandardCAN","ExtendedCAN","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","reserved","StandardCAN_FD","ExtendedCAN_FD"; BA_DEF_DEF_ "CANFD_BRS" "1"; BA_DEF_DEF_ "BusType" ""; BA_DEF_DEF_ "ECU" ""; BA_DEF_DEF_ "VFrameFormat" "StandardCAN"; BA_ "BusType" "CAN FD"; BA_ "VFrameFormat" BO_ 101 14; BA_ "VFrameFormat" BO_ 201 0; BA_ "VFrameFormat" BO_ 202 0; BA_ "VFrameFormat" BO_ 203 0;[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="7 Appendix B, the file T-DEMO-FD.t"][vc_code_raket code="JTBBJTBBJTBBJTBBdmFyaWFibGVzJTIwJTdCJTBBJTIwJTIwY29uc3QlMjBpbnQlMjBNeUNBTkZEY2glMjAlM0QwJT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UGh5cyUzQiUwQSUyMCUyMEZEX0dQUy5TXzEwMV9BTFQuUGh5cyUyMCUyMCUzRHRoaXMuU18yMDJfQUxULlBoeXMlM0IlMEElMEElMjAlMjBGRF9HUFNfVEVTVCUzRCUyMCUyOEZEX0dQU19URVNUJTIwJTdDJTIwMiUyOSUzQiUyMCUyMCUwQSUwQSUyMCUyMGlmJTIwJTI4RkRfR1BTX1RFU1QlM0UlM0Q3JTI5JTIwJTdCJTBBJTIwJTIwJTIwJTIwY2FuV3JpdGUlMjhNeUNBTkZEY2glMkNGRF9HUFMlMjklM0IlMEElMjAlMjAlMjAlMjBGRF9HUFNfVEVTVCUzRDAlM0IlMEElMjAlMjAlN0QlMEElN0QlMEElMEFvbiUyMENhbk1lc3NhZ2UlMjAlM0NNeUNBTmNoJTNFJTIwVEVTVF9NU0dfMjAzJTIwJTdCJTBBJTBBJTIwJTIwRkRfR1BTLlNfMTAxX0NPRy5QaHlzJTIwJTIwJTNEdGhpcy5TXzIwM19DT0cuUGh5cyUzQiUwQSUyMCUyMEZEX0dQUy5TXzEwMV9TT0cuUGh5cyUyMCUyMCUzRHRoaXMuU18yMDNfU09HLlBoeXMlM0IlMEElMEElMjAlMjBGRF9HUFNfVEVTVCUzRCUyMCUyOEZEX0dQU19URVNUJTIwJTdDJTIwNCUyOSUzQiUyMCUyMCUwQSUwQSUyMCUyMGlmJTIwJTI4RkRfR1BTX1RFU1QlM0UlM0Q3JTI5JTIwJTdCJTBBJTIwJTIwJTIwJTIwY2FuV3JpdGUlMjhNeUNBTkZEY2glMkNGRF9HUFMlMjklM0IlMEElMjAlMjAlMjAlMjBGRF9HUFNfVEVTVCUzRDAlM0IlMEElMjAlMjAlN0QlMEElN0QlMEElMEE="][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="8 Appendix C, File structure on storage area"][vc_column_text]The internal format of the storage area is following the FAT-32 format, but there are several restrictions in how we can use the memory area. We do not have any support for DIRECTORIES, so all files are located in the ROOT of the memory area. The DIN Rail SE410S-X10, uses the 8.3 filename convention. Legal characters for the filenames include the following: Upper case letters A–Z Lower case letters a–z (Used as A–Z) Numbers 0–9 Underscore “_” Non allowed: ASCII 0 - ASCII 32 (Control characters 0–31 and SPACE) ASCII127 - ASCII255 (including DEL(127)) " * + / : ; < = > ? \ [ ] | ! @ (Is allowed in some file systems, but let us avoid them) # $ % & ' ( ) - ^ ` { } ~ On other Kvaser interfaces, there might be some files already on the memory area (like on a Kvaser Memorator). Please do not use any of these filenames: *.LIF LOG*.KMF DATABASE.BIN Also avoid these filenames, they are allowed on Kvasers units, but might cause errors when copied. COM, COM1, COM2, COM3 LPT, LPT1,LPT2,LPT3 CON DEVICE Files names with predefined functions AUTOEXEC.TXT (Used for startup of *.TXE files)[/vc_column_text][/vc_column][/vc_row] [post_title] => Using DINRail SE410S-X10 as CAN FD translator [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => using-dinrail-se410s-x10-as-can-fd-translator [to_ping] => [pinged] => [post_modified] => 2021-10-26 19:57:41 [post_modified_gmt] => 2021-10-26 19:57:41 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=35851 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [8] => WP_Post Object ( [ID] => 35599 [post_author] => 23 [post_date] => 2021-10-04 21:44:53 [post_date_gmt] => 2021-10-04 21:44:53 [post_content] =>

[vc_row][vc_column][vc_single_image image="37077"][vc_column_text]Kvaser's latest software release adds further updates and fixes for J1939 within the Python wrapper for Kvaser CANlib. Users can download the Python wrapper directly from PyPI and read the documentation online via Read the Docs, both of which will be updated continuously going forward. 

Among the notable changes in this release are:

Python CANlib package (V1.19.205):
Docstrings have been updated, extracted and can be viewed online at https://pycanlib.readthedocs.io/

Kvaser Drivers for Windows and CANlib SDK (V5.37): 
DIAdem DAT and MTS RPC III output formats have been added, to expand the formats that work with Kvaser’s converter.

Further support for J1939 includes a new flag in CANlib’s database library. 

Kvaser Linux driver and SDK (V5.37):
The same output formats that are available for Windows (see above) are available in Linux. 

Kvaser mhydra firmware (Blackbird, Memorator 2nd gen., U100, USBcan) (V3.25.855):
An intermittent issue was fixed on Kvaser Memorator 2xHS v2’s where in some circumstances, the device could hang for several seconds at startup. Second-generation Memorator devices using Kvaser Memorator Configuration Tool will benefit from improved timeout handling when formatting SD-cards.

For more details, please read the respective release notes in Kvaser Downloads[/vc_column_text][/vc_column][/vc_row]

[post_title] => Kvaser’s September 2021 Software Release [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvasers-september-2021-software-release [to_ping] => [pinged] => [post_modified] => 2022-01-24 23:54:50 [post_modified_gmt] => 2022-01-24 23:54:50 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=35599 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [9] => WP_Post Object ( [ID] => 35666 [post_author] => 192 [post_date] => 2021-09-29 18:45:02 [post_date_gmt] => 2021-09-29 18:45:02 [post_content] => [vc_row][vc_column][vc_single_image image="37696"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]The Kvaser U100, the most flexible, rugged and intuitive CAN / CAN-FD to USB interface we’ve ever built, just became more flexible. Application-specific connectors are now available, bringing the Kvaser U100’s high data rates, IP67 rating and innovative LED display to many more applications in harsh environments such as marine, heavy-duty truck and trailers and the wider automotive field. The new connectors are as follows:[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/3"][vc_single_image image="37698"][vc_column_text]

Kvaser U100-X1 (01266-0) has a 9-pin J1939-13 Type II CAN connector.

[/vc_column_text][vc_button_raket title="View Product Details" text="" align="align_center" page_id="https://www.kvaser.com/product/kvaser-u100-x1/"][/vc_column][vc_column width="1/3"][vc_single_image image="37699"][vc_column_text]

Kvaser U100-X2 (01267-7) connects to CAN via a 5-pole M12 connector.

[/vc_column_text][vc_button_raket title="View Product Details" text="" align="align_center" page_id="https://www.kvaser.com/product/kvaser-u100-x2/"][/vc_column][vc_column width="1/3"][vc_single_image image="37700"][vc_column_text]

Kvaser U100-X3 (01268-4) has a 16-pin OBDII plug.

[/vc_column_text][vc_button_raket title="View Product Details" text="" align="align_center" page_id="https://www.kvaser.com/product/kvaser-u100-x3/"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]All U100 models are designed for tough environments, with IP67 water and dust resistance, galvanic isolation tested at 5,000 AC voltage RMS for 60 seconds and an operating temperature of -40° C to +85° C. Both the M12 and J1939 Type-II connectors are also classed as IP67-compliant. Should the connectors ever need replacement, an authorized Kvaser party can do so without compromising IP67 integrity.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_separator_raket][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Learn More about the Kvaser U100 USB-to-CAN product series.[/vc_column_text][/vc_column][/vc_row] [post_title] => Kvaser U100 available with M12, J1939, OBDII connections [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvaser-u100-available-with-m12-j1939-obdii-connections [to_ping] => [pinged] => [post_modified] => 2022-06-08 13:32:00 [post_modified_gmt] => 2022-06-08 13:32:00 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=35666 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) ) [post_count] => 10 [current_post] => -1 [in_the_loop] => [post] => WP_Post Object ( [ID] => 36950 [post_author] => 38400 [post_date] => 2022-01-21 14:23:23 [post_date_gmt] => 2022-01-21 14:23:23 [post_content] => [vc_row][vc_column][vc_single_image image="36956"][/vc_column][vc_column][vc_column_text]Rensselaer Formula Hybrid is a student led club that designs, builds, and races an all electric formula style race car for the annual Formula Hybrid competition in Loudon, New Hampshire. We design and manufacture the majority of our parts in house, which allows us to gain valuable engineering experience.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_single_image image="36957"][/vc_column][vc_column width="1/2"][vc_column_text]A large subsystem of the car is its electronics, which include the high voltage battery and power for the motor and also lower voltage safety and telemetry systems. As the team’s knowledge has grown, we’ve started designing and programming custom printed circuit boards to meet system requirements instead of buying off the shelf models. This year, we’ve decided to use CAN communication protocols between our boards, as it’s an industry standard. This also allows us to use less wires on the car itself, increases the amount of data we can send, and reduces noise in the signal, especially when travelling from one end of the car to the other. [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="2/3"][vc_column_text]We would like to thank Kvaser for their generous donation of a Kvaser Leaf Light HS v2, which is a CAN to USB interface. This system allows us to connect our circuit board CAN signals to a laptop, as it comes with a 9 pin D-SUB to USB connector with galvanic isolation as protection. With its high speed and accurate sampling, we can test our circuit boards, and ensure that each board can both send and receive all the data needed for the race car. The Leaf Light HS v2 also comes with a software suite, programming interface, and documentation, which will allow us to debug and test easily, and will also allow us to build team knowledge of how to use the software for CAN interfaces. [/vc_column_text][/vc_column][vc_column width="1/3"][vc_single_image image="36959"][/vc_column][/vc_row] [post_title] => Rensselaer Formula Hybrid use Kvaser to test custom circuit boards [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => rensselaer-formula-hybrid-use-kvaser-to-test-custom-circuit-boards [to_ping] => [pinged] => [post_modified] => 2022-07-22 22:56:47 [post_modified_gmt] => 2022-07-22 22:56:47 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=36950 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [comment_count] => 0 [current_comment] => -1 [found_posts] => 469 [max_num_pages] => 47 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => 1 [is_privacy_policy] => [is_404] => [is_embed] => [is_paged] => 1 [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_favicon] => [is_posts_page] => 1 [is_post_type_archive] => [query_vars_hash:WP_Query:private] => e5bf1491684c7f670c21f743a687fe70 [query_vars_changed:WP_Query:private] => 1 [thumbnails_cached] => [stopwords:WP_Query:private] => [compat_fields:WP_Query:private] => Array ( [0] => query_vars_hash [1] => query_vars_changed ) [compat_methods:WP_Query:private] => Array ( [0] => init_query_flags [1] => parse_tax_query ) )

News and Events

Rensselaer Formula Hybrid use Kvaser to test custom circuit boards

Rensselaer Formula Hybrid use Kvaser to test custom circuit boards

21/01/2022

Rensselaer Formula Hybrid is a student led club that designs, builds, and races an all electric formula style race car… Read More

Read More

KVASER CANlib and Python Part 2: Tests and Samples

21/12/2021

This is the second of two articles that introduce Kvaser CANlib and the Python CANlib Wrapper. In this article, we… Read More

Read More
KVASER CANlib and Python Part 1: Initial setup

KVASER CANlib and Python Part 1: Initial setup

14/12/2021

This is the first of two articles introducing Kvaser CANlib SDK and the Python package canlib. In this part of… Read More

Read More
Kvaser’s wireless CAN bridge replaces CAN cables in marine and other extreme environments

Kvaser’s wireless CAN bridge replaces CAN cables in marine and other extreme environments

29/11/2021

Configuration-free wireless CAN bridge with M12 connector achieves predictable CAN communication in situations where wired CAN connection is challenging Mölndal,… Read More

Read More
How the heavy-duty trucking industry is securing on-board communications

How the heavy-duty trucking industry is securing on-board communications

15/11/2021

Cybersecurity and functional safety have become major topics and focuses of development in most transportation-related industries lately. Many organizations are… Read More

Read More
Meet with Kvaser and Warwick Control Technologies staff at METS!

Meet with Kvaser and Warwick Control Technologies staff at METS!

12/11/2021

Kvaser will be present on the Warwick Control Technologies’ stand (03.314) at the METSTRADE Show between 16 and 18th November.… Read More

Read More

Congratulations to Indy Autonomous Challenge Winners – TUM Autonomous Motorsport

27/10/2021

Congratulations to the winner of this past weekend’s Indy Autonomous Challenge: TUM Autonomous Motorsport from the Technische Universität München (TUM)!… Read More

Read More
Using DINRail SE410S-X10  as CAN FD translator

Using DINRail SE410S-X10 as CAN FD translator

26/10/2021

In this document I will show how to use a Kvaser DINRail as a CAN FD to CAN translator. I… Read More

Read More
Kvaser’s September 2021 Software Release

Kvaser’s September 2021 Software Release

04/10/2021

Kvaser’s latest software release adds further updates and fixes for J1939 within the Python wrapper for Kvaser CANlib. Users can… Read More

Read More

Kvaser U100 available with M12, J1939, OBDII connections

29/09/2021

The Kvaser U100, the most flexible, rugged and intuitive CAN / CAN-FD to USB interface we’ve ever built, just became… Read More

Read More