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

    [query_vars] => Array
        (
            [paged] => 28
            [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 270, 10
    [posts] => Array
        (
            [0] => WP_Post Object
                (
                    [ID] => 11506
                    [post_author] => 14
                    [post_date] => 2018-09-16 20:36:15
                    [post_date_gmt] => 2018-09-16 20:36:15
                    [post_content] => [vc_row el_class="indented"][vc_column][vc_column_text]This is the first post in a 4-part series about configuring and reading logged data using a Kvaser Memorator 2nd Generation device through kvmlib:[/vc_column_text][vc_column_text]

1 Getting started with kvmlib

2 Adding script and triggers to a configuration 3 Digging deeper into kvmlib 4 Configure an SD card using kvmlib [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]This first post will give an overview on how to configure the Kvaser device using Python. Part two adds some complexity to the configuration, while part three will go deeper and show how to use kvmlib at the C API level. The last part shows how to configure the device while only having access to the removable SD card. Full program listings are available on GitHub.[/vc_column_text][vc_header_raket header_type="h3" header="1.1 Introduction"][vc_column_text]Configuration of newer Kvaser Memorator devices are normally done using the Kvaser Memomorator Config Tool, which is a Windows GUI tool. But you may also configure these devices programmatically using the Kvaser Memorator library (kvmlib) which is part of the Kvaser CANlib SDK.1 Our device of choice today is the Kvaser Memorator Pro 5xHS2 which runs firmware version 3.113. We will also be using v1.6 of the Python canlib package and v5.23 of the Kvaser CANlib SDK, the latest versions are available from www.kvaser.com/download.[/vc_column_text][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="1.2 Initialize the SD card"][vc_column_text]It’s not enough to just format the SD card in our operating system’s file manager, we also need to initialize the SD card using our Kvaser Memorator device. After having inserted the SD card into our Kvaser Memorator device, we connect the Kvaser Memorator device to a free USB port on our computer and run our first bit of code to format the SD card.[/vc_column_text][vc_code_raket language="python" header="Listing 2: Connecting to a Kvaser device using the kvDevice module." code="JTIzJTIwMDFfaW5pdF9zZGNhcmQucHklMEFmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwRUFOJTBBZnJvbSUyMGNhbmxpYi5kZXZpY2UlMjBpbXBvcnQlMjBEZXZpY2UlMEFmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwa3ZtbGliJTBBJTBBJTIzJTIwRmluZCUyMG91ciUyMGNvbm5lY3RlZCUyMEt2YXNlciUyME1lbW9yYXRvciUyMFBybyUyMDV4SFMlMjB3aXRoJTIwRUFOJTIwNzMtMzAxMzAtMDA3NzgtOSUwQWVhbiUyMCUzRCUyMEVBTiUyOCUyNzczLTMwMTMwLTAwNzc4LTklMjclMjklMEFkZXYlMjAlM0QlMjBEZXZpY2UuZmluZCUyOGVhbiUzRGVhbiUyOSUwQSUwQSUyMyUyMEFzayUyMHRoZSUyMGRldmljZSUyMGZvciUyMHNvbWUlMjBpbmZvJTJDJTIwYW5kJTIwcHJpbnQlMjB0aGF0JTBBcHJpbnQlMjhkZXYucHJvYmVfaW5mbyUyOCUyOSUyOSUwQSUwQSUyMyUyME9wZW4lMjB0aGUlMjBtZW1vcmF0b3IlMjBmb3IlMjBjb25maWd1cmF0aW9uJTIwdXNpbmclMjB0aGUlMjBDQU5saWIlMjBjaGFubmVsJTIwbnVtYmVyJTIwd2UlMEElMjMlMjBmb3VuZCUyMGl0JTIwb24uJTIwVGhlJTIwTEVEJTIwd2lsbCUyMHN0YXJ0JTIwYSUyMHNsb3clMjAlMjJydW5uaW5nJTIwbGlnaHQlMjIlMjBpbmRpY2F0aW5nJTIwdGhhdCUwQSUyMyUyMGl0JTIwaXMlMjBvcGVuZWQlMjBmb3IlMjBjb25maWd1cmF0aW9uLiUwQSUwQSUyMyUyMFdlJTIwd2lsbCUyMHVzZSUyMGElMjBjb250ZXh0JTIwbWFuYWdlciUyMGluJTIwb3JkZXIlMjB0byUyMG1ha2UlMjBzdXJlJTIwdGhhdCUyMHdlJTIwY29ycmVjdGx5JTBBJTIzJTIwY2xvc2UlMjB0aGUlMjBpbnRlcm5hbCUyMG1lbW9yYXRvciUyMGhhbmRsZSUyMHdoZW4lMjB3ZSUyMGFyZSUyMGRvbmUuJTBBd2l0aCUyMGt2bWxpYi5vcGVuRGV2aWNlJTI4ZGV2LmNoYW5uZWxfbnVtYmVyJTI4JTI5JTI5JTIwYXMlMjBtZW1vJTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwSW5pdGlhbGl6ZSUyMHRoZSUyMFNEJTIwY2FyZCUyMHdpdGglMjBkZWZhdWx0JTIwdmFsdWVzLiUyMFRoZSUyMENBTiUyMExFRHMlMjB3aWxsJTIwZmxhc2glMEElMjAlMjAlMjAlMjAlMjMlMjBxdWlja2x5JTIwZHVyaW5nJTIwZGlzayUyMGluaXRpYWxpemF0aW9uLiUwQSUyMCUyMCUyMCUyMHByaW50JTI4JTI3Rm9ybWF0dGluZyUyMGRpc2suLi4lMjclMkMlMjBlbmQlM0QlMjclMjclMjklMEElMjAlMjAlMjAlMjBtZW1vLmZvcm1hdF9kaXNrJTI4JTI5JTBBJTIwJTIwJTIwJTIwcHJpbnQlMjglMjclMjBkb25lJTIxJTI3JTI5"][vc_column_text]

Listing 1: Initializing the SD card inside a Kvaser Memorator device.

[/vc_column_text][vc_column_text]When running this we can confirm that our device is indeed running firmware v3.11, and the device is currently connected to canlib channel 0.[/vc_column_text][vc_code_raket header="Listing 2: Connecting to a Kvaser device using the kvDevice module." code="Q0FObGliJTIwQ2hhbm5lbCUzQSUyMDAlMEFDYXJkJTIwTnVtYmVyJTIwJTIwJTIwJTNBJTIwMCUwQURldmljZSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMEt2YXNlciUyME1lbW9yYXRvciUyMFBybyUyMDV4SFMlMjAlMjhjaGFubmVsJTIwMCUyOSUwQURyaXZlciUyME5hbWUlMjAlMjAlMjAlM0ElMjBrY2FueTBhJTBBRUFOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwNzMtMzAxMzAtMDA3NzgtOSUwQUZpcm13YXJlJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwMy4xMS4wLjU1NyUwQVNlcmlhbCUyME51bWJlciUyMCUzQSUyMDEwMjMlMEFGb3JtYXR0aW5nJTIwZGlzay4uLiUyMGRvbmUlMjElMEE="][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="1.3 Create a configuration"][vc_column_text]Now we have to create a configuration which we do by writing a piece of XML code4. Let us take a simple example that just uses channel 0 and 1. We will set the bit rate on these two channels to 1 Mbit/s and log everything while in silent mode.[/vc_column_text][vc_code_raket language="python" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMCUzRiUzRSUwQSUzQyUyMS0tJTIwbG9nZ2FsbC54bWwlMjAtLSUzRSUwQSUzQyUyMURPQ1RZUEUlMjBLVkFTRVIlM0UlMEElM0NLVkFTRVIlM0UlMEElMjAlMjAlM0NWRVJTSU9OJTNFMi4wJTNDJTJGVkVSU0lPTiUzRSUwQSUyMCUyMCUzQ0JJTkFSWV9WRVJTSU9OJTNFNi4wJTNDJTJGQklOQVJZX1ZFUlNJT04lM0UlMEElMjAlMjAlM0NTRVRUSU5HUyUzRSUwQSUyMCUyMCUyMCUyMCUzQ01PREUlMjBmaWZvX21vZGUlM0QlMjJOTyUyMiUyMGxvZ19hbGwlM0QlMjJZRVMlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZTRVRUSU5HUyUzRSUwQSUyMCUyMCUzQ0NBTl9CVVMlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMCUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMSUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZDQU5fQlVTJTNFJTBBJTIwJTIwJTNDVFJJR0dFUkJMT0NLJTJGJTNFJTBBJTIwJTIwJTNDU0NSSVBUUyUyRiUzRSUwQSUzQyUyRktWQVNFUiUzRQ=="][vc_column_text]

Listing 2: Simple XML configuration sample.

[/vc_column_text][vc_column_text]The current version of the XML configuration is v2.0 and our device, running v3.11 of the firmware, expects binary (configuration) version 6.0. In the next article, where we increase the complexity of the configuration, we will look into how to explicitly validate the configuration before trying to download it. For now we just make sure we enter the XML without any errors.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="1.4 Download the configuration"][vc_column_text]We are now almost ready to start logging, we just need to place the configuration on the device. We will do this by reading in the XML file we just created, convert this XML configuration to a binary configuration and download the binary configuration to the device.[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwMDJfY29uZmlnX2RldmljZS5weSUwQWZyb20lM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TIwJTIwJTIwJTIwbWVtby53cml0ZV9jb25maWclMjhjb25maWdfbGlmJTI5"][vc_column_text]

Listing 3: Downloading configuration to Kvaser device.

[/vc_column_text][vc_column_text]
Now we are all set to disconnect our configured device from the computer and instead connect our device to an existing CAN bus and start logging by applying power to the device’s CAN 1 bus connector.
[/vc_column_text][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="1.5 Read logged messages"][vc_column_text]After we have logged some messages, we once again connect our Kvaser Memorator device to a free USB port on our computer and read out the result.[/vc_column_text][vc_code_raket language="python" header="Listing 6: Read logged messages and print to stdout." code="JTIzJTIwMDNfcmVhZF9sb2dnZWQucHklMEFmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwRUFOJTJDJTIwRGV2aWNlJTBBZnJvbSUyMGNhbmxpYiUyMGltcG9ydCUyMGt2bWxpYiUwQSUwQSUyMyUyMENvbm5lY3QlMjB0byUyMG91ciUyMEt2YXNlciUyME1lbW9yYXRvciUyMFBybyUyMDV4SFMlMjB3aXRoJTIwRUFOJTIwNzMtMzAxMzAtMDA3NzgtOSUwQSUyMyUyMGFuZCUyMG1vdW50JTIwdGhlJTIwbG9nJTIwYXJlYSUwQWRldiUyMCUzRCUyMERldmljZS5maW5kJTI4ZWFuJTNERUFOJTI4JTI3MDA3NzgtOSUyNyUyOSUyOSUwQW1lbW8lMjAlM0QlMjBrdm1saWIub3BlbkRldmljZSUyOGRldi5jaGFubmVsX251bWJlciUyOCUyOSUyQyUyMG1vdW50JTNEVHJ1ZSUyOSUwQSUwQWZpbGVDb3VudCUyMCUzRCUyMGxlbiUyOG1lbW8ubG9nJTI5JTBBcHJpbnQlMjglMjdGb3VuZCUyMCU3QiU3RCUyMGZpbGUlN0IlN0QlMjBvbiUyMGNhcmQuJTI3LmZvcm1hdCUyOCUwQSUyMCUyMCUyMCUyMGZpbGVDb3VudCUyQyUwQSUyMCUyMCUyMCUyMCUyMnMlMjIlMjBpZiUyMGZpbGVDb3VudCUyMCUzRSUyMDElMjBlbHNlJTIwJTIyJTIyJTI5JTBBJTI5JTBBJTBBJTIzJTIwTG9vcCUyMHRocm91Z2glMjBhbGwlMjBsb2dmaWxlcyUyMGFuZCUyMHdyaXRlJTIwdGhlaXIlMjBjb250ZW50cyUyMHRvJTIwc3Rkb3V0JTBBZm9yJTIwaSUyQyUyMGxvZ2ZpbGUlMjBpbiUyMGVudW1lcmF0ZSUyOG1lbW8ubG9nJTI5JTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQlMjglMjdSZWFkaW5nJTIwZmlsZSUyMCU3QiU3RCUzQSUyNy5mb3JtYXQlMjhpJTI5JTI5JTBBJTIwJTIwJTIwJTIwcHJpbnQlMjglMjJMb2dnaW5nJTIwc3RhcnRlZCUyMGF0JTIyJTJDJTIwbG9nZmlsZS5zdGFydF90aW1lLmlzb2Zvcm1hdCUyOCUyNyUyMCUyNyUyOSUyOSUwQSUwQSUyMCUyMCUyMCUyMGZvciUyMGV2ZW50JTIwaW4lMjBsb2dmaWxlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJpbnQlMjhldmVudCUyOSUwQSUwQSUyMyUyMG1lbW8ubG9nLmRlbGV0ZV9hbGwlMjglMjklMjAlMjAlMjAlMjMlMjBPcHRpb25hbGx5JTJDJTIwZGVsZXRlJTIwYWxsJTIwbG9nZmlsZXMlMEElMEElMjMlMjBDbG9zZSUyMHRoZSUyMG1lbW9yYXRvciUwQW1lbW8uY2xvc2UlMjglMjk="][vc_column_text]

Listing 4: Read logged messages and print to stdout.

[/vc_column_text][vc_column_text]Note that the deletion of log files on line 24 in Listing 4 is commented out so that we may run the script multiple times without the need to redo the logging on the CAN bus.[/vc_column_text][vc_code_raket header="Listing 6: Read logged messages and print to stdout." code="Rm91bmQlMjAxJTIwZmlsZSUyMG9uJTIwY2FyZC4lMEFSZWFkaW5nJTIwZmlsZSUyMDAlM0ElMEFMb2dnaW5nJTIwc3RhcnRlZCUyMGF0JTIwMjA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UyMGlkJTNBJTIwMTAzJTIwZGxjJTNBJTIwOCUyMGQlM0E0ZSUyMDBkJTIwMWElMjBkZCUyMDhkJTIwYjIlMjAxOSUyMGFiJTBBJTIwdCUzQSUyMCUyMDEwLjIyMDUwNzgxMiUyMCUyMERhdGVUaW1lJTNBJTIwMjAxOC0wNS0yMiUyMDExJTNBMDklM0EwNg=="][vc_column_text]
That’s it for this time. We have now seen how to configure and read back logged data using kvmlib. In the next part, we will branch out and look at adding some complexity to the configuration.
[/vc_column_text][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="Footnotes"][vc_column_text]1 For an overview of all the Kvaser SDK libraries, please read the blog post about how to Get more from your hardware with Kvaser SDK libraries. The product number of Kvaser Memorator Pro 5xHS is 73-30130-00778-9 Firmware for Kvaser Memorator Pro 5xHS is bundled in the Kvaser Firmware Update Tool which can be downloaded here. The XML configuration format is described in the document Specification of Kvaser Memorator Device configuration XML format, which is available here.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/6"][vc_column_text] [/vc_column_text][/vc_column][vc_column width="2/3"][vc_button_raket title="Adding script and triggers to a configuration" text="Part Two" page_id="https://www.kvaser.com/developer-blog/adding-script-and-triggers-to-a-configuration/"][/vc_column][vc_column width="1/6"][vc_column_text] [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][vc_separator_raket][vc_message]This article has been updated. To view the original, click on the box below.[/vc_message][vc_accordion active_tab="0" collapsible="yes"][vc_accordion_tab title="Original Article"][vc_column_text]Original article published March 29, 2016.[/vc_column_text][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 first post in a 4-part series about configuring and reading logged data using a Kvaser Memorator 2nd Generation device through kvmlib:[/vc_column_text][vc_column_text]

1 Getting started with kvmlib

2 Adding script and triggers to a configuration 3 Digging deeper into kvmlib 4 Configure an SD card using kvmlib[/vc_column_text][vc_column_text] This first post will give an overview on how to configure the Kvaser device using Python. Part two adds some complexity to the configuration, while part three will go deeper and show how to use kvmlib at the C API level. The last part shows how to configure the device while only having access to the removable SD card. Full program listings are available on GitHub. [/vc_column_text][vc_column_text]Update 2017-02-17: Updated sample code to work with Python 3 as well as using the Python canlib package introduced in CANlib SDK v5.17.[/vc_column_text][vc_header_raket header_type="h3" header="1.1 Introduction"][vc_column_text]Configuration of Kvaser Memorator 2nd Generation devices are normally done using the Kvaser Memomorator Config Tool, which is a GUI tool. But you may also configure these devices progammatically using kvmlib which is included in the CANlib SDK.1 Here we will show how to use kvmlib to configure a Kvaser Memorator Pro 5xHS.2 For an overview of the Kvaser SDK libraries, please read the blog post about how to get more from your hardware with Kvaser SDK libraries.[/vc_column_text][vc_column_text]We are running on a Windows system, so initially we need to download and install the CANlib SDK. This article will access kvmlib using Python3, so you might want to start by reading the blog post about Accessing CANlib from Python if you haven't done so already.[/vc_column_text][vc_column_text]The code snippets in this blog post are omitting the following import statements for brevity:4[/vc_column_text][vc_well_raket images="7797" float="1" title_link="1" title="Download CANlib" post_id="https://www.kvaser.com/download/?utm_source=software&utm_ean=7330130980150&utm_status=latest" button_title="Download"]Get the SDK package with API and examples.[/vc_well_raket][vc_code_raket language="python" code="aW1wb3J0JTIwZGF0ZXRpbWUlMEElMEFpbXBvcnQlMjBjYW5saWIua3ZhTWVtb0xpYlhtbCUyMGFzJTIwa3ZhTWVtb0xpYlhtbCUwQWltcG9ydCUyMGNhbmxpYi5rdkRldmljZSUyMGFzJTIwa3ZEZXZpY2UlMEFpbXBvcnQlMjBjYW5saWIua3ZtbGliJTIwYXMlMjBrdm1saWI=" header="Listing 1: Import statements that should be included in all code snippets."][vc_column_text]

Listing 1: Import statements that should be included in all code snippets.

[/vc_column_text][vc_column_text] We will be using a Kvaser Memorator Pro 5xHS which runs firmware version 3.0.5 If you have an older firmware, please update before continuing. [/vc_column_text][vc_video link="https://www.youtube.com/watch?v=HJr0RnXKXKY"][vc_header_raket header_type="h3" header="1.2 Initialize the SD card"][vc_column_text] It's not enough to just format the SD card in our operating system's file manager, we also need to initialize the SD card using our Kvaser Memorator device. After having inserted the SD card into our Kvaser Memorator device, we connect the Kvaser Memorator device to a free USB port on our computer and run our first bit of code to let us see that the device is alive. [/vc_column_text][vc_code_raket language="python" header="Listing 2: Connecting to a Kvaser device using the kvDevice module." code="JTIzJTIwQ29ubmVjdCUyMHRvJTIwb3VyJTIwS3Zhc2VyJTIwTWVtb3JhdG9yJTIwUHJvJTIwNXhIUyUyMHdpdGglMjBFQU4lMjAwMDc3OC05JTBBZGV2JTIwJTNEJTIwa3ZEZXZpY2Uua3ZEZXZpY2UlMjhlYW4lM0QlMjI3My0zMDEzMC0wMDc3OC05JTIyJTI5JTBBcHJpbnQlMjhkZXYlMjk="][vc_column_text]

Listing 2: Connecting to a Kvaser device using the kvDevice module.

[/vc_column_text][vc_column_text]
Device: Kvaser Memorator Pro 5xHS (channel 0)
EAN : 73-30130-00778-9
S/N : 1023
FW : v3.0.546
Card : 0
Drv : kcany0a
Card channel : 0
Canlib channel: 0
[/vc_column_text][vc_column_text] Here we note that we are able to connect to the device and that we indeed have firmware version 3.0. Now let us open the device and initialize the SD card using default values. [/vc_column_text][vc_code_raket language="python" header="Listing 3: Initializing SD card in Kvaser device." code="JTIzJTIwT3BlbiUyMHRoZSUyMGRldmljZSUwQWRldi5tZW1vT3BlbiUyOCUyOSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjB0aGUlMjBTRCUyMGNhcmQlMjB3aXRoJTIwZGVmYXVsdCUyMHZhbHVlcyUwQWRldi5tZW1vLmRldmljZUZvcm1hdERpc2slMjglMjklMEElMEElMjMlMjBDbG9zZSUyMHRoZSUyMGRldmljZSUwQWRldi5tZW1vQ2xvc2UlMjglMjk="][vc_column_text]

Listing 3: Initializing SD card in Kvaser device.

[/vc_column_text][vc_header_raket header_type="h3" header="1.3 Create a configuration"][vc_column_text]Now we have to create a configuration which we do by writing a piece of XML code.6 For more information, the latest version of the XML format is described in the document Specification of Kvaser Memorator Device configuration XML format. Let us take a simple example that just uses channel 1 and 2. We will set the bit rate on these two channels to 1 Mbit/s and log everything while in silent mode.[/vc_column_text][vc_code_raket language="python" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMCUzRiUzRSUwQSUzQyUyMURPQ1RZUEUlMjBLVkFTRVIlM0UlMEElM0NLVkFTRVIlM0UlMEElMjAlMjAlM0NWRVJTSU9OJTNFMi4wJTNDJTJGVkVSU0lPTiUzRSUwQSUyMCUyMCUzQ0JJTkFSWV9WRVJTSU9OJTNFNi4wJTNDJTJGQklOQVJZX1ZFUlNJT04lM0UlMEElMjAlMjAlM0NTRVRUSU5HUyUzRSUwQSUyMCUyMCUyMCUyMCUzQ01PREUlMjBmaWZvX21vZGUlM0QlMjJOTyUyMiUyMGxvZ19hbGwlM0QlMjJZRVMlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZTRVRUSU5HUyUzRSUwQSUyMCUyMCUzQ0NBTl9CVVMlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMCUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMSUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZDQU5fQlVTJTNFJTBBJTIwJTIwJTNDVFJJR0dFUkJMT0NLJTJGJTNFJTBBJTIwJTIwJTNDU0NSSVBUUyUyRiUzRSUwQSUzQyUyRktWQVNFUiUzRQ=="][vc_column_text]

Listing 4: Simple XML configuration sample.

[/vc_column_text][vc_column_text]The current version of the XML is v2.0 and our device, running v3.0 of the firmware, expects binary version 6.0. In the next article, where we increase the complexity of the configuration, we will look into how to explicitly validate the configuration before trying to download it. For now we just make sure we enter the XML without any errors.[/vc_column_text][vc_header_raket header_type="h3" header="1.4 Download the configuration"][vc_column_text] We are now almost ready to start logging, we just need to place the configuration on the device. We will do this by reading in the XML file we just created, convert this XML configuration to a binary configuration and download the binary configuration to the device. [/vc_column_text][vc_code_raket language="python" code="eGwlMjAlM0QlMjBrdmFNZW1vTGliWG1sLmt2YU1lbW9MaWJYbWwlMjglMjklMEElMEElMjMlMjBSZWFkJTIwaW4lMjB0aGUlMjBYTUwlMjBjb25maWd1cmF0aW9uJTIwZmlsZSUwQXdpdGglMjBvcGVuJTI4JTIybG9nYWxsLnhtbCUyMiUyQyUyMCUyN3IlMjclMjklMjBhcyUyMG15ZmlsZSUzQSUwQSUyMCUyMCUyMCUyMGNvbmZpZ194bWwlMjAlM0QlMjBteWZpbGUucmVhZCUyOCUyOSUwQSUwQSUyMyUyMENvbnZlcnQlMjB0aGUlMjBYTUwlMjBjb25maWd1cmF0aW9uJTIwdG8lMjBhJTIwYmluYXJ5JTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ19saWYlMjAlM0QlMjB4bC5rdmFYbWxUb0J1ZmZlciUyOGNvbmZpZ194bWwlMjklMEElMEElMjMlMjBPcGVuJTIwdGhlJTIwZGV2aWNlJTIwYW5kJTIwd3JpdGUlMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBZGV2Lm1lbW9PcGVuJTI4JTI5JTBBZGV2Lm1lbW8ua21mV3JpdGVDb25maWclMjhjb25maWdfbGlmJTI5JTBBJTBBJTIzJTIwQ2xvc2UlMjB0aGUlMjBkZXZpY2UlMEFkZXYubWVtb0Nsb3NlJTI4JTI5"][vc_column_text]

Listing 5: Downloading configuration to Kvaser device.

[/vc_column_text][vc_column_text] Now we are all set to disconnect our configured device from the computer and instead connect our device to an existing CAN bus and start logging by applying power to the device's CAN 1 bus connector. [/vc_column_text][vc_header_raket header_type="h3" header="1.5 Read logged messages"][vc_column_text] After we have logged some messages, we once again connect our Kvaser Memorator device to a free USB port on our computer and read out the result. [/vc_column_text][vc_code_raket language="python" header="Listing 6: Read logged messages and print to stdout." code="JTIzJTIwQ29ubmVjdCUyMHRvJTIwb3VyJTIwS3Zhc2VyJTIwTWVtb3JhdG9yJTIwUHJvJTIwNXhIUyUyMHdpdGglMjBFQU4lMjAwMDc3OC05JTBBZGV2JTIwJTNEJTIwa3ZEZXZpY2Uua3ZEZXZpY2UlMjhlYW4lM0QlMjI3My0zMDEzMC0wMDc3OC05JTIyJTI5JTBBZGV2Lm9wZW4lMjglMjklMEFkZXYubWVtb09wZW4lMjglMjklMEFmaWxlQ291bnQlMjAlM0QlMjBkZXYubWVtby5sb2dGaWxlR2V0Q291bnQlMjglMjklMEFwcmludCUyOCUyMkZvdW5kJTIwJTI1ZCUyMGZpbGUlMjVzJTIwb24lMjBjYXJkJTNBJTIyJTIwJTI1JTIwJTI4ZmlsZUNvdW50JTJDJTIwJTIycyUyMiUyMGlmJTIwZmlsZUNvdW50JTIwJTNFJTIwMSUyMGVsc2UlMjAlMjIlMjIlMjklMjklMEElMEElMjMlMjBMb29wJTIwdGhyb3VnaCUyMGFsbCUyMGxvZ2ZpbGVzJTIwYW5kJTIwd3JpdGUlMjB0aGVpciUyMGNvbnRlbnRzJTIwdG8lMjBzdGRvdXQlMEFmb3IlMjBmaWxlSW5keCUyMGluJTIwcmFuZ2UlMjhmaWxlQ291bnQlMjklM0ElMEElMjAlMjAlMjAlMjBteUV2ZW50cyUyMCUzRCUyMGRldi5tZW1vUmVhZEV2ZW50cyUyOGZpbGVJbmR4JTI5JTBBJTIwJTIwJTIwJTIwZm9yJTIwZXZlbnQlMjBpbiUyMG15RXZlbnRzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJpbnQlMjhldmVudCUyOSUwQSUyMCUyMCUyMCUyMHByaW50JTI4JTIyJTVDbiUyMiUyOSUwQSUwQSUyMyUyMERlbGV0ZSUyMGFsbCUyMGxvZ2ZpbGVzJTBBZGV2Lm1lbW8ubG9nRmlsZURlbGV0ZUFsbCUyOCUyOSUwQSUwQSUyMyUyMENsb3NlJTIwZGV2aWNlJTBBZGV2Lm1lbW9DbG9zZSUyOCUyOSUwQWRldi5jbG9zZSUyOCUyOQ=="][vc_column_text]

Listing 6: Read logged messages and print to stdout.

[/vc_column_text][vc_column_text]
Found 1 file on card:
*t:          - EAN:73-30130-00778-9 s/n:1023 FW:v3.0.546 LIO:v0.0
t: 0.249998387 DateTime: 2016-02-23 06:56:04
t: 0.249998387 Log Trigger Event (type: 0x1, trigno: 0x00, pre-trigger: 0, post-trigger: -1)

t: 9.479176975 DateTime: 2016-02-23 06:56:13
t: 13.29719495 ch:0 f: 2 id: 490 dlc: 2 d:5d d6
t: 13.29719495 ch:1 f: 2 id: 490 dlc: 2 d:5d d6
t: 13.298196175 ch:0 f: 2 id: 284 dlc: 2 d:a8 b1
t: 13.298196175 ch:1 f: 2 id: 284 dlc: 2 d:a8 b1
t: 13.299137412 ch:0 f: 2 id: 739 dlc: 2 d:7a 4b
t: 13.299137412 ch:1 f: 2 id: 739 dlc: 2 d:7a 4b
t: 13.300282637 ch:0 f: 2 id: 622 dlc: 6 d:8d b9 69 8a 98 e1
t: 13.300282637 ch:1 f: 2 id: 622 dlc: 6 d:8d b9 69 8a 98 e1
t: 13.301156875 ch:0 f: 2 id: 559 dlc: 1 d:78
t: 13.301156875 ch:1 f: 2 id: 559 dlc: 1 d:78
t:   13.3022261 ch:0 f: 2 id: 33a dlc: 1 d:0d
t:   13.3022261 ch:1 f: 2 id: 33a dlc: 1 d:0d
t: 13.303279325 ch:0 f: 2 id: 463 dlc: 6 d:14 eb d6 ae ed 46
t: 13.303279325 ch:1 f: 2 id: 463 dlc: 6 d:14 eb d6 ae ed 46
t: 13.304230562 ch:0 f: 2 id: 59b dlc: 6 d:7f a9 28 3a f2 5d
t: 13.304230562 ch:1 f: 2 id: 59b dlc: 6 d:7f a9 28 3a f2 5d
t: 13.305248787 ch:0 f: 2 id: 103 dlc: 8 d:4e 0d 1a dd 8d b2 19 ab
[/vc_column_text][vc_column_text]That's it for this time. We have now seen how to configure and read back logged data using kvmlib. In the next part, we will branch out and look at adding some complexity to the configuration.[/vc_column_text][vc_header_raket header_type="h3" header="Footnotes"][vc_column_text]1 The CANlib SDK can be downloaded from www.kvaser.com/developer/canlib-sdk. 2 EAN 73-30130-00778-9 3 As of Python canlib package v1.2.163 (included in CANlib SDK v5.19), the Python wrappers should work in both Python v3.4+ as well as under Python v2.7. 4 The full program listings are available on github.com/Kvaser/developer-blog. 5 The firmware for Kvaser Memorator Pro 5xHS is bundled in the Kvaser Firmware Update Tool which can be downloaded from www.kvaser.com/download. 6 The latest version of the XML format is described in the document Specification of Kvaser Memorator Device configuration XML format.[/vc_column_text][/vc_accordion_tab][/vc_accordion][/vc_column][/vc_row] [post_title] => Getting started with kvmlib [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => getting-started-with-kvmlib [to_ping] => [pinged] => [post_modified] => 2022-12-21 23:35:21 [post_modified_gmt] => 2022-12-21 23:35:21 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=11506 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [1] => WP_Post Object ( [ID] => 21939 [post_author] => 5 [post_date] => 2018-09-14 20:04:56 [post_date_gmt] => 2018-09-14 20:04:56 [post_content] => [vc_row][vc_column][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][vc_column_text]It’s no secret that here at Kvaser, we’re excited about the possibilities that CAN FD is enabling in the automotive industry, with its increased data loads, faster response time and higher performance capabilities.[/vc_column_text][vc_column_text]Recently, our own Director of Marketing, Jesse Paliotto, penned an article to share our enthusiasm with the readers of Design News, a publication that highlights new and compelling developments relevant to design engineers across industries.[/vc_column_text][vc_column_text]While CAN FD has seen applications in many different sectors, its greatest impact is currently being felt in the automotive industry, where the CAN bus is the most widely used in-vehicle network for ECU and sensor communication. With cars becoming more and more “connected,” CAN FD provides a perfect stepping stone from the original CAN protocol, allowing higher bandwidth communications, lower latency and better real-time performance – all critical to the success of the modern connected car. [/vc_column_text][vc_column_text]Read the whole article on the Design News website: How CAN FD Is Affecting the Automotive Industry.[/vc_column_text][/vc_column][/vc_row] [post_title] => Kvaser Shares CAN FD Possibilities With Design News [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => kvaser-shares-can-fd-possibilities-with-design-news [to_ping] => [pinged] => [post_modified] => 2018-09-14 20:04:56 [post_modified_gmt] => 2018-09-14 20:04:56 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21939 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [2] => WP_Post Object ( [ID] => 21926 [post_author] => 6080 [post_date] => 2018-09-13 13:09:01 [post_date_gmt] => 2018-09-13 13:09:01 [post_content] => [post_title] => ABtronix (Netherlands) offers 'Intro. to Vibration Test' course in October [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => abtronix-netherlands-offers-intro-to-vibration-test-course-in-october [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:05 [post_modified_gmt] => 2022-04-04 10:19:05 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21926 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [3] => WP_Post Object ( [ID] => 21924 [post_author] => 6080 [post_date] => 2018-09-13 13:02:42 [post_date_gmt] => 2018-09-13 13:02:42 [post_content] => [post_title] => emotas releases CAN MultiProtocol Stack [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => emtas-releases-can-multiprotocol-stack [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:05 [post_modified_gmt] => 2022-04-04 10:19:05 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21924 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [4] => WP_Post Object ( [ID] => 21922 [post_author] => 6080 [post_date] => 2018-09-13 12:58:43 [post_date_gmt] => 2018-09-13 12:58:43 [post_content] => [post_title] => ANcrypt FD security for NXP LPC54618 now available [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => ancrypt-fd-security-for-nxp-lpc54618-now-available [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:05 [post_modified_gmt] => 2022-04-04 10:19:05 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21922 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [5] => WP_Post Object ( [ID] => 21917 [post_author] => 6080 [post_date] => 2018-09-13 12:48:15 [post_date_gmt] => 2018-09-13 12:48:15 [post_content] => [post_title] => Insight into gantry systems from servo power specialist [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => insight-into-gantry-systems-from-servo-power-specialist [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:05 [post_modified_gmt] => 2022-04-04 10:19:05 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21917 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [6] => WP_Post Object ( [ID] => 21868 [post_author] => 6080 [post_date] => 2018-09-11 13:04:02 [post_date_gmt] => 2018-09-11 13:04:02 [post_content] => [post_title] => Big data and next-gen prognostics for heavy-duty vehicles [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => big-data-and-next-gen-prognostics-for-heavy-duty-vehicles [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:05 [post_modified_gmt] => 2022-04-04 10:19:05 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21868 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [7] => WP_Post Object ( [ID] => 21852 [post_author] => 6080 [post_date] => 2018-09-06 13:53:37 [post_date_gmt] => 2018-09-06 13:53:37 [post_content] => [post_title] => As cars collect more data, companies try to move it all faster [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => as-cars-collect-more-data-companies-try-to-move-it-all-faster [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:05 [post_modified_gmt] => 2022-04-04 10:19:05 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21852 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [8] => WP_Post Object ( [ID] => 21810 [post_author] => 6080 [post_date] => 2018-08-30 12:51:38 [post_date_gmt] => 2018-08-30 12:51:38 [post_content] => [post_title] => UR10 Robot At Aircraft Tooling Inc. [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => ur10-robot-aircraft-tooling-inc [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:04 [post_modified_gmt] => 2022-04-04 10:19:04 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21810 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [9] => WP_Post Object ( [ID] => 21799 [post_author] => 6080 [post_date] => 2018-08-29 15:01:11 [post_date_gmt] => 2018-08-29 15:01:11 [post_content] => [post_title] => Living Our Mission” Video Captures Essence of Dedicated Computing’s Purpose [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => living-mission-video-captures-essence-dedicated-computings-purpose [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:04 [post_modified_gmt] => 2022-04-04 10:19:04 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=21799 [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] => 11506 [post_author] => 14 [post_date] => 2018-09-16 20:36:15 [post_date_gmt] => 2018-09-16 20:36:15 [post_content] => [vc_row el_class="indented"][vc_column][vc_column_text]This is the first post in a 4-part series about configuring and reading logged data using a Kvaser Memorator 2nd Generation device through kvmlib:[/vc_column_text][vc_column_text]

1 Getting started with kvmlib

2 Adding script and triggers to a configuration 3 Digging deeper into kvmlib 4 Configure an SD card using kvmlib [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]This first post will give an overview on how to configure the Kvaser device using Python. Part two adds some complexity to the configuration, while part three will go deeper and show how to use kvmlib at the C API level. The last part shows how to configure the device while only having access to the removable SD card. Full program listings are available on GitHub.[/vc_column_text][vc_header_raket header_type="h3" header="1.1 Introduction"][vc_column_text]Configuration of newer Kvaser Memorator devices are normally done using the Kvaser Memomorator Config Tool, which is a Windows GUI tool. But you may also configure these devices programmatically using the Kvaser Memorator library (kvmlib) which is part of the Kvaser CANlib SDK.1 Our device of choice today is the Kvaser Memorator Pro 5xHS2 which runs firmware version 3.113. We will also be using v1.6 of the Python canlib package and v5.23 of the Kvaser CANlib SDK, the latest versions are available from www.kvaser.com/download.[/vc_column_text][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="1.2 Initialize the SD card"][vc_column_text]It’s not enough to just format the SD card in our operating system’s file manager, we also need to initialize the SD card using our Kvaser Memorator device. After having inserted the SD card into our Kvaser Memorator device, we connect the Kvaser Memorator device to a free USB port on our computer and run our first bit of code to format the SD card.[/vc_column_text][vc_code_raket language="python" header="Listing 2: Connecting to a Kvaser device using the kvDevice module." code="JTIzJTIwMDFfaW5pdF9zZGNhcmQucHklMEFm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G1lbW9yYXRvciUyMGhhbmRsZSUyMHdoZW4lMjB3ZSUyMGFyZSUyMGRvbmUuJTBBd2l0aCUyMGt2bWxpYi5vcGVuRGV2aWNlJTI4ZGV2LmNoYW5uZWxfbnVtYmVyJTI4JTI5JTI5JTIwYXMlMjBtZW1vJTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwSW5pdGlhbGl6ZSUyMHRoZSUyMFNEJTIwY2FyZCUyMHdpdGglMjBkZWZhdWx0JTIwdmFsdWVzLiUyMFRoZSUyMENBTiUyMExFRHMlMjB3aWxsJTIwZmxhc2glMEElMjAlMjAlMjAlMjAlMjMlMjBxdWlja2x5JTIwZHVyaW5nJTIwZGlzayUyMGluaXRpYWxpemF0aW9uLiUwQSUyMCUyMCUyMCUyMHByaW50JTI4JTI3Rm9ybWF0dGluZyUyMGRpc2suLi4lMjclMkMlMjBlbmQlM0QlMjclMjclMjklMEElMjAlMjAlMjAlMjBtZW1vLmZvcm1hdF9kaXNrJTI4JTI5JTBBJTIwJTIwJTIwJTIwcHJpbnQlMjglMjclMjBkb25lJTIxJTI3JTI5"][vc_column_text]

Listing 1: Initializing the SD card inside a Kvaser Memorator device.

[/vc_column_text][vc_column_text]When running this we can confirm that our device is indeed running firmware v3.11, and the device is currently connected to canlib channel 0.[/vc_column_text][vc_code_raket header="Listing 2: Connecting to a Kvaser device using the kvDevice module." code="Q0FObGliJTIwQ2hhbm5lbCUzQSUyMDAlMEFDYXJkJTIwTnVtYmVyJTIwJTIwJTIwJTNBJTIwMCUwQURldmljZSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUzQSUyMEt2YXNlciUyME1lbW9yYXRvciUyMFBybyUyMDV4SFMlMjAlMjhjaGFubmVsJTIwMCUyOSUwQURyaXZlciUyME5hbWUlMjAlMjAlMjAlM0ElMjBrY2FueTBhJTBBRUFOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwNzMtMzAxMzAtMDA3NzgtOSUwQUZpcm13YXJlJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwMy4xMS4wLjU1NyUwQVNlcmlhbCUyME51bWJlciUyMCUzQSUyMDEwMjMlMEFGb3JtYXR0aW5nJTIwZGlzay4uLiUyMGRvbmUlMjElMEE="][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="1.3 Create a configuration"][vc_column_text]Now we have to create a configuration which we do by writing a piece of XML code4. Let us take a simple example that just uses channel 0 and 1. We will set the bit rate on these two channels to 1 Mbit/s and log everything while in silent mode.[/vc_column_text][vc_code_raket language="python" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMCUzRiUzRSUwQSUzQyUyMS0tJTIwbG9nZ2FsbC54bWwlMjAtLSUzRSUwQSUzQyUyMURPQ1RZUEUlMjBLVkFTRVIlM0UlMEElM0NLVkFTRVIlM0UlMEElMjAlMjAlM0NWRVJTSU9OJTNFMi4wJTNDJTJGVkVSU0lPTiUzRSUwQSUyMCUyMCUzQ0JJTkFSWV9WRVJTSU9OJTNFNi4wJTNDJTJGQklOQVJZX1ZFUlNJT04lM0UlMEElMjAlMjAlM0NTRVRUSU5HUyUzRSUwQSUyMCUyMCUyMCUyMCUzQ01PREUlMjBmaWZvX21vZGUlM0QlMjJOTyUyMiUyMGxvZ19hbGwlM0QlMjJZRVMlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZTRVRUSU5HUyUzRSUwQSUyMCUyMCUzQ0NBTl9CVVMlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMCUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMSUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZDQU5fQlVTJTNFJTBBJTIwJTIwJTNDVFJJR0dFUkJMT0NLJTJGJTNFJTBBJTIwJTIwJTNDU0NSSVBUUyUyRiUzRSUwQSUzQyUyRktWQVNFUiUzRQ=="][vc_column_text]

Listing 2: Simple XML configuration sample.

[/vc_column_text][vc_column_text]The current version of the XML configuration is v2.0 and our device, running v3.11 of the firmware, expects binary (configuration) version 6.0. In the next article, where we increase the complexity of the configuration, we will look into how to explicitly validate the configuration before trying to download it. For now we just make sure we enter the XML without any errors.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="1.4 Download the configuration"][vc_column_text]We are now almost ready to start logging, we just need to place the configuration on the device. We will do this by reading in the XML file we just created, convert this XML configuration to a binary configuration and download the binary configuration to the device.[/vc_column_text][vc_code_raket language="python" code="JTIzJTIwMDJfY29uZmlnX2RldmljZS5weSUwQWZyb20lMjBjYW5saWIlMjBpbXBvcnQlMjBFQU4lMkMlMjBEZXZpY2UlMEFmcm9tJTIwY2FubGliJTIwaW1wb3J0JTIwa3ZhbWVtb2xpYnhtbCUwQWZyb20lMjBjYW5saWIlMjBpbXBvcnQlMjBrdm1saWIlMEElMEElMjMlMjBMb29rJTIwZm9yJTIwb3VyJTIwY29ubmVjdGVkJTIwS3Zhc2VyJTIwTWVtb3JhdG9yJTIwUHJvJTIwNXhIUyUwQSUyMyUyMFRpcCUzQSUyMEl0JTIwaXMlMjBlbm91Z2glMjB0byUyMHdyaXRlJTIwdGhlJTIwbGFzdCUyMDYlMjBkaWdpdHMuJTBBZGV2JTIwJTNEJTIwRGV2aWNlLmZpbmQlMjhlYW4lM0RFQU4lMjglMjcwMDc3OC05JTI3JTI5JTI5JTBBJTBBJTIzJTIwUmVhZCUyMGluJTIwdGhlJTIwWE1MJTIwY29uZmlndXJhdGlvbiUyMGZpbGUlMEF3aXRoJTIwb3BlbiUyOCUyMmxvZ2FsbC54bWwlMjIlMkMlMjAlMjdyJTI3JTI5JTIwYXMlMjBteWZpbGUlM0ElMEElMjAlMjAlMjAlMjBjb25maWdfeG1sJTIwJTNEJTIwbXlmaWxlLnJlYWQlMjglMjklMEElMEElMjMlMjBDb252ZXJ0JTIwdGhlJTIwWE1MJTIwY29uZmlndXJhdGlvbiUyMHRvJTIwYSUyMGJpbmFyeSUyMGNvbmZpZ3VyYXRpb24lMEFjb25maWdfbGlmJTIwJTNEJTIwa3ZhbWVtb2xpYnhtbC5rdmFYbWxUb0J1ZmZlciUyOGNvbmZpZ194bWwlMjklMEElMEElMjMlMjBPcGVuJTIwdGhlJTIwbWVtb3JhdG9yJTIwYW5kJTIwd3JpdGUlMjB0aGUlMjBiaW5hcnklMjBjb25maWd1cmF0aW9uJTBBd2l0aCUyMGt2bWxpYi5vcGVuRGV2aWNlJTI4ZGV2LmNoYW5uZWxfbnVtYmVyJTI4JTI5JTI5JTIwYXMlMjBtZW1vJTNBJTBBJTIwJTIwJTIwJTIwbWVtby53cml0ZV9jb25maWclMjhjb25maWdfbGlmJTI5"][vc_column_text]

Listing 3: Downloading configuration to Kvaser device.

[/vc_column_text][vc_column_text]
Now we are all set to disconnect our configured device from the computer and instead connect our device to an existing CAN bus and start logging by applying power to the device’s CAN 1 bus connector.
[/vc_column_text][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="1.5 Read logged messages"][vc_column_text]After we have logged some messages, we once again connect our Kvaser Memorator device to a free USB port on our computer and read out the result.[/vc_column_text][vc_code_raket language="python" header="Listing 6: Read logged messages and print to stdout." code="JTIzJTIwM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I5JTI5JTBBJTIwJTIwJTIwJTIwcHJpbnQlMjglMjJMb2dnaW5nJTIwc3RhcnRlZCUyMGF0JTIyJTJDJTIwbG9nZmlsZS5zdGFydF90aW1lLmlzb2Zvcm1hdCUyOCUyNyUyMCUyNyUyOSUyOSUwQSUwQSUyMCUyMCUyMCUyMGZvciUyMGV2ZW50JTIwaW4lMjBsb2dmaWxlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJpbnQlMjhldmVudCUyOSUwQSUwQSUyMyUyMG1lbW8ubG9nLmRlbGV0ZV9hbGwlMjglMjklMjAlMjAlMjAlMjMlMjBPcHRpb25hbGx5JTJDJTIwZGVsZXRlJTIwYWxsJTIwbG9nZmlsZXMlMEElMEElMjMlMjBDbG9zZSUyMHRoZSUyMG1lbW9yYXRvciUwQW1lbW8uY2xvc2UlMjglMjk="][vc_column_text]

Listing 4: Read logged messages and print to stdout.

[/vc_column_text][vc_column_text]Note that the deletion of log files on line 24 in Listing 4 is commented out so that we may run the script multiple times without the need to redo the logging on the CAN bus.[/vc_column_text][vc_code_raket header="Listing 6: Read logged messages and print to stdout." code="Rm91bmQlMjAxJTIwZmlsZSUyMG9uJTIwY2FyZC4lMEFSZWFkaW5nJTIwZmlsZSUyMDAlM0ElMEFMb2dnaW5nJTIwc3RhcnRlZCUyMGF0JTIwMjAxOC0wNS0yMiUyMDExJTNBMDglM0E1NiUwQSUyQXQlM0ElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtJTIwRUFOJTNBNzMtMzAxMzAtMDA3NzgtOSUyMCUyMHMlMkZuJTNBMTAyMyUyMCUyMEZXJTNBdjMuMTEuNTU3JTIwJTIwTElPJTNBdjUuMCUwQSUyMHQlM0ElMjAlMjAlMjAwLjIzNjczNDAxMiUyMCUyMERhdGVUaW1lJTNBJTIwMjAxOC0wNS0yMiUyMDExJTNBMDglM0E1NiUwQSUyMHQlM0ElMjAlMjAlMjAwLjIzNj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UzQSUyMCUyMCUyMCUyMDIlMjBpZCUzQSUyMDQ2MyUyMGRsYyUzQSUyMDYlMjBkJTNBMTQlMjBlYiUyMGQ2JTIwYWUlMjBlZCUyMDQ2JTBBJTIwdCUzQSUyMCUyMCUyMDQuNDU2NzU0ODYyJTIwJTIwY2glM0EwJTIwZiUzQSUyMCUyMCUyMCUyMDIlMjBpZCUzQSUyMDU5YiUyMGRsYyUzQSUyMDYlMjBkJTNBN2YlMjBhOSUyMDI4JTIwM2ElMjBmMiUyMDVkJTBBJTIwdCUzQSUyMCUyMCUyMCUyMCUyMDQuNDU2NzU0OSUyMCUyMGNoJTNBMSUyMGYlM0ElMjAlMjAlMjAlMjAyJTIwaWQlM0ElMjA1OWIlMjBkbGMlM0ElMjA2JTIwZCUzQTdmJTIwYTklMjAyOCUyMDNhJTIwZjIlMjA1ZCUwQSUyMHQlM0ElMjAlMjAlMjA0LjQ1NzI2OTk4NyUyMCUyMGNoJTNBMCUyMGYlM0ElMjAlMjAlMjAlMjAyJTIwaWQlM0ElMjAxMDMlMjBkbGMlM0ElMjA4JTIwZCUzQTRlJTIwMGQlMjAxYSUyMGRkJTIwOGQlMjBiMiUyMDE5JTIwYWIlMEElMjB0JTNBJTIwJTIwJTIwNC40NTcyNzAwMjUlMjAlMjBjaCUzQTElMjBmJTNBJTIwJTIwJTIwJTIwMiUyMGlkJTNBJTIwMTAzJTIwZGxjJTNBJTIwOCUyMGQlM0E0ZSUyMDBkJTIwMWElMjBkZCUyMDhkJTIwYjIlMjAxOSUyMGFiJTBBJTIwdCUzQSUyMCUyMDEwLjIyMDUwNzgxMiUyMCUyMERhdGVUaW1lJTNBJTIwMjAxOC0wNS0yMiUyMDExJTNBMDklM0EwNg=="][vc_column_text]
That’s it for this time. We have now seen how to configure and read back logged data using kvmlib. In the next part, we will branch out and look at adding some complexity to the configuration.
[/vc_column_text][vc_raw_html]JTNDYnIlM0U=[/vc_raw_html][vc_header_raket header_type="h3" header="Footnotes"][vc_column_text]1 For an overview of all the Kvaser SDK libraries, please read the blog post about how to Get more from your hardware with Kvaser SDK libraries. The product number of Kvaser Memorator Pro 5xHS is 73-30130-00778-9 Firmware for Kvaser Memorator Pro 5xHS is bundled in the Kvaser Firmware Update Tool which can be downloaded here. The XML configuration format is described in the document Specification of Kvaser Memorator Device configuration XML format, which is available here.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/6"][vc_column_text] [/vc_column_text][/vc_column][vc_column width="2/3"][vc_button_raket title="Adding script and triggers to a configuration" text="Part Two" page_id="https://www.kvaser.com/developer-blog/adding-script-and-triggers-to-a-configuration/"][/vc_column][vc_column width="1/6"][vc_column_text] [/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][vc_separator_raket][vc_message]This article has been updated. To view the original, click on the box below.[/vc_message][vc_accordion active_tab="0" collapsible="yes"][vc_accordion_tab title="Original Article"][vc_column_text]Original article published March 29, 2016.[/vc_column_text][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 first post in a 4-part series about configuring and reading logged data using a Kvaser Memorator 2nd Generation device through kvmlib:[/vc_column_text][vc_column_text]

1 Getting started with kvmlib

2 Adding script and triggers to a configuration 3 Digging deeper into kvmlib 4 Configure an SD card using kvmlib[/vc_column_text][vc_column_text] This first post will give an overview on how to configure the Kvaser device using Python. Part two adds some complexity to the configuration, while part three will go deeper and show how to use kvmlib at the C API level. The last part shows how to configure the device while only having access to the removable SD card. Full program listings are available on GitHub. [/vc_column_text][vc_column_text]Update 2017-02-17: Updated sample code to work with Python 3 as well as using the Python canlib package introduced in CANlib SDK v5.17.[/vc_column_text][vc_header_raket header_type="h3" header="1.1 Introduction"][vc_column_text]Configuration of Kvaser Memorator 2nd Generation devices are normally done using the Kvaser Memomorator Config Tool, which is a GUI tool. But you may also configure these devices progammatically using kvmlib which is included in the CANlib SDK.1 Here we will show how to use kvmlib to configure a Kvaser Memorator Pro 5xHS.2 For an overview of the Kvaser SDK libraries, please read the blog post about how to get more from your hardware with Kvaser SDK libraries.[/vc_column_text][vc_column_text]We are running on a Windows system, so initially we need to download and install the CANlib SDK. This article will access kvmlib using Python3, so you might want to start by reading the blog post about Accessing CANlib from Python if you haven't done so already.[/vc_column_text][vc_column_text]The code snippets in this blog post are omitting the following import statements for brevity:4[/vc_column_text][vc_well_raket images="7797" float="1" title_link="1" title="Download CANlib" post_id="https://www.kvaser.com/download/?utm_source=software&utm_ean=7330130980150&utm_status=latest" button_title="Download"]Get the SDK package with API and examples.[/vc_well_raket][vc_code_raket language="python" code="aW1wb3J0JTIwZGF0ZXRpbWUlMEElMEFpbXBvcnQlMjBjYW5saWIua3ZhTWVtb0xpYlhtbCUyMGFzJTIwa3ZhTWVtb0xpYlhtbCUwQWltcG9ydCUyMGNhbmxpYi5rdkRldmljZSUyMGFzJTIwa3ZEZXZpY2UlMEFpbXBvcnQlMjBjYW5saWIua3ZtbGliJTIwYXMlMjBrdm1saWI=" header="Listing 1: Import statements that should be included in all code snippets."][vc_column_text]

Listing 1: Import statements that should be included in all code snippets.

[/vc_column_text][vc_column_text] We will be using a Kvaser Memorator Pro 5xHS which runs firmware version 3.0.5 If you have an older firmware, please update before continuing. [/vc_column_text][vc_video link="https://www.youtube.com/watch?v=HJr0RnXKXKY"][vc_header_raket header_type="h3" header="1.2 Initialize the SD card"][vc_column_text] It's not enough to just format the SD card in our operating system's file manager, we also need to initialize the SD card using our Kvaser Memorator device. After having inserted the SD card into our Kvaser Memorator device, we connect the Kvaser Memorator device to a free USB port on our computer and run our first bit of code to let us see that the device is alive. [/vc_column_text][vc_code_raket language="python" header="Listing 2: Connecting to a Kvaser device using the kvDevice module." code="JTIzJTIwQ29ubmVjdCUyMHRvJTIwb3VyJTIwS3Zhc2VyJTIwTWVtb3JhdG9yJTIwUHJvJTIwNXhIUyUyMHdpdGglMjBFQU4lMjAwMDc3OC05JTBBZGV2JTIwJTNEJTIwa3ZEZXZpY2Uua3ZEZXZpY2UlMjhlYW4lM0QlMjI3My0zMDEzMC0wMDc3OC05JTIyJTI5JTBBcHJpbnQlMjhkZXYlMjk="][vc_column_text]

Listing 2: Connecting to a Kvaser device using the kvDevice module.

[/vc_column_text][vc_column_text]
Device: Kvaser Memorator Pro 5xHS (channel 0)
EAN : 73-30130-00778-9
S/N : 1023
FW : v3.0.546
Card : 0
Drv : kcany0a
Card channel : 0
Canlib channel: 0
[/vc_column_text][vc_column_text] Here we note that we are able to connect to the device and that we indeed have firmware version 3.0. Now let us open the device and initialize the SD card using default values. [/vc_column_text][vc_code_raket language="python" header="Listing 3: Initializing SD card in Kvaser device." code="JTIzJTIwT3BlbiUyMHRoZSUyMGRldmljZSUwQWRldi5tZW1vT3BlbiUyOCUyOSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjB0aGUlMjBTRCUyMGNhcmQlMjB3aXRoJTIwZGVmYXVsdCUyMHZhbHVlcyUwQWRldi5tZW1vLmRldmljZUZvcm1hdERpc2slMjglMjklMEElMEElMjMlMjBDbG9zZSUyMHRoZSUyMGRldmljZSUwQWRldi5tZW1vQ2xvc2UlMjglMjk="][vc_column_text]

Listing 3: Initializing SD card in Kvaser device.

[/vc_column_text][vc_header_raket header_type="h3" header="1.3 Create a configuration"][vc_column_text]Now we have to create a configuration which we do by writing a piece of XML code.6 For more information, the latest version of the XML format is described in the document Specification of Kvaser Memorator Device configuration XML format. Let us take a simple example that just uses channel 1 and 2. We will set the bit rate on these two channels to 1 Mbit/s and log everything while in silent mode.[/vc_column_text][vc_code_raket language="python" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMCUzRiUzRSUwQSUzQyUyMURPQ1RZUEUlMjBLVkFTRVIlM0UlMEElM0NLVkFTRVIlM0UlMEElMjAlMjAlM0NWRVJTSU9OJTNFMi4wJTNDJTJGVkVSU0lPTiUzRSUwQSUyMCUyMCUzQ0JJTkFSWV9WRVJTSU9OJTNFNi4wJTNDJTJGQklOQVJZX1ZFUlNJT04lM0UlMEElMjAlMjAlM0NTRVRUSU5HUyUzRSUwQSUyMCUyMCUyMCUyMCUzQ01PREUlMjBmaWZvX21vZGUlM0QlMjJOTyUyMiUyMGxvZ19hbGwlM0QlMjJZRVMlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZTRVRUSU5HUyUzRSUwQSUyMCUyMCUzQ0NBTl9CVVMlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMCUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlMjAlMjAlM0NQQVJBTUVURVJTJTIwYml0cmF0ZSUzRCUyMjEwMDAwMDAlMjIlMjBjaGFubmVsJTNEJTIyMSUyMiUyMHNpbGVudCUzRCUyMllFUyUyMiUyMHNqdyUzRCUyMjElMjIlMjB0c2VnMSUzRCUyMjUlMjIlMjB0c2VnMiUzRCUyMjIlMjIlMkYlM0UlMEElMjAlMjAlM0MlMkZDQU5fQlVTJTNFJTBBJTIwJTIwJTNDVFJJR0dFUkJMT0NLJTJGJTNFJTBBJTIwJTIwJTNDU0NSSVBUUyUyRiUzRSUwQSUzQyUyRktWQVNFUiUzRQ=="][vc_column_text]

Listing 4: Simple XML configuration sample.

[/vc_column_text][vc_column_text]The current version of the XML is v2.0 and our device, running v3.0 of the firmware, expects binary version 6.0. In the next article, where we increase the complexity of the configuration, we will look into how to explicitly validate the configuration before trying to download it. For now we just make sure we enter the XML without any errors.[/vc_column_text][vc_header_raket header_type="h3" header="1.4 Download the configuration"][vc_column_text] We are now almost ready to start logging, we just need to place the configuration on the device. We will do this by reading in the XML file we just created, convert this XML configuration to a binary configuration and download the binary configuration to the device. [/vc_column_text][vc_code_raket language="python" code="eGwlMjAlM0QlMjBrdmFNZW1vTGliWG1sLmt2YU1lbW9MaWJYbWwlMjglMjklMEElMEElMjMlMjBSZWFkJTIwaW4lMjB0aGUlMjBYTUwlMjBjb25maWd1cmF0aW9uJTIwZmlsZSUwQXdpdGglMjBvcGVuJTI4JTIybG9nYWxsLnhtbCUyMiUyQyUyMCUyN3IlMjclMjklMjBhcyUyMG15ZmlsZSUzQSUwQSUyMCUyMCUyMCUyMGNvbmZpZ194bWwlMjAlM0QlMjBteWZpbGUucmVhZCUyOCUyOSUwQSUwQSUyMyUyMENvbnZlcnQlMjB0aGUlMjBYTUwlMjBjb25maWd1cmF0aW9uJTIwdG8lMjBhJTIwYmluYXJ5JTIwY29uZmlndXJhdGlvbiUwQWNvbmZpZ19saWYlMjAlM0QlMjB4bC5rdmFYbWxUb0J1ZmZlciUyOGNvbmZpZ194bWwlMjklMEElMEElMjMlMjBPcGVuJTIwdGhlJTIwZGV2aWNlJTIwYW5kJTIwd3JpdGUlMjB0aGUlMjBjb25maWd1cmF0aW9uJTBBZGV2Lm1lbW9PcGVuJTI4JTI5JTBBZGV2Lm1lbW8ua21mV3JpdGVDb25maWclMjhjb25maWdfbGlmJTI5JTBBJTBBJTIzJTIwQ2xvc2UlMjB0aGUlMjBkZXZpY2UlMEFkZXYubWVtb0Nsb3NlJTI4JTI5"][vc_column_text]

Listing 5: Downloading configuration to Kvaser device.

[/vc_column_text][vc_column_text] Now we are all set to disconnect our configured device from the computer and instead connect our device to an existing CAN bus and start logging by applying power to the device's CAN 1 bus connector. [/vc_column_text][vc_header_raket header_type="h3" header="1.5 Read logged messages"][vc_column_text] After we have logged some messages, we once again connect our Kvaser Memorator device to a free USB port on our computer and read out the result. [/vc_column_text][vc_code_raket language="python" header="Listing 6: Read logged messages and print to stdout." code="JTIzJTIwQ29ubmVjdCUyMHRvJTIwb3VyJTIwS3Zhc2VyJTIwTWVtb3JhdG9yJTIwUHJvJTIwNXhIUyUyMHdpdGglMjBFQU4lMjAwMDc3OC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_text]
Found 1 file on card:
*t:          - EAN:73-30130-00778-9 s/n:1023 FW:v3.0.546 LIO:v0.0
t: 0.249998387 DateTime: 2016-02-23 06:56:04
t: 0.249998387 Log Trigger Event (type: 0x1, trigno: 0x00, pre-trigger: 0, post-trigger: -1)

t: 9.479176975 DateTime: 2016-02-23 06:56:13
t: 13.29719495 ch:0 f: 2 id: 490 dlc: 2 d:5d d6
t: 13.29719495 ch:1 f: 2 id: 490 dlc: 2 d:5d d6
t: 13.298196175 ch:0 f: 2 id: 284 dlc: 2 d:a8 b1
t: 13.298196175 ch:1 f: 2 id: 284 dlc: 2 d:a8 b1
t: 13.299137412 ch:0 f: 2 id: 739 dlc: 2 d:7a 4b
t: 13.299137412 ch:1 f: 2 id: 739 dlc: 2 d:7a 4b
t: 13.300282637 ch:0 f: 2 id: 622 dlc: 6 d:8d b9 69 8a 98 e1
t: 13.300282637 ch:1 f: 2 id: 622 dlc: 6 d:8d b9 69 8a 98 e1
t: 13.301156875 ch:0 f: 2 id: 559 dlc: 1 d:78
t: 13.301156875 ch:1 f: 2 id: 559 dlc: 1 d:78
t:   13.3022261 ch:0 f: 2 id: 33a dlc: 1 d:0d
t:   13.3022261 ch:1 f: 2 id: 33a dlc: 1 d:0d
t: 13.303279325 ch:0 f: 2 id: 463 dlc: 6 d:14 eb d6 ae ed 46
t: 13.303279325 ch:1 f: 2 id: 463 dlc: 6 d:14 eb d6 ae ed 46
t: 13.304230562 ch:0 f: 2 id: 59b dlc: 6 d:7f a9 28 3a f2 5d
t: 13.304230562 ch:1 f: 2 id: 59b dlc: 6 d:7f a9 28 3a f2 5d
t: 13.305248787 ch:0 f: 2 id: 103 dlc: 8 d:4e 0d 1a dd 8d b2 19 ab
[/vc_column_text][vc_column_text]That's it for this time. We have now seen how to configure and read back logged data using kvmlib. In the next part, we will branch out and look at adding some complexity to the configuration.[/vc_column_text][vc_header_raket header_type="h3" header="Footnotes"][vc_column_text]1 The CANlib SDK can be downloaded from www.kvaser.com/developer/canlib-sdk. 2 EAN 73-30130-00778-9 3 As of Python canlib package v1.2.163 (included in CANlib SDK v5.19), the Python wrappers should work in both Python v3.4+ as well as under Python v2.7. 4 The full program listings are available on github.com/Kvaser/developer-blog. 5 The firmware for Kvaser Memorator Pro 5xHS is bundled in the Kvaser Firmware Update Tool which can be downloaded from www.kvaser.com/download. 6 The latest version of the XML format is described in the document Specification of Kvaser Memorator Device configuration XML format.[/vc_column_text][/vc_accordion_tab][/vc_accordion][/vc_column][/vc_row] [post_title] => Getting started with kvmlib [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => getting-started-with-kvmlib [to_ping] => [pinged] => [post_modified] => 2022-12-21 23:35:21 [post_modified_gmt] => 2022-12-21 23:35:21 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=11506 [menu_order] => 0 [post_type] => developer_blog [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] => 3e3a1742392b94812b1bbbe55dfdf3ce [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 kvmlib

16/09/2018

This is the first post in a 4-part series about configuring and reading logged data using a Kvaser Memorator 2nd… Read More

Read More
Kvaser Shares CAN FD Possibilities With Design News

Kvaser Shares CAN FD Possibilities With Design News

14/09/2018

It’s no secret that here at Kvaser, we’re excited about the possibilities that CAN FD is enabling in the automotive… Read More

Read More

ABtronix (Netherlands) offers ‘Intro. to Vibration Test’ course in October

13/09/2018

Read More

Read More

emotas releases CAN MultiProtocol Stack

13/09/2018

Read More

Read More

ANcrypt FD security for NXP LPC54618 now available

13/09/2018

Read More

Read More

Insight into gantry systems from servo power specialist

13/09/2018

Read More

Read More

Big data and next-gen prognostics for heavy-duty vehicles

11/09/2018

Read More

Read More

As cars collect more data, companies try to move it all faster

06/09/2018

Read More

Read More

UR10 Robot At Aircraft Tooling Inc.

30/08/2018

Read More

Read More

Living Our Mission” Video Captures Essence of Dedicated Computing’s Purpose

29/08/2018

Read More

Read More