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

    [query_vars] => Array
        (
            [paged] => 41
            [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 400, 10
    [posts] => Array
        (
            [0] => WP_Post Object
                (
                    [ID] => 39877
                    [post_author] => 14
                    [post_date] => 2015-04-29 13:38:30
                    [post_date_gmt] => 2015-04-29 13:38:30
                    [post_content] => [vc_row disable_element="yes"][vc_column][vc_column_text]

This is the first part of a series.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]The new Kvaser Pro products have script feature called t. The t language is a 'c like', event oriented language. The t-programs run on the device and can be loaded and started either from a pc or autonomously on the device. This is a short introduction to get started with t programming.[/vc_column_text][vc_column_text]To be able to test and run a t program you need a Kvaser Pro product. The software needed is installed with CANlib SDK and called Kvaser TRX.[/vc_column_text][/vc_column][vc_column width="1/2"][vc_column_text]can bus tutorial[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]To get up and running and write your first t program, start by downloading and installing CANlib SDK (Download) then start TRX.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]It will look something like this:image1 In the <New> tab enter:[/vc_column_text][vc_code_raket code="b24lMjBzdGFydCUyMCU3QiUwQSUyMCUyMHByaW50ZiUyOCUyMkhlbGxvJTIwV29ybGQlMjElNUNuJTIyJTI5JTNCJTBBJTdE"][vc_column_text]This a very basic program that reacts on an 'on start' event and prints "Hello World!" in the 'Device Output'. It is the actual device that sends the "Hello World!" to the computer and that TRX reads. Then choose Run->Compile from the menu. To be able to compile you first have to save the t program, TRX will prompt you for this, and it will also prompt you to save a project file. I saved it as blogpost1. If the compilation succedes the next step will require an actual Kvaser Pro product. I connected a Kvaser Memorator Pro 2xHS v2 (View Product). You can see that TRX can use your device if the combo box just under the menu bar has the name of your Kvaser device. To test the t program, just go to Run->Download, this will download the t program to the device. Next step will be to actually run the program. Run->Run will start he application, thus hopefully you will see the printf printout in the Device Output window. image2[/vc_column_text][vc_column_text][/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

Additional resources:

  • The description of the t language can be found in the The Kvaser t Programming Language specification (View).

[/vc_column_text][vc_column_text]

Comments?  Contact us directly at [email protected].

[/vc_column_text][/vc_column][/vc_row] [post_title] => Getting Started with t Programming [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => getting-started-with-t-programming [to_ping] => [pinged] => [post_modified] => 2022-10-04 13:40:17 [post_modified_gmt] => 2022-10-04 13:40:17 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=39877 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [1] => WP_Post Object ( [ID] => 39876 [post_author] => 14 [post_date] => 2015-04-22 13:35:29 [post_date_gmt] => 2015-04-22 13:35:29 [post_content] => [vc_row][vc_column][vc_column_text]Some of our interfaces are equipped with hardware buffers for automatic sending or responding to messages. They can be used when the timing conditions are strict, and might not be possible to fulfill on the application level. Normally, a CAN message received by the CAN driver in the Kvaser unit has to pass through to the computer, by for example a USB or PCI port. It has to pass the operating system and get picked up by the driver before the application can process it. Now, this isn’t as slow as it sounds, but sometimes it is not fast enough. That is when the Kvaser object buffers can be useful, to get around the latency caused by these steps. There are two types of object buffers, auto response and auto transmit.
  • Auto response sends a defined message immediately upon receiving a message meeting your conditions.
  • Auto transmit sends a message periodically, with higher timing accuracy than can be achieved by an application working through driver and operating system.
[/vc_column_text][vc_column_text]

Using the object buffers

Scenario 1: Auto Response

To use the object buffers, you start with allocating a buffer with a call to canObjBufAllocate(). For an auto response buffer, you define which messages to respond to by calling canObjBufSetFilter(), and the contents of the response is set with canObjBufWrite(). To enable a buffer, call canObjBufEnable(), and call canObjBufDisable() to disable it. The filter in canObjBufSetFilter() is of mask and code type, which means you can set the buffer to respond to a range of CAN ids.

Example Code:

This code snippet sets up a buffer that responds to CAN ID 100, with a message with ID 200.[/vc_column_text][vc_code_raket language="csharp" header="This code snippet sets up a buffer that responds to CAN ID 100, with a message with ID 200" code="JTIwJTJGJTJBJTIwU2V0JTIwdXAlMjBhbiUyMGF1dG8lMjByZXNwb25zZSUyMGJ1ZmZlciUyMCUyQSUyRiUwQSUwQSUwQWJ5dGUlNUIlNUQlMjBtc2clMjAlM0QlMjAlN0IlMjAxJTJDJTIwMiUyQyUyMDMlMkMlMjA0JTJDJTIwNSUyQyUyMDYlMjAlN0QlM0IlMjAlMkYlMkZkZWZpbmUlMjBtZXNzYWdlJTBBaW50JTIwYXV0b0J1ZkluZGV4JTIwJTNEJTIwJTI4aW50JTI5JTI4Y2FuT2JqQnVmQWxsb2NhdGUlMjhoYW5kbGUlMkMlMjBjYW5PQkpCVUZfVFlQRV9BVVRPX1JFU1BPTlNFJTI5JTI5JTNCJTIwJTJGJTJGQWxsb2NhdGUlMjBidWZmZXIlMEFpbnQlMjBzdGF0dXMlM0IlMEFzdGF0dXMlMjAlM0QlMjBjYW5PYmpCdWZXcml0ZSUyOGhhbmRsZSUyQyUyMGF1dG9CdWZJbmRleCUyQyUyMDIwMCUyQyUyMG1zZyUyQyUyMDAlMkMlMjAwJTI5JTNCJTIwJTJGJTJGV3JpdGUlMjB0byUyMGJ1ZmZlciUwQXN0YXR1cyUzRCUyMCUyMGNhbk9iakJ1ZlNldEZpbHRlciUyOGhhbmRsZSUyQyUyMGF1dG9CdWZJbmRleCUyQyUyMDEwMCUyQyUyMDB4RkZGRiUyOSUzQiUyMCUyRiUyRk9ubHklMjBtYXRjaCUyMG1lc3NhZ2UlMjB3aXRoJTIwaWQlMjAxMDAlMkMlMjBtYXRjaCUyMG9uJTIwYWxsJTIwYml0cy4lMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMEFzdGF0dXMlMjAlM0QlMjBjYW5saWJDTFNORVQuQ2FubGliLmNhbk9iakJ1ZkVuYWJsZSUyOGhhbmRsZSUyQyUyMGF1dG9CdWZJbmRleCUyOSUzQiUyMCUyRiUyRmFjdGl2YXRlJTIwdGhlJTIwYnVmZmVyJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIw"][vc_column_text][/vc_column_text][vc_column_text]

Scenario 2: Auto Transmit

Once again, to use the object buffers, you start with allocating a buffer with a call to canObjBufAllocate(). For an auto transmit buffer, call canObjBufSetPeriod() to set the frequency of the message, call canObjBufSetMsgCount() to set the number of messages to send from the buffer, and call canObjBufWrite() to define the contents of the message.

Example Code:

This code snippet set up a auto transmit buffer that sends a message with ID 300 with an interval of 1ms.[/vc_column_text][vc_code_raket language="csharp" code="JTJGJTJBJTIwU2V0JTIwdXAlMjBhbiUyMGF1dG8lMjB0cmFuc21pdCUyMGJ1ZmZlciUyMCUyQSUyRiUwQSUwQWJ5dGUlNUIlNUQlMjBtc2clMjAlM0QlMjAlN0IlMjAxJTJDJTIwMiUyQyUyMDMlMkMlMjA0JTJDJTIwNSUyQyUyMDYlMjAlN0QlM0IlMjAlMkYlMkZkZWZpbmUlMjBtZXNzYWdlJTBBaW50JTIwYXV0b0J1ZkluZGV4JTIwJTNEJTIwJTI4aW50JTI5JTI4Y2FuT2JqQnVmQWxsb2NhdGUlMjhoYW5kbGUlMkMlMjBjYW5PQkpCVUZfVFlQRV9BVVRPX1RSQU5TTUlUJTI5JTI5JTNCJTIwJTJGJTJGQWxsb2NhdGUlMjBidWZmZXIlMEFpbnQlMjBzdGF0dXMlM0IlMEFzdGF0dXMlMjAlM0QlMjBjYW5PYmpCdWZXcml0ZSUyOGhhbmRsZSUyQyUyMGF1dG9CdWZJbmRleCUyQyUyMDMwMCUyQyUyMG1zZyUyQyUyMDAlMkMlMjAwJTI5JTNCJTIwJTJGJTJGV3JpdGUlMjB0byUyMGJ1ZmZlciUwQXN0YXR1cyUyMCUzRCUyMGNhbk9iakJ1ZlNldFBlcmlvZCUyOGhhbmRsZSUyQyUyMGF1dG9CdWZJbmRleCUyQyUyMDEwMDAlMjklM0IlMjAlMkYlMkZTZXQlMjBwZXJpb2QlMjB0byUyMDEwMDAlMjBtaWNyb3NlY29uZHMlMEFzdGF0dXMlMjAlM0QlMjBjYW5saWJDTFNORVQuQ2FubGliLmNhbk9iakJ1ZkVuYWJsZSUyOGhhbmRsZSUyQyUyMGF1dG9CdWZJbmRleCUyOSUzQiUyMCUyRiUyRmFjdGl2YXRlJTIwdGhlJTIwYnVmZmVyJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIw"][vc_column_text][/vc_column_text][vc_column_text]

Which CAN interfaces has Object Buffers?

Hardware object buffers are available on our Professional products, and in general 8 buffers are available. Search Professional products >>[/vc_column_text][vc_column_text]

Comments?  Contact us directly at [email protected].

[/vc_column_text][/vc_column][/vc_row] [post_title] => Using Object Buffers [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => using-object-buffers [to_ping] => [pinged] => [post_modified] => 2022-10-04 13:37:57 [post_modified_gmt] => 2022-10-04 13:37:57 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=39876 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [2] => WP_Post Object ( [ID] => 39846 [post_author] => 14 [post_date] => 2015-04-14 09:26:20 [post_date_gmt] => 2015-04-14 09:26:20 [post_content] => [vc_row][vc_column][vc_message]This blog uses now deprecated functions, see blog "Improved API in Python canlib v1.5" for more information.[/vc_message][vc_column_text]This is the last post in a 3-part series about using Python with Kvaser products:
  1. Accessing Kvaser CANlib from Python
  2. Using Python to connect to your remote device
  3. A more object oriented approach on accessing your Kvaser device from Python
Earlier we have seen how to use the canlib.py and kvrlib.py wrappers in Python (currently for v2.7). However, those are primarily just "wrappers" and do not take into account the flexibility we get with an object oriented language as Python (this is equally true for other wrappers like C#). During testing, the focus is often on a specific device instead of the channel centered CANlib. This is especially true when you are dealing with remote devices such as Kvaser BlackBird v2 and Ethercan that tend to turn up on new CANlib channels when connected remotely. This is now taken care of via the new Python module kvDevice. To open a specific device, supply the EAN and serial number as shown below.[/vc_column_text][vc_code_raket language="python" header="Accessing a device using kvDevice.py." code="aW1wb3J0JTIwb3MlMEFpbXBvcnQlMjBzeXMlMEFzeXMucGF0aC5hcHBlbmQlMjglMjJDJTNBJTJGdGVtcCUyRkNhbmxpYl9TREtfdjUuOSUyRlNhbXBsZXMlMkZQeXRob24lMjIlMjklMEElMEFpbXBvcnQlMjBrdkRldmljZSUwQSUwQWRldmljZSUyMCUzRCUyMGt2RGV2aWNlLmt2RGV2aWNlJTI4ZWFuJTNEJTIyNzMtMzAxMzAtMDA3NzgtOSUyMiUyQyUyMHNlcmlhbCUzRDEwMjMlMjklMEFwcmludCUyMCUyMiU1Q24lMjIlMkMlMjBkZXZpY2UlMEE="][vc_column_text]If we have a device with EAN and serial number that matches we get the following output:[/vc_column_text][vc_code_raket language="clike" code="RGV2aWNlJTNBJTIwS3Zhc2VyJTIwTWVtb3JhdG9yJTIwUHJvJTIwNXhIUyUyMCUyOGNoYW5uZWwlMjAwJTI5JTBBRUFOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwNzMtMzAxMzAtMDA3NzgtOSUwQVMlMkZOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwMTAyMyUwQUZXJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwdjIuNS4yODclMEFDYXJkJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwMSUwQURydiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMGtjYW55MWElMEFDYW5saWIlMjBjaGFubmVsJTNBJTIwMw=="][vc_column_text]If we do not specify the serial number, we get the first device that matches the EAN. It is also possible to specify a CANlib channel directly.[/vc_column_text][vc_code_raket language="python" header="Accessing a device using only EAN or CANlib channel." code="ZGV2aWNlJTIwJTNEJTIwa3ZEZXZpY2Uua3ZEZXZpY2UlMjhlYW4lM0QlMjI3My0zMDEzMC0wMDc3OC05JTIyJTI5JTBBcHJpbnQlMjAlMjIlNUNuJTIyJTJDJTIwZGV2aWNlJTBBJTBBZGV2aWNlJTIwJTNEJTIwa3ZEZXZpY2Uua3ZEZXZpY2UlMjhjaCUzRDYlMjklMEFwcmludCUyMCUyMiU1Q24lMjIlMkMlMjBkZXZpY2U="][vc_code_raket language="clike" code="RGV2aWNlJTNBJTIwS3Zhc2VyJTIwTWVtb3JhdG9yJTIwUHJvJTIwNXhIUyUyMCUyOGNoYW5uZWwlMjAwJTI5JTBBRUFOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwNzMtMzAxMzAtMDA3NzgtOSUwQVMlMkZOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwMTAyMyUwQUZXJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwdjIuNS4yODclMEFDYXJkJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwMSUwQURydiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMGtjYW55MWElMEFDYW5saWIlMjBjaGFubmVsJTNBJTIwMiUwQSUwQURldmljZSUzQSUyMEt2YXNlciUyME1lbW9yYXRvciUyMFBybyUyMDV4SFMlMjAlMjhjaGFubmVsJTIwNCUyOSUwQUVBTiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMDczLTMwMTMwLTAwNzc4LTklMEFTJTJGTiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMDEwMjMlMEFGVyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMHYyLjUuMjg3JTBBQ2FyZCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMDElMEFEcnYlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlM0ElMjBrY2FueTFlJTBBQ2FubGliJTIwY2hhbm5lbCUzQSUyMDYlMEE="][vc_column_text]As a final example, if the specified device is not found, we still get a device returned but we do not get any information about it.[/vc_column_text][vc_code_raket language="python" header="Example of accessing a device using kvDevice.py." code="ZGV2aWNlcyUyMCUzRCUyMGt2RGV2aWNlLmt2RGV2aWNlLmFsbERldmljZXMlMjglMjklMEFwcmludCUyMCUyMkxpc3QlMjBhbGwlMjAlMjVkJTIwZGV2aWNlcyUyMiUyMCUyNSUyMCUyOGxlbiUyOGRldmljZXMlMjklMjklMEFmb3IlMjBkZXYlMjBpbiUyMGRldmljZXMlM0ElMEFwcmludCUyMCUyMiU1Q24lMjIlMkMlMjBkZXYlMEElMEFwcmludCUyMCUyMiU1Q24tLS0lNUNuVHJ5JTIwYW5kJTIwZmluZCUyMGElMjBub24tZXhpc3RpbmclMjBkZXZpY2UuJTIyJTBBZGV2aWNlJTIwJTNEJTIwa3ZEZXZpY2Uua3ZEZXZpY2UlMjhlYW4lM0QlMjI3My0zMDEzMC0wMDc3OC05JTIyJTJDJTIwc2VyaWFsJTNEMTAwJTI5JTBBcHJpbnQlMjA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MGZpbmQlMjBhJTIwbm9uLWV4aXN0aW5nJTIwZGV2aWNlLiUwQSUwQURldmljZSUzQSUyME5vbmUlMEFFQU4lMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlM0ElMjA3My0zMDEzMC0wMDc3OC05JTBBUyUyRk4lMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlM0ElMjAxMDAlMEFGVyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyME5vbmUlMEFDYXJkJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwTm9uZSUwQURydiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyME5vbmUlMEFDYW5saWIlMjBjaGFubmVsJTNBJTIwTm9uZSUwQQ=="][vc_column_text]If you take a look inside the module kvDevice.py, you'll notice that most of the attributes are stored in names starting with an underscore (_driver, _channel and so on). This tries to denote that these values are the last known values. (In Python, a leading underscore is normally a weak "internal use" indicator.) That is, the device could now have been removed and perhaps also reinserted and thus got renumbered, but the last time the device was opened via kvDevice.py, it was found using those values. (The device was found on CANlib channel _channel using the driver name _driver.) Hopefully, this overview of how Python can be used to help manage Kvaser devices will help you to be even more productive in your role as a developer. EDIT 2015-05-22: Stated that the current wrappers are written for Python v2.7.[/vc_column_text][vc_column_text]

Comments?  Contact us directly at [email protected].

[/vc_column_text][/vc_column][/vc_row] [post_title] => A more object oriented approach on accessing your Kvaser device from Python (3 of 3) [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => object-oriented-approach-accessing-kvaser-device-python-3-3 [to_ping] => [pinged] => [post_modified] => 2022-11-18 22:54:20 [post_modified_gmt] => 2022-11-18 22:54:20 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=39846 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [3] => WP_Post Object ( [ID] => 39878 [post_author] => 14 [post_date] => 2015-04-08 13:40:42 [post_date_gmt] => 2015-04-08 13:40:42 [post_content] => [vc_row][vc_column][vc_message]This blog uses now deprecated functions, see blog "Improved API in Python canlib v1.5" for more information.[/vc_message][vc_column_text]This is the second post in a 3-part series about using Python with Kvaser products:
  1. Accessing Kvaser CANlib from Python
  2. Using Python to connect to your remote device
  3. A more object oriented approach on accessing your Kvaser device from Python
[/vc_column_text][vc_column_text]Last time I mentioned that kvrlib also has a Python v2.7 wrapper included in the Kvaser CANlib SDK and I thought we could take a quick look at this as well. The kvrlib library is used to handle remote devices, such as the Blackbird and Ethercan devices. We will try some discovery and configuration in the following two examples. First let us use the discovery functions to scan and connect to a remote device. Our remote device has serial number 16 and is already connected to the same network as our computer:[/vc_column_text][vc_code_raket language="python" header="Example of using the Python kvrlib wrapper for scanning." code="aW1wb3J0JTIwc3lzJTBBc3lzLnBhdGguYXBwZW5kJTI4JTIyQyUzQSUyRnRlbXAlMkZDYW5saWJfU0RLX3Y1LjklMkZTYW1wbGVzJTJGUHl0aG9uJTIyJTI5JTBBJTBBaW1wb3J0JTIwa3ZybGliJTBBJTBBa2wlMjAlM0QlMjBrdnJsaWIua3ZybGliJTI4JTI5JTBBcHJpbnQlMjAlMjJrdnJsaWIlMjB2ZXJzaW9uJTNBJTIwJTI1cyUyMiUyMCUyNSUyMGtsLmdldFZlcnNpb24lMjglMjklMEElMEFzZXJpYWxObyUyMCUzRCUyMDE2JTBBcHJpbnQlMjAlMjJDb25uZWN0aW5nJTIwdG8lMjBkZXZpY2UlMjB3aXRoJTIwc2VyaWFsJTIwbnVtYmVyJTIwJTI1cyUyMiUyMCUyNSUyMHNlcmlhbE5vJTBBYWRkcmVzc0xpc3QlMjAlM0QlMjBrdnJsaWIua3ZyRGlzY292ZXJ5LmdldERlZmF1bHRBZGRyZXNzZXMlMjhrdnJsaWIua3ZyQWRkcmVzc1R5cGVGbGFnX0JST0FE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jAlMjAlMjBwcmludCUyMCUyN0Nvbm5lY3RpbmclMjB0byUyMHRoZSUyMGZvbGxvd2luZyUyMGRldmljZSUzQSUyNyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByaW50JTIwJTI3LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tJTI3JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJpbnQlMjBkZXZpY2VJbmZvJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZGlzY292ZXJ5LnN0b3JlRGV2aWNlcyUyOGRldmljZUluZm9zJTI5JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYnJlYWslM0IlMEFkaXNjb3ZlcnkuY2xvc2UlMjglMjklMEFrbC51bmxvYWQlMjglMjk="][vc_column_text]You should really set the envar PYTHONPATH before calling your script instead of appending to the sys.path (as seen on line 2). Note also that the Python wrappers are usually quite helpful when printing resulting variables. This means that you could uncomment line 13 and line 22 and get a human readable output. The above code gives the following output:[/vc_column_text][vc_code_raket language="clike" code="a3ZybGliJTIwdmVyc2lvbiUzQSUyMDguOSUwQUNvbm5lY3RpbmclMjB0byUyMGRldmljZSUyMHdpdGglMjBzZXJpYWwlMjBudW1iZXIlMjAxNiUwQUZvdW5kJTIwNCUyMGFkZHJlc3Nlcy4lMEFTY2FubmluZyUyMGRldmljZXMuLi4lMEElMEFDb25uZWN0aW5nJTIwdG8lMjB0aGUlMjBmb2xsb3dpbmclMjBkZXZpY2UlM0ElMEEtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lMEFuYW1lJTJGaG9zdG5hbWUlMjAlMjAlM0ElMjAlMjJLdmFzZXIlMjBSZW1vdGUlMjAlMjMxNiUyMiUyMCUyRiUyMCUyMmt2LTA3MTMwLTAwMDAxNiUyMiUwQSUyMCUyMGVhbiUyRnNlcmlhbCUyMCUyMCUyMCUzQSUyMDczMzAxLTMwMDA3MTMwJTIwJTJGJTIwMTYlMEElMjAlMjBmdyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMDIuNC4xMjYlMEElMjAlMjBhZGRyJTJGY2xpJTJGQVAlMjAlMjAlM0ElMjAxMC4wLjMuMzIlMjAlMjhJUFY0JTI5JTIwJTJGJTIwMTAuMC4zLjI3JTIwJTI4SVBWNCUyOSUyMCUyRiUyMHVua25vd24lMjAlMjhVTktOT1dOJTI5JTBBJTIwJTIwdXNhZ2UlMkZhY2Nlc3MlMjAlM0ElMjBGUkVFJTIwJTJGJTIwUFVCTElDJTBBJTIwJTIwcGFzcyUyRmVuYy5rZXklMjAlM0ElMjBubyUyMCUyRiUyMG5v"][vc_column_text]Now let us do some minimal configuration on the device, why not change the device name? The remote device has now turned up on CANlib channel 0 (line 6), let us set the device name to "MrKvaser" (line 7).[/vc_column_text][vc_code_raket language="python" header="Example of setting device name on a remote device." code="aW1wb3J0JTIwc3lzJTBBc3lzLnBhdGguYXBwZW5kJTI4JTIyQyUzQSUyRnRlbXAlMkZDYW5saWJfU0RLX3Y1LjklMkZTYW1wbGVzJTJGUHl0aG9uJTIyJTI5JTBBJTBBaW1wb3J0JTIwa3ZybGliJTBBJTBBY2FuQ2hhbm5lbCUyMCUzRCUyMDAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMEFkZXZpY2VOYW1lJTIwJTNEJTIwJTIyTXJLdmFzZXIlMjIlMjAlMjAlMjAlMEElMEFrbCUyMCUzRCUyMGt2cmxpYi5rdnJsaWIlMjglMjklMEFwcmludCUyMCUyMkNvbmZpZ3VyYXRpbmclMjBkZXZpY2UlMjBvbiUyMGNoYW5uZWwlMjAlMjVkLiUyMiUyMCUyNSUyMGNhbkNoYW5uZWwlMEF0cnklM0ElMEElMjAlMjAlMjAlMjBjb25maWclMjAlM0QlMjBrbC5jb25maWdPcGVuJTI4Y2hh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start by opening the configuration in read/write mode on line 12, then reads in the existing configuration on line 13. After printing the whole XML configuration on line 14 we manipulate the device name element before writing it back to the device on line 18. This results in the following being printed on the console:[/vc_column_text][vc_code_raket language="clike" code="Q29uZmlndXJhdGluZyUyMGRldmljZSUyMG9uJTIwY2hhbm5lbCUyMDAuJTBBQ3VycmVudCUyMGRldmljZSUyMGNvbmZpZ3VyYXRpb24lM0ElMEElM0MlM0Z4bWwlMjB2ZXJzaW9uJTNEJTIyMS4wJTIyJTIwJTNGJTNFJTNDS1ZBU0VSJTNFJTBBJTNDVkVSU0lPTiUzRTQuMyUzQyUyRlZFUlNJT04lM0UlMEElM0NQUk9EVUNURkFNSUxZJTNFZXRoZXJjYW4lM0MlMkZQUk9EVUNURkFNSUxZJTNFJTBBJTNDREVWSUNFX0FDQ0VTUyUyMGxldmVsJTNEJTIyUFVCTElDJTIyJTIwcGFzc3dvcmQlM0QlMjIlMjIlMkYlM0UlMEElM0NDT05GSUdfUFJPVEVDVElPTiUyMHBhc3N3b3JkJTNEJTIyJTIyJTIwcHJvdGVjdGVkJTNEJTIyTk8lMjIlMkYlM0UlMEElM0NORVRXT1JLJTIwYWRkcmVzc190eXBlJTNEJTIyREhDUCUyMiUyMGRldmljZV9uYW1lJTNEJTIyS3Zhc2VyJTIwUmVtb3RlJTIwJTIzMTYlMjIlMjBob3N0X25hbWUlM0QlMjJrdi0wNzEzMC0wMDAwMTYlMjIlMjBtdHUlM0QlMjIxNDkyJTIyJTIwcG9ydCUzRCUyMjExNDE2JTIyJTJGJTNFJTBBJTNDUFJPRklMRV9JTkZPJTIwbmFtZSUzRCUyMlVubmFtZWQlMjBQcm9maWxlJTIyJTJGJTNFJTBBJTNDVFJBRkZJQ19FTkNSWVBUSU9OJTIwa2V5JTNEJTIyJTIyJTIwdHlwZSUzRCUyMk5PTkUlMjIlMkYlM0UlMEElM0NXRUJTRVJWRVIlMjBjaGFuZ2VfbG9nX3NldHRpbmdzJTNEJTIyTk8lMjIlMjBkZWJ1Z19jb21tYW5kcyUzRCUyMk5PJTIyJTIwZW5hYmxlZCUzRCUyMk5PJTIyJTIwdXNlcl9kYXRhX2Rvd25sb2FkJTNEJTIyTk8lMjIlMkYlM0UlMEElM0MlMkZLVkFTRVIlM0UlMEFEZXZpY2UlMjBuYW1lJTIwd2FzJTIwJTI3S3Zhc2VyJTIwUmVtb3RlJTIwJTIzMTYlMjclMEFTZXR0aW5nJTIwbmV3JTIwZGV2aWNlJTIwbmFtZSUyMCUyN01yS3Zhc2VyJTI3"][vc_column_text]The XML configuration that we get from the device can be manipulated using built-in Python XML support as can be seen on line 14 and line 17. You can find the full description of the XML used during configuration in the document Specification of Kvaser Remote Device Configuration XML Format on the download page. Just one more thing, do we really need to "know" that the device will turn up on CANlib channel 0 (at line 6)? Let us fix that in the next post... EDIT 2015-05-22: Stated that the current wrappers are written for Python v2.7.[/vc_column_text][vc_column_text]

Comments?  Contact us directly at [email protected].

[/vc_column_text][/vc_column][/vc_row] [post_title] => Using Python to connect to your remote device (2 of 3) [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => using-python-connect-remote-device-2-3 [to_ping] => [pinged] => [post_modified] => 2022-11-18 22:57:17 [post_modified_gmt] => 2022-11-18 22:57:17 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=39878 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [4] => WP_Post Object ( [ID] => 39843 [post_author] => 14 [post_date] => 2015-04-01 08:51:16 [post_date_gmt] => 2015-04-01 08:51:16 [post_content] => [vc_row][vc_column][vc_message]This blog uses now deprecated functions, see blog "Improved API in Python canlib v1.5" for more information.[/vc_message][vc_column_text css=".vc_custom_1432272939969{padding-top: 10px !important;padding-bottom: 5px !important;padding-left: 10px !important;background-color: #f4f4f4 !important;}"]This is the first post in a 3-part series about using Python with Kvaser products:
  1. Accessing Kvaser CANlib from Python
  2. Using Python to connect to your remote device
  3. A more object oriented approach on accessing your Kvaser device from Python
[/vc_column_text][vc_column_text]Did you know that you can access Kvaser CANlib from Python? There have been Python wrappers for CANlib included in the Kvaser CANlib SDK for a while now, but recently they have gotten an overhaul and more libraries and functions are wrapped as we speak. Currently the wrappers is only tested in Python v2.7 and is not compatible with Python v3. The latest released version of SDK can be found on www.kvaser.com/download/ (Current version is v 5.9 (released 2015-03-17). Be sure to install the SDK to a place where you have write permissions if you plan to edit the samples directly. (The default C:\Program Files (x86)\Kvaser\Canlib\ is usually not the ideal place. As you can see below, today I chose a sub-directory of C:\temp\.) The downloaded Python sample directory now includes wrappers for both CANlib and kvrlib. To get an idea of how to use them, see the bottom of each wrapper file. E.g. the canlib.py can be used as seen below.[/vc_column_text][vc_code_raket language="python" header="Example of using the Python CANlib wrapper." code="aW1wb3J0JTIwc3lzJTBBc3lzLnBhdGguYXBwZW5kJTI4JTIyQyUzQSUyRnRlbXAlMkZDYW5saWJfU0RLX3Y1LjklMkZTYW1wbGVzJTJGUHl0aG9uJTIyJTI5JTBBJTBBaW1wb3J0JTIwY2FubGliJTBBJTBBY2wlMjAlM0QlMjBjYW5saWIuY2FubGliJTI4JTI5JTBBcHJpbnQlMjAlMjJjYW5saWIlMjB2ZXJzaW9uJTNBJTIwJTI1cyUyMiUyMCUyNSUyMGNsLmdldFZlcnNpb24lMjglMjklMEElMEFjaGFubmVsJTIwJTNEJTIwMCUwQWhhbmRsZTElMjAlM0QlMjBjbC5vcGVuQ2hhbm5lbCUyOGNoYW5uZWwlMkMlMjBjYW5saWIuY2FuT1BFTl9BQ0NFUFRfVklSVFVBTCUyOSUwQXByaW50JTIwJTIyVXNpbmclMjBjaGFubmVsJTNBJTIwJTI1cyUyQyUyMEVBTiUzQSUyMCUyNXMlMjIlMjAlMjUlMjAlMjhoYW5kbGUxLmdldENoYW5uZWxEYXRhX05hbWUlMjglMjklMkMlMEFoYW5kbGUxLmdldENoYW5uZWxEYXRhX0VBTiUyOCUyOSUyOSUwQSUwQWhhbmRsZTEuc2V0QnVzT3V0cHV0Q29udHJvbCUyOGNhbmxpYi5jYW5EUklWRVJfTk9STUFMJTI5JTBBaGFuZGxlMS5zZXRCdXNQYXJhbXMlMjhjYW5saWIuY2FuQklUUkFURV8xTSUyOSUwQWhhbmRsZTEuYnVzT24lMjglMjk="][vc_column_text]Running the above code results in the following printout. canlib version: 8.9 Using channel: Kvaser Ethercan Light HS (Remote) (channel 0), EAN: 73-30130-00713-0[/vc_column_text][vc_column_text]As veteran users of CANlib knows, the version number of canlib.dll that is printed (8.9), is not identical to the version number of the CANlib package (v5.9). Appending of the variable sys.path (as seen on line 2) is one way to make the module accessible from Python, a more conventional way is to set the Environment variable PYTHONPATH before calling your script. The Python wrapper uses ctypes to interface with Kvaser CANlib. This is a foreign function library for Python that provides C compatible data types and allows calling functions in DLLs or shared libraries. This means that it would also be possible to use these samples on Linux (but since kvrlib not yet is ported to Linux it is currently limited to CANlib). In the next post, we will see how to connect to remote devices with Python... EDIT 2015-05-22: Stated that the current wrappers are written for Python v2.7.[/vc_column_text][vc_column_text]

Comments?  Contact us directly at [email protected].

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][/vc_column][/vc_row] [post_title] => [Archive] Accessing Kvaser CANlib from Python (1 of 3) [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => archive-accessing-kvaser-canlib-python-1-3 [to_ping] => [pinged] => [post_modified] => 2022-12-21 23:38:00 [post_modified_gmt] => 2022-12-21 23:38:00 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=39843 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [5] => WP_Post Object ( [ID] => 7189 [post_author] => 5 [post_date] => 2015-03-16 08:00:10 [post_date_gmt] => 2015-03-16 08:00:10 [post_content] => French car manufacturer Renault has created a prototype called NEXT TWO that will be used as basis for the development of its next generation autonomous, connected vehicles. With human error considered to be the leading cause of 90% of road accidents, autonomous driving and connected car technologies are seen as the next step towards enhancing automotive safety. By delegating driving to the car itself, the driver and other car occupants will experience a new form of mobility: the car will become a mobile office or lounge, with the driver and other occupants able to engage in video-conferencing, watch a movie or shop online. For the Next Two cockpit, FAAR Industry provided a custom system control solution that connects the Infotainment Platform to the autonomous vehicle’s CAN and LIN buses. USB 2.0 to CAN and LIN interfaces from Kvaser assured data transfer from various sensors to an Infotainment industrial PC (temperature, air conditioning, steering wheel control commands). Our interfaces are also responsible for sharing information throughout the system and managing display parameters (such as brightness or power on). Specifically, Renault has used the Kvaser Leaf Light Rugged HS, Kvaser Leaf Professional LIN and Kvaser USBcan Professional HS/HS. FAAR Industry implemented Kvaser’s Linux libraries to provide diagnostic capabilities for all components connected wired and wirelessly, and used its own EASY CAN software tool to send, record and analyse CAN data simply. Based on the electric car Renault ZOE, the Next Two could be ready for mass production and large scale commercialization by 2020.   Renault Next Two inside in autonomous active mode Watch the Next Two prototype presentation Video by Carlos Ghosn here [post_title] => Kvaser interfaces deployed by Faar Industry in Renault’s NEXT TWO project [post_excerpt] => French car manufacturer Renault has created a prototype called NEXT TWO that will be used as basis for the development of its next generation autonomous, connected vehicles. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvaser-interfaces-deployed-renaults-next-two-project [to_ping] => [pinged] => [post_modified] => 2022-12-22 00:51:43 [post_modified_gmt] => 2022-12-22 00:51:43 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=7189 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [6] => WP_Post Object ( [ID] => 7374 [post_author] => 5 [post_date] => 2015-03-12 10:03:56 [post_date_gmt] => 2015-03-12 10:03:56 [post_content] => Kvaser will be participating in several CAN FD Tech Days in the US in 2015. Come along to hear about the latest CAN FD developments, answer your CAN FD questions, exchange views and network with CAN FD experts. The events are as follows: CAN FD Tech Day Detroit  – 25th March 2015 Venue: GM Heritage Center, 6400 Center Drive, Sterling Heights, MI 48312 Of special interest: The Detroit event will be preceded by a CAN FD plug fest, allowing participants to test CAN FD products in development – both ISO CAN FD and non-ISO CAN FD. CAN FD Tech Day San Jose – 16th June 2015 Venue: The Sainte Claire, 302 S Market St., US-San Jose, 95113 Of special interest: CANopen FD. Presentations on this next generation data link layer and its impacts on system design and higher-layer protocols are part of this event. CAN FD Tech Day Chicago / CiA Off-Highway Tech Day – 18th June Venue: DoubleTree by Hilton Chicago-Schaumburg, 800 National Parkway, US-Schaumburg, IL 60173 Of special interest: This event will focus on mobile machine control, but CAN FD topics will also be discussed. At each of the above events, Kvaser’s hardware manager, Kent Lennartsson, will present a paper entitled ‘Physical layer filter and diagnostics for CAN FD’, and you’ll be able to see Kvaser’s CAN FD demonstrator in the tabletop exhibit. For more information and to register for any of the above events, please visit www.can-cia.org   [post_title] => CAN FD Tech Days in Detroit, San Jose and Chicago, USA [post_excerpt] => Come along to hear about the latest CAN FD developments, answer your CAN FD questions, exchange views and network with CAN FD experts. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => can-fd-tech-days-detroit-san-jose-chicago-usa [to_ping] => [pinged] => [post_modified] => 2022-09-29 04:14:13 [post_modified_gmt] => 2022-09-29 04:14:13 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=7374 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [7] => WP_Post Object ( [ID] => 7303 [post_author] => 5 [post_date] => 2015-03-05 08:04:19 [post_date_gmt] => 2015-03-05 08:04:19 [post_content] => With 3 female and 1 male D-SUB9 connectors, the Kvaser T-cannector v2 is a hub/splitter that provides adjustable CAN termination and an external power source to the network. Connect multiple CAN interfaces, dataloggers and/or multiple CAN channels together quickly and easily with the T-cannector v2, without the risk of creating short circuits or time spent from wiring them together yourself. The adjustable CAN termination resistor (120/60/0 Ohm) on the the T-cannector v2 provides an effective and safe way of terminating the CAN circuit, and the external power capability is ideal for powering devices that take their power from the CAN network to which they are attached, such as Kvaser’s Blackbird and Memorator series. With the launch of this product, Kvaser underlines its commitment to providing extremely price-competitive, easy-to-use tools that allow engineers to start gathering CAN data within minutes. Use cases include pairing the T-cannector v2 with Kvaser’s OBD II to DSUB9 Adapter Cable (00723-9) to connect multiple CAN dataloggers to just one ODBII diagnostic port, or combining it with Kvaser’s free CanKing CAN bus monitor software to perform loop back tests on CAN channels. 00776-5_v01.00.000_PICTUR_5-720x480   To find out more, visit the T-cannector v2 product page [post_title] => Kvaser introduces the T-cannector v2 CAN hub [post_excerpt] => With 3 female and 1 male D-SUB9 connectors, the Kvaser T-cannector V2 is a hub/splitter that provides adjustable CAN termination and an external power source to the network. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvaser-introduces-t-cannector-v2-can-hub [to_ping] => [pinged] => [post_modified] => 2022-09-29 04:14:12 [post_modified_gmt] => 2022-09-29 04:14:12 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=7303 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [8] => WP_Post Object ( [ID] => 7212 [post_author] => 5 [post_date] => 2015-03-02 13:58:34 [post_date_gmt] => 2015-03-02 13:58:34 [post_content] => QSR Profile: AutonomouStuff_edit Bobby Hambrick’s background is as an automation engineer. It was whilst working on industrial robotic projects that he recognised the potential of the emerging market in autonomous systems. What exactly is an autonomous system? Says Bobby: “It’s a valid question as these systems span both industrial automation and mobility sectors, as a result of which, both are being redefined.” Autonomous systems are ostensibly robots that can perform tasks without human guidance and they are being developed for use in just about every environment on earth and beyond. So far they have been or are soon to be deployed in harvesting, snow grooming, haulage, airborne, the marine sector and more. ‘Low hanging fruit’ include applications such as mining where there is pressure to increase efficiency and throughput, yet where tasks often have a high degree of repeatability. Defence applications were also an early area of research focus: autonomous convoys have long been envisaged as a way of avoiding casualties from detonating IEDs. AutonomouStuff – a company that Hambrick founded in March 2010 – sells products and services to the autonomous system market. Explains Hambrick:
“The company’s mission is to help make our customers successful, by making it easy to source all of the perception, computing, GPS, and interface components necessary for their projects.”
Typically, this technology is difficult to access today, unless you are interested in ordering 100s or 1000s of units at a time. Sourcing one or two radar units for research purposes is often impossible, which is where AutonomouStuff’s buying power comes in. Says Hambrick: “A large gap in the supply-chain in this sector means we already have customers in every major developing country, creating economies of scale for this type of very specialized equipment.” However, the company also supplies an ever broadening array of more easily located hardware, such as rugged computers, enclosures, actuation and Kvaser’s interface tools, as customers increasingly want to deal with a single supplier. Reliable support is key Key to AutonomouStuff’s business model is a commitment to bringing together the World’s best technology that is well supported. Notes Hambrick: “Our unique position in the market is due partly to our focus on recruiting talented support engineers that are knowledgeable in these technologies and can help customers apply them in non-traditional ways.” Prior to signing up as a qualified sales representative for Kvaser, the company worked with a Kvaser competitor but became frustrated at their ‘unreliable support’. Since switching to Kvaser’s interface portfolio, Hambrick’s customers have benefited from “more competitive pricing, better functionality and technology in general, and committed support”. The automotive sector is one of the most buoyant within the autonomous systems industry as a whole. “With tens of thousands of lives lost annually on US roads alone, every innovative automotive OEM is looking towards providing some level of automation, be it obstacle detection, intersection safety, collision avoidance, and/or full autonomous driving,” says Hambrick. It’s therefore no surprise that CAN has a valuable role to play. He explains: “Autonomous systems need to be highly reliable and have clearly defined system architecture, which is why CAN is popular. While there are plenty of other interface buses in use – particularly as high bandwidth is a typical requirement – they all have pros and cons, and CAN is mostly used at the sensor level.” He concludes:
“Kvaser is customer focused and continuously introducing new products that support the development of autonomous systems. Take the USBcan Light 2xHS for example, it provides a very compact and extremely cost effective solution that enables a single USB connection to two CAN channels. AutonomouStuff is proud to be partnered with Kvaser and looks forward to providing customer solutions together.”
To contact AutonomouStuff, please follow this link [post_title] => Kvaser supports emerging autonomous systems market [post_excerpt] => Bobby Hambrick’s background is as an automation engineer. It was whilst working on industrial robotic projects that he recognised the potential of the emerging market in autonomous systems. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvaser-supports-emerging-autonomous-systems-market [to_ping] => [pinged] => [post_modified] => 2022-09-29 04:14:12 [post_modified_gmt] => 2022-09-29 04:14:12 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=7212 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [9] => WP_Post Object ( [ID] => 7015 [post_author] => 22955 [post_date] => 2015-02-01 15:29:57 [post_date_gmt] => 2015-02-01 15:29:57 [post_content] => [vc_row][vc_column][vc_single_image image="40644" img_size="full"][vc_column_text]2nd February 2015 - Kvaser AB has introduced a 5 channel high-speed controller area network (CAN) to USB interface and datalogger that allows users to monitor and log data from multiple CAN channels using just one device. The Kvaser Memorator Pro 5xHS not only time synchronises the data transmitted and received across all five buses but also automatically synchronises with other Kvaser interfaces connected to the same PC, resulting in simpler, more accurate multichannel data capture. The Kvaser Memorator Pro 5xHS has a 26 pin HD DSUB that connects to a splitter with five 9 pin DSUBs, and one USB connector that easily links to any USB port on a host computer. Only one USB port needs to be allocated when monitoring multiple CAN buses, reducing the need for an external hub in many applications.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/4"][vc_single_image image="40645" img_size="full"][/vc_column][vc_column width="1/4"][vc_single_image image="40646" img_size="full"][/vc_column][vc_column width="1/4"][vc_single_image image="40647" img_size="full"][/vc_column][vc_column width="1/4"][vc_single_image image="40648" img_size="full"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

A special feature of the 5-channel Memorator Professional is its ability to run user-developed scripts. Like Kvaser’s Eagle interface and datalogger, the Memorator Pro 5xHS’s script functionality allows users to develop highly customised applications written in the Kvaser t programming language, such as CAN protocol converters, CAN gateways and advanced CAN logging functionality. Application-specific scripts for this device will also be available from Kvaser’s network of technical associates, who all have different domain expertise. As such, this device is designed to appeal to engineers in industries as broad ranging as automotive development, machine control and industrial network connectivity.

Commented Lars-Berno Fredriksson, president of Kvaser AB: “A five channel combined interface and datalogger in Kvaser’s trademark form factor is a first for the industry. It transforms the task of multiple CAN channel data gathering, making the process easier and quicker for engineers and the process more robust.”

Martin Sventén, General Manager at Accurate Technologies AB notes: “New engines typically undergo rigorous performance and durability testing on a dynamometer rig for days at a time. Typically, multiple CAN channels monitor all parameters, but interfacing with them can mean a rat’s nest of cabling at the dyno or indeed, during in-vehicle testing. This product decreases cabling complexity and frees up USB ports on the PC. The datalogging capability means that results from up to five CAN channels are recorded on one card, thus avoiding the difficult situation of trying to combine logfiles from two or three different memory cards.”

When connected to the host computer, the Memorator Pro 5xHS is automatically in interface mode and when connected only to CAN, it is in datalogger mode. Power is derived from the USB connection, CAN and an in-built power supply.

The Kvaser Memorator Pro 5xHS is compatible with J1939, CANopen, NMEA 2000® and DeviceNet, and will also be CAN FD upgradeable via firmware. It is supported in newer versions of CANLIB and Kvaser Memorator Config Tool software.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_text_separator title="Videos"][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_video link="https://www.youtube.com/watch?v=HJr0RnXKXKY" title="Memorator Professional Quick Start Guide"][/vc_column][vc_column width="1/2"][vc_video link="https://www.youtube.com/watch?v=oYG9rnHa2DE" title="Memorator Professional Advanced Setup"][/vc_column][/vc_row] [post_title] => Industry’s First 5-channel Programmable Interface and Datalogger [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => industry-first-5-channel-programmable-interface-datalogger [to_ping] => [pinged] => [post_modified] => 2023-01-10 10:46:18 [post_modified_gmt] => 2023-01-10 10:46:18 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=7015 [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] => 39877 [post_author] => 14 [post_date] => 2015-04-29 13:38:30 [post_date_gmt] => 2015-04-29 13:38:30 [post_content] => [vc_row disable_element="yes"][vc_column][vc_column_text]
This is the first part of a series.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]The new Kvaser Pro products have script feature called t. The t language is a 'c like', event oriented language. The t-programs run on the device and can be loaded and started either from a pc or autonomously on the device. This is a short introduction to get started with t programming.[/vc_column_text][vc_column_text]To be able to test and run a t program you need a Kvaser Pro product. The software needed is installed with CANlib SDK and called Kvaser TRX.[/vc_column_text][/vc_column][vc_column width="1/2"][vc_column_text]can bus tutorial[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]To get up and running and write your first t program, start by downloading and installing CANlib SDK (Download) then start TRX.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]It will look something like this:image1 In the <New> tab enter:[/vc_column_text][vc_code_raket code="b24lMjBzdGFydCUyMCU3QiUwQSUyMCUyMHByaW50ZiUyOCUyMkhlbGxvJTIwV29ybGQlMjElNUNuJTIyJTI5JTNCJTBBJTdE"][vc_column_text]This a very basic program that reacts on an 'on start' event and prints "Hello World!" in the 'Device Output'. It is the actual device that sends the "Hello World!" to the computer and that TRX reads. Then choose Run->Compile from the menu. To be able to compile you first have to save the t program, TRX will prompt you for this, and it will also prompt you to save a project file. I saved it as blogpost1. If the compilation succedes the next step will require an actual Kvaser Pro product. I connected a Kvaser Memorator Pro 2xHS v2 (View Product). You can see that TRX can use your device if the combo box just under the menu bar has the name of your Kvaser device. To test the t program, just go to Run->Download, this will download the t program to the device. Next step will be to actually run the program. Run->Run will start he application, thus hopefully you will see the printf printout in the Device Output window. image2[/vc_column_text][vc_column_text][/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

Additional resources:

  • The description of the t language can be found in the The Kvaser t Programming Language specification (View).

[/vc_column_text][vc_column_text]

Comments?  Contact us directly at [email protected].

[/vc_column_text][/vc_column][/vc_row] [post_title] => Getting Started with t Programming [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => getting-started-with-t-programming [to_ping] => [pinged] => [post_modified] => 2022-10-04 13:40:17 [post_modified_gmt] => 2022-10-04 13:40:17 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=39877 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [comment_count] => 0 [current_comment] => -1 [found_posts] => 468 [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] => 85cca116a53eb0f755d3f1a9b114d066 [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

Getting Started with t Programming

29/04/2015

The new Kvaser Pro products have script feature called t. The t language is a ‘c like’, event oriented language.… Read More

Read More

Using Object Buffers

22/04/2015

Some of our interfaces are equipped with hardware buffers for automatic sending or responding to messages. They can be used… Read More

Read More

A more object oriented approach on accessing your Kvaser device from Python (3 of 3)

14/04/2015

This blog uses now deprecated functions, see blog “Improved API in Python canlib v1.5” for more information. This is the last post… Read More

Read More

Using Python to connect to your remote device (2 of 3)

08/04/2015

This blog uses now deprecated functions, see blog “Improved API in Python canlib v1.5” for more information. This is the second post… Read More

Read More

[Archive] Accessing Kvaser CANlib from Python (1 of 3)

01/04/2015

This blog uses now deprecated functions, see blog “Improved API in Python canlib v1.5” for more information. This is the first post… Read More

Read More
Kvaser interfaces deployed by Faar Industry in Renault’s NEXT TWO project

Kvaser interfaces deployed by Faar Industry in Renault’s NEXT TWO project

16/03/2015

French car manufacturer Renault has created a prototype called NEXT TWO that will be used as basis for the development… Read More

Read More

CAN FD Tech Days in Detroit, San Jose and Chicago, USA

12/03/2015

Kvaser will be participating in several CAN FD Tech Days in the US in 2015. Come along to hear about… Read More

Read More

Kvaser introduces the T-cannector v2 CAN hub

05/03/2015

With 3 female and 1 male D-SUB9 connectors, the Kvaser T-cannector v2 is a hub/splitter that provides adjustable CAN termination… Read More

Read More

Kvaser supports emerging autonomous systems market

02/03/2015

QSR Profile: Bobby Hambrick’s background is as an automation engineer. It was whilst working on industrial robotic projects that he… Read More

Read More

Industry’s First 5-channel Programmable Interface and Datalogger

01/02/2015

2nd February 2015 – Kvaser AB has introduced a 5 channel high-speed controller area network (CAN) to USB interface and… Read More

Read More