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

    [query_vars] => Array
        (
            [paged] => 13
            [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 120, 10
    [posts] => Array
        (
            [0] => WP_Post Object
                (
                    [ID] => 32321
                    [post_author] => 38
                    [post_date] => 2021-03-23 18:39:59
                    [post_date_gmt] => 2021-03-23 18:39:59
                    [post_content] => [vc_row][vc_column][vc_single_image image="32324"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]MathWorks and Kvaser are hosting a joint webinar to support customers using MATLAB's Vehicle Network Toolbox to transition to CAN FD.

This webinar will walk through the challenges of migrating to CAN FD, showing how to leverage the technology using MathWorks’ Vehicle Network Toolbox and Kvaser hardware. The presenters will introduce the basic concepts of CAN FD, compare classical CAN to CAN FD and show how to decode and visualise CAN FD signals, with a demonstration of the new MATLAB features for CAN FD.

The 1-hour session, designed for engineers working at the software level, will be co-presented by Jaremy Pyle, Development Manager, Automotive Connectivity at MathWorks and Kent Lennartsson, Research Manager at Kvaser AB.

Wednesday, April 7
8a PST / 11a ET / 17:00 CET

1-Hour Webinar (includes 15min Q&A)[/vc_column_text][vc_button_raket title="Register Now" text="" page_id="https://attendee.gotowebinar.com/register/5553864542155748363?source=Kvaser"][/vc_column][/vc_row]
                    [post_title] => Webinar: CAN FD Data Acquisition and Visualization with MATLAB and Kvaser Hardware
                    [post_excerpt] => 
                    [post_status] => publish
                    [comment_status] => closed
                    [ping_status] => closed
                    [post_password] => 
                    [post_name] => webinar-can-fd-data-acquisition-and-visualization-with-matlab-and-kvaser-hardware
                    [to_ping] => 
                    [pinged] => 
                    [post_modified] => 2022-06-14 12:15:27
                    [post_modified_gmt] => 2022-06-14 12:15:27
                    [post_content_filtered] => 
                    [post_parent] => 0
                    [guid] => https://www.kvaser.com/?p=32321
                    [menu_order] => 0
                    [post_type] => post
                    [post_mime_type] => 
                    [comment_count] => 0
                    [filter] => raw
                )

            [1] => WP_Post Object
                (
                    [ID] => 31978
                    [post_author] => 4840
                    [post_date] => 2021-03-22 09:49:04
                    [post_date_gmt] => 2021-03-22 09:49:04
                    [post_content] => [vc_row][vc_column][vc_column_text]In this document I will show how to connect to a unique Kvaser CAN channel, using a nickname instead of CANlib channel number. This method makes it possible to dedicate a can channel to a specific interface.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="1. Customized channel names"][vc_column_text]We ([email protected]) often get the question:
  • Can I make sure that my computer always starts my kvaser interfaces in the same order?
The answer to that question is unfortunately: No![/vc_column_text][vc_column_text]Normally, if you have multiple interfaces, the interfaces will be started on the same order every time, but if you change one interface, then the order can be different.[/vc_column_text][vc_column_text]
  • Is it possible to name each channel with an identifier?
Yes, it is possible to set a name on each channel that can be used to identify a channel.  (Will be shown in another blog later)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]There is one quite simple method that does not require so much work, that makes it quite easy to open a unique CAN channel. All our (Kvaser) Interfaces do have a product number (EAN) and a serial-number, in combination with the “Channel Number On Card” these three data fields create a unique combination.[/vc_column_text][vc_column_text]Example[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image="31979"][vc_column_text]My “Kvaser USBcan Pro 2xHS v2” interface has two channels, no 0 and no 1, and it will be found at CANlib channel 1 and 2.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="2. Finding channel information for a specific channel"][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image="31980"][vc_column_text]If we check my  “Kvaser USBcan Pro 2xHS v2” interface, we will find: Device EAN              73-30130-00752-9 (this is the product number) Serial Number          12160 Channel on Card      0                           (On the first channel) Channel on Card      1                           (On the second channel)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]If I create a name based on this information, eg. “00752-9:12160/1”, then this name will always point to the second channel on my “USBcan Pro”, there is no other Kvaser interface that can have that combination. So if I have connected  “00752-9:12160/1” to a very secret test object, then I know that if I open that name combination, I will always communicate with that object, and I do not need to know how many other interfaces I have installed in my computer. Something like canOpenChannel(‘00752-9:12160/1’,flags).[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.1. The CANlib command canOpenChannel()"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Normally when we call the command canOpenChannel, then we provide a CANlib channel number, and some FLAGS. Can we use the syntax canOpenChannel(‘00752-9:12160:1’,flags) instead? Well, in the best of worlds, this command should already be a part of CANlib, but it does not exist yet, so you will have to do it yourself.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="2.2. User defined MycanOpenChannel()"][vc_column_text]Let us create a command: MyCanOpenSpecificChannel()[/vc_column_text][vc_column_text]Delphi function MyCanOpenSpecificChannel(const NickName: string; const flags: integer; var FoundChannel: integer): canHandle; Parameters [in]    NickName           String with “EAN:SN/ChOnCard” (‘00752-9:12160/1’) [in]    flags                   A combination of canOPEN_xxx flags [out] FoundChannel     The number of the opened channel Returns Returns a handle to the opened circuit, or canERR_xxx (negative) if the call failed.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]A complete listing of the functions MyCanOpenSpecificChannel() Appendix A. Let us assume that NickName contains ‘00752-9:12160/1’. Let us call the function SplitNickNameStringPlease(), it will return EAN, SN and NoOnCard. EAN             = ‘00752-9’ SN               = 12160 NoOnCard    = 1[/vc_column_text][vc_column_text]With the command canGetChannelData() we can get a lot of information about our connected interfaces. We will use the parameters: canCHANNELDATA_CARD_SERIAL_NO, canCHANNELDATA_CHAN_NO_ON_CARD and canCHANNELDATA_CARD_UPC_NO. canCHANNELDATA_CARD_SERIAL_NO uses a 64bit integer canCHANNELDATA_CHAN_NO_ON_CARD uses a 32bit integer canCHANNELDATA_CARD_UPC_NO uses a 64bit BCD string[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]So by calling(when iteration through all channels (I)): canGetChannelData(I, canCHANNELDATA_CARD_SERIAL_NO , U64_1, sizeof(U64_1)); canGetChannelData(I, canCHANNELDATA_CHAN_NO_ON_CARD, U32_1, sizeof(U32_1)); canGetChannelData(I, canCHANNELDATA_CARD_UPC_NO , U64_2, sizeof(U64_2));[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]We will receive some information in U64_1,U32_1 and U64_2. U64_1 and U32_1 will contain the Serial Sumber respective Channel No on Card, and can easily be compared with our search values. U64_2 contains the EAN-number and we need to do some processing to be able to read the EAN number. First, convert U64_2 to a 16 digit long HEX string, 2026405030294825 ToHexString becomes: '0007330130007529'[/vc_column_text][vc_column_text]The full EAN number is 73-30130-00752-9 so it easy to identify what we must copy 73-30130-00752-9  '0007330130007529 st := copy(st, 11, 5) + '-' + copy(st, 16, 1);[/vc_column_text][vc_column_text]We are looking for the condition: EAN      = ‘00752-9’ SN       = 12160 NoOnCard = 1 If (U64_1=SN) and (U32_1=SN) and (EAN=st) then we have found our interface, let us return the channel number and try to call canOpenChannel(). You can see the complete listing of the function in Appendix A.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="3. Conclusion"][vc_column_text]Of course, you can select almost any format to describe a certain unique channel. What I tried to describe here in this text, is that with three calls to canGetChannelData(), you will receive enough information to be able to determine if this is the channel you want to open. I hope this information is useful to you. Comments and questions are welcome![/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="4. Appendix A MycanOpenChannel()"][vc_header_raket header_type="h2" header="4.1. function MycanOpenChannel()"][vc_code_raket language="csharp" code="ZnVuY3Rpb24lMjBNeWNhbk9wZW5DaGFubmVsJTI4Y29uc3QlMjBOaWNrTmFtZSUzQSUyMHN0cmluZyUzQiUyMGNvbnN0JTIwZmxhZ3MlM0ElMjBpbnRlZ2VyJTNCJTIwdmFyJTIwRm91bmRDaGFubmVsJTNBJTIwaW50ZWdlciUyOSUzQSUyMGNhbkhhbmRsZSUzQiUwQSUyMCUyMCUyMCUyMHZhciUwQSUyMCUyMCUyMCUyMCUyMCUyMEklM0ElMjBpbnRlZ2VyJTNCJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwRUFOJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTNBJTIwc3RyaW5nJTNCJTBBJTIwJTIwJTIwJTIwJTIwJTIwU04lMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlM0ElMjBVSU5UNjQlM0IlMEElMjAlMjAlMjAlMjAlMjAlMjBDaE5vT25DYXJkJTNBJTIwVUlOVDMyJTNCJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwTiUzQSUyMGludGVnZXIlM0IlMEElMjAlMjAlMjAlMjAlMjAlMjBVSTY0JTIwJTIwJTIwJTNBJTIwVUlOVDY0JTNCJTBBJTIwJTIwJTIwJTIwJTIwJTIwVUkzMiUyMCUyMCUyMCUzQSUyMFVJTlQzMiUzQiUwQSUyMCUyMCUyMCUyMCUyMCUyMHN0JTIwJTIwJTIwJTIwJTIwJTNBJTIwc3RyaW5nJTNCJTBBJTBBJTIwJTIwJTIwJTIwYmVnaW4lMEElMjAlMjAlMjAlMjAlMjAlMjByZXN1bHQlMjAlMjAlMjAlMjAlMjAlMjAlMjAlM0ElM0QlMjBjYW5FUlJfTk9URk9VTkQlM0IlMEElMjAlMjAlMjAlMjAlMjAlMjBGb3VuZENoYW5uZWwlMjAlM0ElM0QlMjBjYW5FUlJfTk9URk9VTkQl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IwcmVzdWx0JTIwJTNBJTNEJTIwdHJ1ZSUzQiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGVuZCUzQiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGVuZCUzQiUwQSUyMCUyMCUyMCUyMCUyMCUyMGV4Y2VwdCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzQSUzRCUyMGZhbHNlJTNCJTBBJTIwJTIwJTIwJTIwJTIwJTIwZW5kJTNCJTBBJTIwJTIwJTIwJTIwZW5kJTNCJTBB"][/vc_column][/vc_row] [post_title] => How to connect to a specific Kvaser CAN channel [post_excerpt] => How to connect to a unique Kvaser CAN channel, using a nickname instead of CANlib channel number, making it possible to dedicate a CAN channel to a specific interface. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => how-to-connect-to-a-specific-kvaser-can-channel [to_ping] => [pinged] => [post_modified] => 2021-03-23 18:25:02 [post_modified_gmt] => 2021-03-23 18:25:02 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=31978 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [2] => WP_Post Object ( [ID] => 22550 [post_author] => 4840 [post_date] => 2021-03-09 03:30:19 [post_date_gmt] => 2021-03-09 03:30:19 [post_content] => [vc_row][vc_column][vc_column_text]In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a C# .NET project. I will show how to create WIN32 and WIN64 applications. I will also show how to handle the platform-settings: x86, x64 and AnyCPU. When this is done, you can use the same project (source code) for creating WIN32 and WIN64 applications without editing your code. The instructions in this document can also be used when enabling CANlib in an existing project.   Important information from the author: Since CANLib version 5.30, the support for canlibCLSNET has been removed. Instead we now supports “.NET Standard 2.0.”[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Abbreviations"][vc_column_text]VS2017Microsoft Visual Studio 2017 (C# .NET) CANlib Kvaser CANlib SDK www.kvaser.com/download[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Before we start..."][vc_column_text]First we must download and install “Kvaser CANlib SDK“ and also “Kvaser Drivers for Windows”. After you have installed CANlib, please check your hard-drive and identify where “canlibCLSNET.DLL” has been installed. On my 64-bit Windows machine it is installed here: c:\Program Files (x86)\Kvaser\Canlib\dotnet\win32\fw40\canlibCLSNET.dll c:\Program Files (x86)\Kvaser\Canlib\dotnet\x64\fw40\canlibCLSNET.dll As you can see, one is for building 32-bit and one is for 64-bit applications. Please remember where you found them, as you will need this information soon. Please also install “Microsoft Visual C++ Redistributable for Visual Studio 2017” if you not have done it. (Installs by default if you install the C++ tools when installing VS2017.) Now we are ready to start Visual Studio 2017 (C# .NET). (I have used “Microsoft Visual Studio Professional 2017” when creating this text.)[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Creating an empty project"][vc_column_text]Creating a project in VS can be done in many different ways, this is one way to do it. Press, “File” - “New” -”Project…”[/vc_column_text][vc_single_image image="22552"][vc_column_text]I chose to create a Windows Forms App (.NET Framework) Visual C#. Edit the name and the rest of the unique information and press “OK”.[/vc_column_text][vc_single_image image="22553"][vc_column_text]Now VS2017 creates an application for us. It is a bit boring, just an empty form that does nothing. (Do not try to create an “Universal Windows” app. Our drivers will not work with “Universal Windows Apps”.)[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Adding some code that uses CANlib (C#)"][vc_column_text]I will now add some code that uses CANlib; exactly what it does is not important in this example. For more information about how to use CANlib, please check CANlib SDK Help. To add a BUTTON and a TEXTBOX, change the property “Multiline” on the textbox to true. (I assume that you are familiar with how to add components in VS2017, I will not show it here). After a bit of editing, we have this beautiful application:[/vc_column_text][vc_single_image image="22554"][vc_column_text]It still does nothing, so in the editor, double click on “button1” and add some code inside the “button1_Click” function.[/vc_column_text][vc_code_raket language="csharp" code="cHJpdmF0ZSUyMHZvaWQlMjBidXR0b24xX0NsaWNrJTI4b2JqZWN0JTIwc2VuZGVyJTJDJTIwRXZlbnRBcmdzJTIwZSUyOSUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCU3QiUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMENhbmxpYi5jYW5TdGF0dXMlMjBSJTNCJTBBJTIwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwaW50JTIwViUzQiUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMHRleHRCb3gxLkNsZWFyJTI4JTI5JTNCJTBBJTIwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwdGV4dEJveDEuVGV4dCUyMCUzRCUyMCUyMkRFTU8lMjBWUzIwMTclMjBDJTIzJTIwLk5FVCU1Q3IlNUNuJTIyJTNCJTBBJTBBJTIwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwQ2FubGliLmNhbkluaXR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UMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwdGV4dEJveDEuVGV4dCUyMCUyQiUzRCUyMHN0cmluZy5Gb3JtYXQlMjglMjJGb3VuZCUyMCU3QjAlN0QlMjBjaGFubmVscyU1Q3IlNUNuJTIyJTJDJTIwTk9DJTI5JTNCJTBBJTIwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwJUMyJUEwdGV4dEJveDEuVGV4dCUyMCUyQiUzRCUyMCUyMi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lNUNyJTVDbiUyMiUzQiUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCU3RA=="][vc_column_text]When I try to run the application, I get multiple errors. Something is wrong and VS2017 cannot find CANlib.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Adding a reference to canlibCLSNET.dll"][vc_column_text]In order to use CANlib in a VS2017 project, we must add information to show where VS2017 can find “canlibCLSNET.dll”. It is only possible to add a reference to either the x86 version or the x64 version. However, with a minor modification in one file, we can enable both. I will show that later in this document. Before I start, I select the platform to “Any CPU” (for the moment, it is the only platform I have enabled in this application). Select “Any CPU” as platform:[/vc_column_text][vc_single_image image="22555"][vc_column_text]Add the text “using canlibCLSNET;” in the USING clauses:[/vc_column_text][vc_single_image image="22556"][vc_column_text]When I try to BUILD, then I get the error: “The type or namespace name 'canlibCLSNET' could not be found (are you missing a using directive or an assembly reference?)” Yes, I am missing a “Reference” I must add the “Reference” to canlibCLSNET Right click on “References”, and select “Add Reference…”:[/vc_column_text][vc_single_image image="22557"][vc_column_text]Select Browse and then click on the button “Browse…”:[/vc_column_text][vc_single_image image="22558"][vc_column_text](If you have done this before, then VS2017 will show canlibCLSNET.dll in the window as you can see in my example.) Select “c:\...\...\win32\fw40\canlibCLSNET.dll” (Hope you remembered it):[/vc_column_text][vc_single_image image="22559"][vc_column_text]I am selecting the WIN32 version (even if I intend to use the WIN64 at a later date). Press the “OK” button. Now I can see that the canlibCLSNET reference has been added:[/vc_column_text][vc_single_image image="22560"][vc_column_text]If I try to BUILD and RUN the application, it works! (sometimes) If I press Button1, something will appear in the textbox:[/vc_column_text][vc_single_image image="22561"][vc_column_text]Sometimes I get a WARNING, and sometimes I get an ERROR. I am not sure why I get the warning or error, because I should always get the error. (I am running my application on a WIN64 PC and the result should be an error. Maybe the compiler tries to save me.) But, there is a simple fix to this little problem, and while I fix it, I also add support for using the WIN32 and WIN64 application platforms. Keep on reading ...[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Enabling CANlib for WIN32 and WIN64"][vc_column_text]So far, I have set “Any CPU” as the target CPU platform. Now I want to set it to the platforms so I can build applications for x86 (win32) and x64 (win64). Select “Configuration Manager…”:[/vc_column_text][vc_single_image image="22562"][vc_column_text]Select “<New…>” and add x86 and x64:[/vc_column_text][vc_single_image image="22563"][vc_column_text]Important: Use the “new” from the “Project contexts”, not from “Active solutions platform”. Copy settings from “any CPU”:[/vc_column_text][vc_single_image image="22564"][vc_column_text]I do this for x86 and x64 and then return to the main IDE.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Testing x86 and x64"][vc_column_text]Select “x86” and press “Start”:[/vc_column_text][vc_single_image image="22565"][vc_column_text]It works! The application starts (but I get a warning). Select “x64” and press “Start”:[/vc_column_text][vc_single_image image="22566"][vc_column_text]I got a warning, but expected an error. This is normal and will be fixed in the next section. OK, now the situation has been improved a lot. We can select the platform, and sometimes we get a warning and sometimes an error. I said earlier that I should fix this, and now this seems to be a proper time to do that.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Setting PATH for canlibCLSNET WIN32 and WIN64"][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]I want VS2017 to automatically select the correct version of canlibCLSNET.dll when I build my project. I have found one method to do it (there might be more methods). In my directory structure for the project, there is a file we can edit: CANlib_VS2017_DEMO.csproj.user (ProjName.csproj.user) But I can not find it! Where is it?  OK, no problem. It is not created by default, only when needed. Let us create it! This file is little like Harry Potter’s “Room of Requirement”; it can be almost whatever we want it to be. Open “Project” - “ProjName Properties…”:[/vc_column_text][/vc_column][vc_column width="1/2"][vc_single_image image="22567"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Go to the section “Reference Paths” and add the path to the WIN32 canlibCLSNET:[/vc_column_text][vc_single_image image="22568"][vc_column_text]I save my project and close VS2017. Now, when I check my project directory, I can find the file “ProjName.csproj.user”. Open it in a text editor, and my file looks like this: (Please note, this file can contain a lot of information, so it is necessary to locate the part where the “ReferencePath” has been defined.)[/vc_column_text][vc_code_raket language="csharp" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMGVuY29kaW5nJTNEJTIydXRmLTglMjIlM0YlM0UlRTIlODAlQTglMEElM0NQcm9qZWN0JTIwVG9vbHNWZXJzaW9uJTNEJTIyMTUuMCUyMiUyMHhtbG5zJTNEJTIyaHR0cCUzQSUyRiUyRnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyRmRldmVsb3BlciUyRm1zYnVpbGQlMkYyMDAzJTIyJTNFJUUyJTgwJUE4JTBBJTIwJTIwJTNDUHJvcGVydHlHcm91cCUzRSVFMiU4MCVBOCUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCUzQ1JlZmVyZW5jZVBhdGglM0VDJTNBJTVDUHJvZ3JhbSUyMEZpbGVzJTIwJTI4eDg2JTI5JTVDS3Zhc2VyJTVDQ2FubGliJTVDZG90bmV0JTVDd2luMzIlNUNmdzQwJTVDJTNDJTJGUmVmZXJlbmNlUGF0aCUzRSVFMiU4MCVBOCUwQSUyMCVDMiVBMCUzQyUyRlByb3BlcnR5R3JvdXAlM0UlRTIlODAlQTglMEElM0MlMkZQcm9qZWN0JTNF"][vc_column_text]I am now adding some lines, and when I am done, my file looks like this:[/vc_column_text][vc_code_raket language="csharp" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMGVuY29kaW5nJTNEJTIydXRmLTglMjIlM0YlM0UlRTIlODAlQTglM0NQcm9qZWN0JTIwVG9vbHNWZXJzaW9uJTNEJTIyMTUuMCUyMiUyMHhtbG5zJTNEJTIyaHR0cCUzQSUyRiUyRnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyRmRldmVsb3BlciUyRm1zYnVpbGQlMkYyMDAzJTIyJTNFJUUyJTgwJUE4JTIwJUMyJUEwJTNDUHJvcGVydHlHcm91cCUzRSVFMiU4MCVBOCUyMCVDMiVBMCVDMiVBMCVDMiVBMCUzQ1JlZmVyZW5jZVBhdGglM0VDJTNBJTVDUHJvZ3JhbSUyMEZpbGVzJTIwJTI4eDg2JTI5JTVDS3Zhc2VyJTVDQ2FubGliJTVDZG90bmV0JTVDd2luMzIlNUNmdzQwJTVDJTNDJTJGUmVmZXJlbmNlUGF0aCUzRSVFMiU4MCVBOCUyMCVDMiVBMCUzQyUyRlByb3BlcnR5R3JvdXAlM0UlMEElMjAlQzIlQTAlM0NQcm9wZXJ0eUdyb3VwJTIwQ29uZGl0aW9uJTNEJTIyJTIwJTI3JTI0JTI4UGxhdGZvcm0lMjklMjclMjAlM0QlM0QlMjAlMjd4NjQlMjclMjAlMjIlM0UlMEElMjAlQzIlQTAlQzIlQTAlQzIlQTAlM0NSZWZlcmVuY2VQYXRoJTNFQyUzQSU1Q1Byb2dyYW0lMjBGaWxlcyUyMCUyOHg4NiUyOSU1Q0t2YXNlciU1Q0NhbmxpYiU1Q2RvdG5ldCU1Q3g2NCU1Q2Z3NDAlNUMlM0MlMkZSZWZlcmVuY2VQYXRoJTNFJTBBJTIwJUMyJUEwJTNDJTJGUHJvcGVydHlHcm91cCUzRSUwQSUzQyUyRlByb2plY3QlM0U="][vc_column_text]I added a PropertyGroup with a condition (x64). This group will override the first PropertyGroup if I have selected x64 as platform. It is important that you add the x64 group after the general group. Please, remember to check the path to the two DLL files.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Selecting platform x86, x64 and AnyCPU"][vc_column_text]I can now select x86 (win32) and x64 (win64) as active platforms, in both cases the application starts correctly and CANlib is available and working. If everything worked well, you will also be able to create an C# dotNET CANlib application in Visual Studio 2017. We have now enabled CANlib in Visual Studio 2017, created a C# .NET project and tested it for both x86 and x64.  ΟΕΔ  (Q.E.D.  Quod erat demonstrandum)[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Thoughts and FAQ"][vc_column_text]Can I use AnyCPU?  When I select AnyCPU as a platform, I get a warning or an error! When the computer starts Visual Studio, if I have selected AnyCPU, the software will decide whether to use the 32bit or 64bit version of the DLL. Yes, AnyCPU might work, but if I run the built application on another machine, with different setup, it might not work. (Dynamic loading of the DLL might work, please check this external link for more information: https://stackoverflow.com/questions/108971/using-side-by-side-assemblies-to-load-the-x64-or-x32-version-of-a-dll) Safest setup?  If I select x86 (WIN32) built application, it will run on both WIN32 and WIN64 machines. Do I need WIN64? If your application needs it, CANlib will work perfectly, but only on WIN64 machines. However, today (2021), the majority of Windows PCs are win64. Microsoft Visual C++ and canlibCLSNET Redistributable When installing your app on another machine (might not have Visual Studio installed), please remember to redistribute (and install) the “Microsoft Visual C++ Redistributable for Visual Studio 2017”. You will need to copy the canlibCLSNET.dll (x86 and/or x64) with your project executable. These dlls are not installed as part of the driver (they are part of KVASER CANlib SDK). Thanks for reading this! If you have any questions or comment regarding this paper, please send a mail to [email protected]. [/vc_column_text][/vc_column][/vc_row] [post_title] => Using CANlib Visual Studio 2017 C#.NET (canlibCLSNET) [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => using-canlib-visual-studio-2017-c-net [to_ping] => [pinged] => [post_modified] => 2021-04-16 12:57:34 [post_modified_gmt] => 2021-04-16 12:57:34 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=22550 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [3] => WP_Post Object ( [ID] => 22588 [post_author] => 4840 [post_date] => 2021-03-08 00:36:59 [post_date_gmt] => 2021-03-08 00:36:59 [post_content] => [vc_row][vc_column][vc_column_text]In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a Visual Basic (VB) project. I will show how to create WIN32 and WIN64 applications. I will also show how to handle the platform-settings: x86 and x64. When this is done, you can use the same project (source code) for creating WIN32 and WIN64 applications without editing your code. The instructions in this document can also be used when enabling CANlib in an existing project.   Important information from the author: Since CANLib version 5.30, the support for canlibCLSNET has been removed. Instead we now supports “.NET Standard 2.0.” If you intend to use .NET Standard 2.0, please read the blog, Using CANlib Visual Studio 2017 VB .NET Standard 2.0.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Abbreviations"][vc_column_text]VS2017Microsoft Visual Studio 2017 (VB) CANlib Kvaser CANlib SDK www.kvaser.com/download[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Before we start..."][vc_column_text]First we must download and install “Kvaser CANlib SDK“ and also “Kvaser Drivers for Windows”. After you have installed CANlib, please check your hard-drive and identify where “canlibCLSNET.DLL” has been installed. On my 64-bit Windows machine it is installed here: c:\Program Files (x86)\Kvaser\Canlib\dotnet\win32\fw40\canlibCLSNET.dll c:\Program Files (x86)\Kvaser\Canlib\dotnet\x64\fw40\canlibCLSNET.dll As you can see, one is for building 32-bit and one is for 64-bit applications. Please remember where you found them, as you will need this information soon. Please also install “Microsoft Visual C++ Redistributable for Visual Studio 2017” if you not have done it. (Installs by default if you install the C++ tools when installing VS2017.) Now we are ready to start Visual Studio 2017 (VB). (I have used “Microsoft Visual Studio Professional 2017” when creating this text.)[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Creating an empty project"][vc_column_text]Creating a project in VS can be done in many different ways, this is one way to do it. Press, “File” - “New” -”Project…”[/vc_column_text][vc_single_image image="22589"][vc_column_text]I chose to create a Windows Forms App (.NET Framework) Visual Basic Edit the name and the rest of the unique information and press “OK”.[/vc_column_text][vc_single_image image="22590"][vc_column_text]Now VS2017 creates an application for us. It is a bit boring, just an empty form that does almost nothing.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Adding some code that uses CANlib (VB)"][vc_column_text]I will now add some code that uses CANlib; exactly what it does is not important in this example. For more information about how to use CANlib, please check CANlib SDK Help. To add a BUTTON and a TEXTBOX, change the property “Multiline” on the textbox to true. (I assume that you are familiar with how to add components in VS2017, I will not show it here). After a bit of editing, we have this beautiful application:[/vc_column_text][vc_single_image image="22591"][vc_column_text]It still does nothing, so in the editor, double click on “button1” and add some code inside the “button1_Click” function.[/vc_column_text][vc_code_raket language="clike" code="UHJpdmF0ZSUyMFN1YiUyMEJ1dHRvbjFfQ2xpY2slMjhzZW5kZXIlMjBBcyUyME9iamVjdCUyQyUyMGUlMjBBcyUyMEV2ZW50QXJncyUyOSUyMEhhbmR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lQTAlQzIlQTAlQzIlQTAlQzIlQTBSJTIwJTNEJTIwY2FubGliQ0xTTkVULkNhbmxpYi5jYW5TZXRCdXNQYXJhbXMlMjhobmQwJTJDJTIwY2FubGliQ0xTTkVULkNhbmxpYi5jYW5CSVRSQVRFXzI1MEslMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyOSUwQSUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMFIlMjAlM0QlMjBjYW5saWJDTFNORVQuQ2FubGliLmNhbkJ1c09uJTI4aG5kMCUyOSUwQSUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMCVDMiVBMFRleHRCb3gxLlRleHQlMjAlMkIlM0QlMjAlMjJDaGFubmVsJTIwMCUyMGFuZCUyMDElMjBpbml0aWF0ZWQlMjIlMjAlMjYlMjB2Yk5ld0xpbmUlMEElMjAlQzIlQTAlQzIlQTAlQzIlQTBFbmQlMjBTdWI="][vc_column_text]When I try to run the application, I get multiple errors. Something is wrong and VS2017 cannot find CANlib.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Enabling the WIN32 and WIN64 platforms"][vc_column_text]When creating an VB application, VB defaults to “Any CPU” as the target CPU platform. We can not use Any CPU as platform because we can only link to one version of canlibCLSNET. We must now enable the x86 (win32) and the x64 (win64) platforms. Select “Configuration Manager…”:[/vc_column_text][vc_single_image image="22592"][vc_column_text]Select “<New…>” and add x86 and x64:[/vc_column_text][vc_single_image image="22593"][vc_column_text]Important: Use the “new” from the “Active solutions platform”, not from “Project contexts”. Create the new platforms x64 and x86 (we will have to do this twice). Copy settings from “any CPU”:[/vc_column_text][vc_single_image image="22594"][vc_column_text]I do this for x86 and x64. I also deletes the AnyCPU platform to make sure that I not enabling it by mistake in the future (select EDIT and remove it). Now I must edit the configuration manager to make sure that we are using the correct platform.[/vc_column_text][vc_single_image image="22595"][vc_column_text]In the picture above, we can see that even if we have selected the combination DEBUG/x86, the compiler will try to create the platform “Any CPU”. This time I select NEW from “Project contexts”[/vc_column_text][vc_single_image image="22596"][vc_column_text]Create the platform x86. Do this for all four combinations: Debug/x86 Use x86 Debug/x64 Use x64 Release/x86 Use x86 Release/x64 Use x64[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Verifying Target CPU and setting output path"][vc_column_text]Open PROJECT/PROPERTIES I can open the PROPERTIES in two different ways: 1 Meny: Project / appname properties 2 Solution Explorer, right click on the appname, select properties.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_single_image image="22597"][/vc_column][vc_column width="1/2"][vc_single_image image="22598"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]In some versions of Visual Studio, there is a bug in the properties page when it is opened with the first method. This bug sometimes claims that the platform is not selectable. If we use the second method, then the page works perfect. Check that Target CPU is correct for all four Configuration/Platform combinations.[/vc_column_text][vc_single_image image="22599"][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Set Build Output Path(Optional) When we are checking the Target CPU, we can also (if we want) edit the output path. Default is: bin\x86\Release\ bin\x64\Debug\ bin\x64\Release\ bin\x86\Debug\ I prefer: bin\Debug\x86\ bin\Debug\x64\ bin\Release\x86\ bin\Release\x64\ I think this makes it a bit easier for me to find the built applications.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Adding a reference to canlibCLSNET.dll"][vc_column_text]In order to use CANlib in a VS2017 project, I must add information to show where VS2017 can find “canlibCLSNET.dll”. It is only possible to add a reference to either the x86 version or the x64 version. However, with a minor modification in one file, we can enable both. I will show that later in this document. Select “x86” as platform:[/vc_column_text][vc_single_image image="22600"][vc_column_text]When I try to BUILD, then I get the errors:[/vc_column_text][vc_single_image image="22601"][vc_column_text]Yes, I am missing a “Reference” I must add the “Reference” to canlibCLSNET[/vc_column_text][vc_column_text]Adding canlibCLSNET.DLL for x86 Right click on “References”, and select “Add Reference…”:[/vc_column_text][vc_single_image image="22602"][vc_column_text]Select Browse and then click on the button “Browse…”:[/vc_column_text][vc_single_image image="22603"][vc_column_text](If you have done this before, then VS2017 will show canlibCLSNET.dll in the window as you can see in my example.) Select “c:\...\...\win32\fw40\canlibCLSNET.dll” (Hope you remembered it):[/vc_column_text][vc_single_image image="22604"][vc_column_text]I am selecting the WIN32 version (even if I intend to use the WIN64 at a later date). Press the “OK” button. Now I can see that the canlibCLSNET reference has been added:[/vc_column_text][vc_single_image image="22605"][vc_column_text]If I try to BUILD and RUN the application, it works! When I press Button1, something will appear in the textbox:[/vc_column_text][vc_single_image image="22606"][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Adding canlibCLSNET.DLL for x64 Select x64 as platform[/vc_column_text][vc_single_image image="22607"][vc_column_text]If I try to build the application, no errors or warnings will appear. But some warnings and errors when I try to run the application.[/vc_column_text][vc_single_image image="22608"][vc_column_text]I can only add one version of canlibCLSNET.DLL. So I must remove the reference to the x86 version, before I add the x64 version. (Please wait a bit to remove the reference, we can keep it and manually enable both x86 and x64. I will show how below)[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Remove reference to canlibCLSNET Remove the reference by right clicking on it and select REMOVE[/vc_column_text][vc_single_image image="22609"][vc_column_text]When the reference id removed, I can add the reference to x64. Follow the same procedure as in adding canlibCLSNET.DLL for x86.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Manually adding canlibCLSNET for x86 and x64 It is possible to add the reference for canlibCLSNET for both x86 and x64 at the same time. When building the application, the correct version will be used and no errors or warnings shall appear. I will show two methods, one manual and one automatic version. Both version works fine and which one you should select depends more how you later decides to handle your software.  The manual method (section 7.4.1) gives you more control of the version and you must manually copy the dll files in the future when updating to never SDK versions.  The automatic version (section 7.4.2) copies the latest installed SDK files and includes them into your project. If you are unsure, use the automatic version, you can switch method whenever you want.[/vc_column_text][vc_column_text]1 - Manually adding canlibCLSNET for x86 and x64 Before we start, add the reference for x86 and test it with BUILD and RUN. (Please read section 7.4.2 before trying this method) When VS2017 is building the application, it also copies the canlibCLSNET.DLL to the application directory. If we turn this feature off, and manually copies the DLL files, then  we can use the x86 reference for both x86 and x64 platform. In Solution explorer/references, select canlibCLSNET.[/vc_column_text][vc_single_image image="22612"][vc_column_text]Change the property “Copy Local” to false. When I build my application, I get four directories: .\WindowsApp1\bin\Debug\x86\ .\WindowsApp1\bin\Debug\x64\ .\WindowsApp1\bin\Release\x86\ .\WindowsApp1\bin\Release\x64\ Copy the file canlibCLSNET.dll to the four directories above (make sure that you copy the x86 version to the x86 platform directory, and the x64 version to the x64 directory)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]2 - Automatic adding canlibCLSNET for x86 and x64 I want VS2017 to automatically select the correct version of canlibCLSNET.dll when I build my project. (I assume that you have followed the example and skipped section 7.4.1) I have found one method to do it (there might be more methods).In my directory structure for the project, there is a file we can edit: WindowsApp1.csproj.user (ProjName.csproj.user) But I can not find it! Where is it? OK, no problem. It is not created by default, only when needed. Let us create it! This file is little like Harry Potter’s “Room of Requirement”; it can be almost whatever we want it to be. Creating the file “ProjName.csproj.user” Open “Project” - “ProjName Properties…” as described above in "Verifying Target CPU and setting output path".[/vc_column_text][vc_single_image image="22613"][vc_column_text]Go to the section “References” and press the button “Reference Path…”[/vc_column_text][vc_single_image image="22614"][vc_column_text]Press button “Browse”[/vc_column_text][vc_single_image image="22615"][vc_column_text]Select directory: ”c:\Program Files (x86)\Kvaser\Canlib\dotnet\win32\fw40\”[/vc_column_text][vc_single_image image="22617"][vc_column_text]Press the button “Add Folder”[/vc_column_text][vc_single_image image="22618"][vc_column_text]Press the “OK” button[/vc_column_text][vc_single_image image="22619"][vc_column_text]I save my project and close VS2017.[/vc_column_text][vc_column_text]Editing the file “ProjName.csproj.user” Now, when I check my project directory, I can find the file “ProjName.csproj.user”. Open it in a text editor, and my file looks like this: (Please note, this file can contain a lot of information, so it is necessary to locate the part where the “ReferencePath” has been defined.)[/vc_column_text][vc_code_raket language="clike" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMGVuY29kaW5nJTNEJTIydXRmLTglMjIlM0YlM0UlMEElRTIlODAlQTglM0NQcm9qZWN0JTIwVG9vbHNWZXJzaW9uJTNEJTIyMTUuMCUyMiUyMHhtbG5zJTNEJTIyaHR0cCUzQSUyRiUyRnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyRmRldmVsb3BlciUyRm1zYnVpbGQlMkYyMDAzJTIyJTNFJUUyJTgwJUE4JTIwJTBBJUMyJUEwJTIwJTNDUHJvcGVydHlHcm91cCUzRSVFMiU4MCVBOCUwQSUyMCVDMiVBMCVDMiVBMCVDMiVBMCUzQ1JlZmVyZW5jZVBhdGglM0VDJTNBJTVDUHJvZ3JhbSUyMEZpbGVzJTIwJTI4eDg2JTI5JTVDS3Zhc2VyJTVDQ2FubGliJTVDZG90bmV0JTVDd2luMzIlNUNmdzQwJTVDJTNDJTJGUmVmZXJlbmNlUGF0aCUzRSUwQSVFMiU4MCVBOCUyMCVDMiVBMCUzQyUyRlByb3BlcnR5R3JvdXAlM0UlMEElRTIlODAlQTglM0MlMkZQcm9qZWN0JTNFJTBB"][vc_column_text]I am now adding some lines, and when I am done, my file looks like this:[/vc_column_text][vc_code_raket language="clike" code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMGVuY29kaW5nJTNEJTIydXRmLTglMjIlM0YlM0UlRTIlODAlQTglM0NQcm9qZWN0JTIwVG9vbHNWZXJzaW9uJTNEJTIyMTUuMCUyMiUyMHhtbG5zJTNEJTIyaHR0cCUzQSUyRiUyRnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyRmRldmVsb3BlciUyRm1zYnVpbGQlMkYyMDAzJTIyJTNFJUUyJTgwJUE4JTIwJUMyJUEwJTNDUHJvcGVydHlHcm91cCUzRSVFMiU4MCVBOCUyMCVDMiVBMCVDMiVBMCVDMiVBMCUzQ1JlZmVyZW5jZVBhdGglM0VDJTNBJTVDUHJvZ3JhbSUyMEZpbGVzJTIwJTI4eDg2JTI5JTVDS3Zhc2VyJTVDQ2FubGliJTVDZG90bmV0JTVDd2luMzIlNUNmdzQwJTVDJTNDJTJGUmVmZXJlbmNlUGF0aCUzRSVFMiU4MCVBOCUyMCVDMiVBMCUzQyUyRlByb3BlcnR5R3JvdXAlM0UlMEElMjAlQzIlQTAlM0NQcm9wZXJ0eUdyb3VwJTIwQ29uZGl0aW9uJTNEJTIyJTIwJTI3JTI0JTI4UGxhdGZvcm0lMjklMjclMjAlM0QlM0QlMjAlMjd4NjQlMjclMjAlMjIlM0UlMEElMjAlQzIlQTAlQzIlQTAlQzIlQTAlM0NSZWZlcmVuY2VQYXRoJTNFQyUzQSU1Q1Byb2dyYW0lMjBGaWxlcyUyMCUyOHg4NiUyOSU1Q0t2YXNlciU1Q0NhbmxpYiU1Q2RvdG5ldCU1Q3g2NCU1Q2Z3NDAlNUMlM0MlMkZSZWZlcmVuY2VQYXRoJTNFJTBBJTIwJUMyJUEwJTNDJTJGUHJvcGVydHlHcm91cCUzRSUwQSUzQyUyRlByb2plY3QlM0U="][vc_column_text]I added a PropertyGroup with a condition (x64). This group will override the first PropertyGroup if I have selected x64 as platform. It is important that you add the x64 group after the general group. Please, remember to check the path to the two DLL files.[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Microsoft Visual C++ and canlibCLSNET Redistributable"][vc_column_text]When installing your app on another machine (might not have Visual Studio installed), please remember to redistribute (and install) the “Microsoft Visual C++ Redistributable for Visual Studio 2017”. You will need to copy the canlibCLSNET.dll (x86 and/or x64) with your project executable. These dlls are not installed as part of the driver (they are part of KVASER CANlib SDK). Thanks for reading this! If you have any questions or comment regarding this paper, please send a mail to [email protected]. [/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="Build and Run platform x86 and x64"][vc_column_text]I can now select x86 (win32) and x64 (win64) as active platforms, in both cases the application starts correctly and CANlib is available and working. If everything worked well, you will also be able to create an VB dotNET CANlib application in Visual Studio 2017. We have now enabled CANlib in Visual Studio 2017, created a VB .NET project and tested it for both x86 and x64.  ΟΕΔ  (Q.E.D.  Quod erat demonstrandum)[/vc_column_text][vc_raw_html]JTNDYnIlMjAlMkYlM0U=[/vc_raw_html][/vc_column][/vc_row] [post_title] => Using CANlib Visual Studio 2017 VB canlibCLSNET [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => using-canlib-visual-studio-2017-vb [to_ping] => [pinged] => [post_modified] => 2023-05-29 06:05:35 [post_modified_gmt] => 2023-05-29 06:05:35 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=22588 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [4] => WP_Post Object ( [ID] => 32005 [post_author] => 4840 [post_date] => 2021-03-05 14:31:42 [post_date_gmt] => 2021-03-05 14:31:42 [post_content] => [vc_row][vc_column][vc_column_text]In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a Visual Basic (VB) project. I will show how to create WIN32 and WIN64 applications. I will also show how to handle the platform-settings: x86 and x64. When this is done, you can use the same project (source code) for creating WIN32 and WIN64 applications without editing your code. The instructions in this document can also be used when enabling CANlib in an existing project.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Important information from the author: Since CANLib version 5.30, the support for canlibCLSNET has been removed. Instead we now supports “.NET Standard 2.0” This text is based on the Dev Blog: Using CANlib Visual Studio 2017 VB canlibCLSNET. It has been modified for “.NET Standard 2.0” and now shows how to use the “.NET Standard 2.0” framework together with “.NET Framework 4.7.2”. Some of the picture is not replaced, so they might still point to “canlibCLSNET”.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="1 Abbreviations"][vc_column_text]"VS2017":  Microsoft Visual Studio 2017 (VB) "CANlib":  Kvaser CANlib SDK (kvaser.com/download)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="2 Before we start..."][vc_column_text]First we must download and install “Kvaser CANlib SDK“ and also “Kvaser Drivers for Windows”. After you have installed CANlib, please check your hard-drive and identify where “canlibCLSNET.DLL” has been installed. On my 64-bit Windows machine it is installed here: c:\Program Files (x86)\Kvaser\Canlib\dotnet\win32\netstandard2.0\Kvaser.CanLib.dll c:\Program Files (x86)\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll As you can see, one is for building 32-bit and one is for 64-bit applications. Please remember where you found them, as you will need this information soon. Now we are ready to start Visual Studio 2017 (VB). (I have used “Microsoft Visual Studio Professional 2017 (version 15.9.33)” when creating this text.)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="3 Creating an empty project"][vc_column_text]Creating a project in VS can be done in many different ways, this is one way to do it. Press, “File” - “New” -”Project…”[/vc_column_text][vc_single_image image="32006"][vc_column_text]I chose to create:
  • Windows Forms App (.NET Framework) Visual Basic
Edit the name and the rest of the unique information and press “OK”. Using “.NET Standard 2.0” requires “.NET Framework 4.6.1” or higher. Many developers recommend using “.NET Framework 4.7.2” or higher because of better stability and compatibility.[/vc_column_text][vc_single_image image="32007"][vc_column_text]Now VS2017 creates an application for us. It is a bit boring, just an empty form that does almost nothing.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="4 Adding some code that uses CANlib (VB)"][vc_column_text]I will now add some code that uses CANlib; exactly what it does is not important in this example. For more information about how to use CANlib, please check CANlib SDK Help. To add a BUTTON and a TEXTBOX, change the property “Multiline” on the textbox to true. (I assume that you are familiar with how to add components in VS2017, I will not show it here). After a bit of editing, we have this beautiful application:[/vc_column_text][vc_single_image image="32008"][vc_column_text]It still does nothing, so in the editor, double click on “button1” and add some code inside the “button1_Click” function.[/vc_column_text][vc_code_raket code="UHJpdmF0ZSUyMFN1YiUyMEJ1dHRvbjFfQ2xpY2slMjhzZW5kZXIlMjBBcyUyME9iamVjdCUyQyUyMGUlMjBBcyUyMEV2ZW50QXJncyUyOSUyMEhhbmRsZXMlMjBCdXR0b24xLkNsaWNrJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwVGV4dEJveDEuVGV4dCUyMCUzRCUyMCUyMkhlbGxvJTIwVmlzdWFsJTIwQmFzaWMlMjAuTmV0JTIwJTI4YzIwMjElMjBLdmFzZXIlMjBBQiUyMiUyMCUyNiUyMHZiTmV3TGluZSUwQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMEt2YXNlci5DYW5MaWIuQ2FubGliLmNhbkluaXRpYWxpemVMaWJyYXJ5JTI4JTI5JTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTI3RGltJTIwY2hhbm5lbCUyMEFzJTIwSW50ZWdlciUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMERpbSUyMGNoYW5uZWwlMjAlM0QlMjAwJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwRGltJTIwaG5kMCUyMEFzJTIwSW50ZWdlciUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMERpbSUyMFIlMjBBcyUyMEt2YXNlci5DYW5MaWIuQ2FubGliLmNhblN0YXR1cyUwQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGhuZDAlMjAlM0QlMjBLdmFzZXIuQ2FuTGliLkNhbmxpYi5jYW5PcGVuQ2hhbm5lbCUyOGNoYW5uZWwlMkMlMjBLdmFzZXIuQ2FuTGliLkNhbmxpYi5jYW5PUEVOX0FDQ0VQVF9WSVJUVUFMJTI5JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwUiUyMCUzRCUyMEt2YXNlci5DYW5MaWIuQ2FubGliLmNhblNldEJ1c1BhcmFtcyUyOGhuZDAlMkMlMjBLdmFzZXIuQ2FuTGliLkNhbmxpYi5jYW5CSVRSQVRFXzI1MEslMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTI5JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwUiUyMCUzRCUyMEt2YXNlci5DYW5MaWIuQ2FubGliLmNhbkJ1c09uJTI4aG5kMCUyOSUwQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFRleHRCb3gxLlRleHQlMjAlMkIlM0QlMjAlMjJDaGFubmVsJTIwMCUyMGFuZCUyMDElMjBpbml0aWF0ZWQlMjIlMjAlMjYlMjB2Yk5ld0xpbmUlMEElMEElMjAlMjAlMjAlMjBFbmQlMjBTdWIlMEE="][vc_column_text]When I try to run the application, I get multiple errors. Something is wrong and VS2017 cannot find 'Kvaser.CanLib’. We will fix that, but first we must set the platforms.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="5 Enabling the WIN32 and WIN64 platforms"][vc_column_text]When creating an VB application, VB defaults to “Any CPU” as the target CPU platform. We can not use Any CPU as platform because we can only link to one version of “Kvaser.CanLib.dll”. We must now enable the x86 (win32) and the x64 (win64) platforms. Select “Configuration Manager…”:[/vc_column_text][vc_single_image image="32009"][vc_column_text]Select “<New…>” and add x86 and x64:[/vc_column_text][vc_single_image image="32010"][vc_column_text]Important: Use the “new” from the “Active solutions platform”, not from “Project contexts”. Create the new platforms x64 and x86 (we will have to do this twice). Copy settings from “any CPU”:[/vc_column_text][vc_single_image image="32011"][vc_column_text]I do this for x86 and x64. I also delete the AnyCPU platform to make sure that I not enabling it by mistake in the future (select EDIT and remove it). Now I must edit the configuration manager to make sure that we are using the correct platform.[/vc_column_text][vc_single_image image="32012"][vc_column_text]In the picture above, we can see that even if we have selected the combination DEBUG/x86, the compiler will try to create the platform “Any CPU”. This time I select NEW from “Project contexts”[/vc_column_text][vc_single_image image="32013"][vc_column_text]Create the platform x86. Do this for all four combinations: Debug/x86    Use x86 Debug/x64 Use x64 Release/x86 Use x86 Release/x64 Use x64[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="6 Verifying Target CPU and setting output path"][vc_header_raket header_type="h3" header="6.1 Open PROJECT/PROPERTIES"][vc_column_text]I can open the PROPERTIES in two different ways: 1 Meny: Project / appname properties 2 Solution Explorer, right click on the appname, select properties.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_single_image image="32014"][/vc_column][vc_column width="1/2"][vc_single_image image="32015"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]In some versions of Visual Studio, there is a bug in the properties page when it is opened with the first method. This bug sometimes claims that the platform is not selectable. If we use the second method, then the page works perfect. Check that Target CPU is correct for all four Configuration/Platform combinations.[/vc_column_text][vc_single_image image="32016"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="6.2 Set Build Output Path(Optional)"][vc_column_text]When we are checking the Target CPU, we can also (if we want) edit the output path. Default is: bin\x86\Release\ bin\x64\Debug\ bin\x64\Release\ bin\x86\Debug\ I prefer: bin\Debug\x86\ bin\Debug\x64\ bin\Release\x86\ bin\Release\x64\ I think this makes it a bit easier for me to find the built applications.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="7 Adding a reference to Kvaser.CanLib.dll"][vc_column_text]In order to use CANlib in a VS2017 project, I must add information to show where VS2017 can find “Kvaser.CanLib.dll”. It is only possible to add a reference to either the x86 version or the x64 version. However, with a minor modification in one file, we can enable both. I will show that later in this document.[/vc_column_text][vc_column_text]Select “x86” as platform:[/vc_column_text][vc_single_image image="32017"][vc_column_text]When I try to BUILD, then I get the errors:[/vc_column_text][vc_single_image image="32018"][vc_column_text]Yes, I am missing a “Reference” I must add the “Reference” to Kvaser.CanLib.dll[/vc_column_text][vc_header_raket header_type="h3" header="7.1 Adding Kvaser.CanLib.dll for x86"][vc_column_text]Right click on “References”, and select “Add Reference…”:[/vc_column_text][vc_single_image image="32019"][vc_column_text]Select Browse and then click on the button “Browse…”:[/vc_column_text][vc_single_image image="32020"][vc_column_text](If you have done this before, then VS2017 will show canlibCLSNET.dll in the window as you can see in my example.) Select “c:\...\...\win32\netstandard2.0\Kvaser.CanLib.dll ” (Hope you remembered it):[/vc_column_text][vc_single_image image="32021"][vc_column_text]I am selecting the WIN32 version (even if I intend to use the WIN64 at a later date). Press the “OK” button. Now I can see that the Kvaser.CanLib reference has been added:[/vc_column_text][vc_single_image image="32022"][vc_column_text]If I try to BUILD and RUN the application, it works! When I press Button1, something will appear in the textbox:[/vc_column_text][vc_single_image image="32023"][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="7.2 Adding Kvaser.CanLib.dll for x64"][vc_column_text]Select x64 as platform[/vc_column_text][vc_single_image image="32024"][vc_column_text]If I try to build the application, no errors or warnings will appear. But some warnings and errors when I try to run the application.[/vc_column_text][vc_single_image image="32025"][vc_column_text](Sorry about the errortext in Swedish!) I can only add one version of Kvaser.CanLib.dll. So I must remove the reference to the x86 version, before I add the x64 version. (Please wait a bit to remove the reference, we can keep it and manually enable both x86 and x64. I will show it in section 7.4)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="7.3 Remove reference to Kvaser.CanLib.dll"][vc_column_text](Please do not remove the reference, continue with section 7.4 !) Remove the reference by right clicking on it and select REMOVE[/vc_column_text][vc_single_image image="32026"][vc_column_text]When the reference is removed, I can add the reference to x64. Follow the same procedure as in section 7.1[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h3" header="7.4 Manually adding Kvaser.CanLib for x86 and x64 "][vc_column_text]It is possible to add the reference for Kvaser.CanLib.dll for both x86 and x64 at the same time. When building the application, the correct version will be used and no errors or warnings shall appear. I will show two methods, one manual and one automatic version. Both versions work fine and which one you should select depends more how you later decide to handle your software.  The manual method (section 7.4.1) gives you more control of the version and you must manually copy the dll files in the future when updating to newer SDK versions.  The automatic version (section 7.4.2) copies the latest installed SDK files and includes them into your project. If you are unsure, use the automatic version, you can switch methods whenever you want.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="7.4.1 Manually adding canlibCLSNET for x86 and x64"][vc_column_text]Before we start, add the reference for x86 and test it with BUILD and RUN. (Please read section 7.4.2 before trying this method) When VS2017 is building the application, it also copies the canlibCLSNET.DLL to the application directory. If we turn this feature off, and manually copies the DLL files, then  we can use the x86 reference for both x86 and x64 platform In Solution explorer/references, select canlibCLSNET[/vc_column_text][vc_single_image image="32027"][vc_column_text]Change the property “Copy Local” to false. When I build my application, I get four directories: .\WindowsApp1\bin\Debug\x86\ .\WindowsApp1\bin\Debug\x64\ .\WindowsApp1\bin\Release\x86\ .\WindowsApp1\bin\Release\x64\ Copy the file canlibCLSNET.dll to the four directories above (make sure that you copy the x86 version to the x86 platform directory, and the x64 version to the x64 directory)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h4" header="7.4.2 Automatic adding canlibCLSNET for x86 and x64"][vc_column_text]I want VS2017 to automatically select the correct version of canlibCLSNET.dll when I build my project. (I assume that you have followed the example and skipped section 7.4.1) I have found one method to do it (there might be more methods). In my directory structure for the project, there is a file we can edit: WindowsApp1.csproj.user (ProjName.csproj.user) But I can not find it! Where is it? OK, no problem. It is not created by default, only when needed. Let us create it! This file is little like Harry Potter’s “Room of Requirement”; it can be almost whatever we want it to be.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]7.4.2.1 Creating the file “ProjName.csproj.user”[/vc_column_text][vc_column_text]Open “Project” - “ProjName Properties…” as described in section 6.1[/vc_column_text][vc_single_image image="32028"][vc_column_text]Go to the section “References” and press the button “Reference Path…”[/vc_column_text][vc_single_image image="32029"][vc_column_text]Press button “Browse”[/vc_column_text][vc_single_image image="32030"][vc_column_text]Select directory: ”c:\Program Files (x86)\Kvaser\Canlib\dotnet\win32\fw40\”[/vc_column_text][vc_single_image image="32031"][vc_column_text]Press the button “Add Folder”[/vc_column_text][vc_single_image image="32032"][vc_column_text]Press the “OK” button[/vc_column_text][vc_single_image image="32033"][vc_column_text]I save my project and close VS2017.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]7.4.2.2 Editing the file “ProjName.csproj.user”[/vc_column_text][vc_column_text]Now, when I check my project directory, I can find the file “ProjName.csproj.user”. Open it in a text editor, and my file looks like this: (Please note, this file can contain a lot of information, so it is necessary to locate the part where the “ReferencePath” has been defined.)[/vc_column_text][vc_code_raket code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMGVuY29kaW5nJTNEJTIydXRmLTglMjIlM0YlM0UlMEElM0NQcm9qZWN0JTIwVG9vbHNWZXJzaW9uJTNEJTIyMTUuMCUyMiUyMHhtbG5zJTNEJTIyaHR0cCUzQSUyRiUyRnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyRmRldmVsb3BlciUyRm1zYnVpbGQlMkYyMDAzJTIyJTNFJTBBJTIwJTIwJTNDUHJvcGVydHlHcm91cCUzRSUwQSUyMCUyMCUyMCUyMCUzQ1JlZmVyZW5jZVBhdGglM0VDJTNBJTVDUHJvZ3JhbSUyMEZpbGVzJTIwJTI4eDg2JTI5JTVDS3Zhc2VyJTVDQ2FubGliJTVDZG90bmV0JTVDd2luMzIlNUNuZXRzdGFuZGFyZDIuMCU1QyUzQyUyRlJlZmVyZW5jZV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Q=="][vc_column_text]I added a PropertyGroup with a condition (x64). This group will override the first PropertyGroup if I have selected x64 as platform. It is important that you add the x64 group after the general group. Please, remember to check the path to the two DLL files.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="8 Build and Run platform x86 and x64"][vc_column_text]I can now select x86 (win32) and x64 (win64) as active platforms, in both cases the application starts correctly and CANlib is available and working. If everything worked well, you will also be able to create an VB dotNET CANlib application in Visual Studio 2017. We have now enabled CANlib in Visual Studio 2017, created a VB .NET project and tested it for both x86 and x64.  ΟΕΔ  (Q.E.D.  Quod erat demonstrandum)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="9 Microsoft Visual C++ and canlibCLSNET Redistributable"][vc_column_text]When installing your app on another machine (might not have Visual Studio installed), please remember to redistribute (and install) the “Microsoft Visual C++ Redistributable for Visual Studio 2017”. You will need to copy the canlibCLSNET.dll (x86 and/or x64) with your project executable. These dlls are not installed as part of the driver (they are part of KVASER CANlib SDK). Thanks for reading this! If you have any questions or comment regarding this paper, please send a mail to [email protected][/vc_column_text][/vc_column][/vc_row] [post_title] => Using CANlib Visual Studio 2017 VB .NET Standard 2.0 [post_excerpt] => This Dev Blog describes how to enable Kvaser's CANlib in Visual Studio 2017 when creating a Visual Basic (VB) project (both WIN32 and WIN64 applications). [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => using-canlib-visual-studio-2017-vb-net-standard-2-0 [to_ping] => [pinged] => [post_modified] => 2021-03-18 14:31:46 [post_modified_gmt] => 2021-03-18 14:31:46 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=32005 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [5] => WP_Post Object ( [ID] => 31981 [post_author] => 4840 [post_date] => 2021-03-05 12:25:43 [post_date_gmt] => 2021-03-05 12:25:43 [post_content] => [vc_row][vc_column][vc_column_text]In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a C# .NET project. I will show how to create WIN32 and WIN64 applications. I will also show how to handle the platform-settings: x86, x64. When this is done, you can use the same project (source code) for creating WIN32 and WIN64 applications without editing your code. The instructions in this document can also be used when enabling CANlib in an existing project.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Important information from the author: Since CANLib version 5.30, the support for canlibCLSNET has been removed. Instead we now supports “.NET Standard 2.0” This text is based on the BLOG: Using CANlib Visual Studio 2017 C#.NET. It has been modified for “.NET Standard 2.0” and now shows how to use the “.NET Standard 2.0” framework together with “.NET Framework 4.7.2”. Some of the picture is not replaced, so they might still point to “canlibCLSNET”.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="1 Abbreviations"][vc_column_text]VS2017 Microsoft Visual Studio 2017 (C# .NET) CANlib Kvaser CANlib SDK www.kvaser.com/downloads-kvaser[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="2 Before we start..."][vc_column_text]First we must download and install “Kvaser CANlib SDK“ and also “Kvaser Drivers for Windows”. After you have installed CANlib, please check your hard-drive and identify where “Kvaser.CanLib.dll”has been installed. On my 64-bit Windows machine it is installed here: c:\Program Files (x86)\Kvaser\Canlib\dotnet\win32\netstandard2.0\Kvaser.CanLib.dll c:\Program Files (x86)\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll[/vc_column_text][vc_column_text]As you can see, one is for building 32-bit and one is for 64-bit applications. Please remember where you found them, as you will need this information soon. Now we are ready to start Visual Studio 2017 (C# .NET). (I have used “Microsoft Visual Studio Professional 2017 (version 15.9.33)” when creating this text.)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="3 Creating an empty project"][vc_column_text]Creating a project in VS can be done in many different ways, this is one way to do it. Press, “File” - “New” -”Project…”[/vc_column_text][vc_single_image image="31982"][vc_column_text]I chose to create:
  • Windows Forms App (.NET Framework) Visual C#
Edit the name and the rest of the unique information and press “OK”. Using “.NET Standard 2.0” requires “.NET Framework 4.6.1” or higher. Many developers recommend using “.NET Framework 4.7.2” or higher because of better stability and compatibility.[/vc_column_text][vc_single_image image="31983"][vc_column_text]Now VS2017 creates an application for us. It is a bit boring, just an empty form that does nothing.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="4 Adding some code that uses CANlib (C#)"][vc_column_text]I will now add some code that uses CANlib; exactly what it does is not important in this example. For more information about how to use CANlib, please check CANlib SDK Help. To add a BUTTON and a TEXTBOX, change the property “Multiline” on the textbox to true. (I assume that you are familiar with how to add components in VS2017, I will not show it here). After a bit of editing, we have this beautiful application:[/vc_column_text][vc_single_image image="31985"][vc_column_text]It still does nothing, so in the editor, double click on “button1” and add some code inside the “button1_Click” function.[/vc_column_text][vc_code_raket code="JTIwcHJpdmF0ZSUyMHZvaWQlMjBidXR0b24xX0NsaWNrJTI4b2JqZWN0JTIwc2VuZGVyJTJDJTIwRXZlbnRBcmdzJTIwZSUyOSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMENhbmxpYi5jYW5TdGF0dXMlMjBSJTNCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaW50JTIwViUzQiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRleHRCb3gxLkNsZWFyJTI4JTI5JTNCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGV4dEJveDEuVGV4dCUyMCUzRCUyMCUyMkRFTU8lMjBWUzIwMTclMjBDJTIzJTIwLk5FVCU1Q3IlNUNuJTIyJTNCJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIw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wJTIwJTIwdGV4dEJveDEuVGV4dCUyMCUyQiUzRCUyMCUyMi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0lNUNyJTVDbiUyMiUzQiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3RCUyMCUyMCUyMCUwQQ=="][vc_column_text]When I try to run the application, I get multiple errors. Something is wrong and VS2017 cannot find CANlib.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="5 Adding a reference to canlibCLSNET.dll"][vc_column_text]In order to use CANlib in a VS2017 project, we must add information to show where VS2017 can find “Kvaser.CanLib.dll”.  It is only possible to add a reference to either the x86 version or the x64 version. However, with a minor modification in one file, we can enable both. I will show that later in this document. Before I start, I select the platform to “Any CPU” (for the moment, it is the only platform I have enabled in this application). Select “Any CPU” as platform:[/vc_column_text][vc_single_image image="32004"][vc_column_text]Add the text “using canlibCLSNET;” in the USING clauses:[/vc_column_text][vc_single_image image="31987"][vc_column_text]Add the text “using Kvaser.CanLib;” in the USING clauses:[/vc_column_text][vc_single_image image="31989"][vc_column_text]When I try to BUILD, then I get the errors: The type or namespace name 'Kvaser' could not be found (are you missing a using directive or an assembly reference?) The type or namespace name 'Canlib' could not be found (are you missing a using directive or an assembly reference?) Yes, I am missing a “Reference” I must add the “Reference” to Kvaser.CanLib[/vc_column_text][vc_column_text]Right click on “References”, and select “Add Reference…”:[/vc_column_text][vc_single_image image="31990"][vc_column_text]Select Browse and then click on the button “Browse…”:[/vc_column_text][vc_single_image image="31991"][vc_single_image image="31992"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text](If you have done this before, then VS2017 will show Kvaser.CanLib.dllin the window as you can see in my example.) Select “c:\...\...\win32\netstandard2.0\Kvaser.CanLib.dlll”[/vc_column_text][vc_single_image image="31993"][vc_column_text]I am selecting the WIN32 version (even if I intend to use the WIN64 at a later date). Press the “OK” button. Now I can see that the Kvaser.CAnLib reference has been added:[/vc_column_text][vc_single_image image="31994"][vc_column_text]If I try to BUILD and RUN the application, it works! (sometimes) If I press Button1, something will appear in the textbox:[/vc_column_text][vc_single_image image="31995"][vc_column_text]Sometimes I get a WARNING, and sometimes I get an ERROR. I am not sure why I get the warning or error, because I should always get the error. (I am running my application on a WIN64 PC and the result should be an error. Maybe the compiler tries to save me.) But, there is a simple fix to this little problem, and while I fix it, I also add support for using the WIN32 and WIN64 application platforms. Keep on reading ...[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="6 Enabling CANlib for WIN32 and WIN64"][vc_column_text]So far, I have set “Any CPU” as the target CPU platform. Now I want to set it to the platforms so I can build applications for x86 (win32) and x64 (win64). Select “Configuration Manager…”:[/vc_column_text][vc_single_image image="31996"][vc_column_text]Select “<New…>” and add x86 and x64:[/vc_column_text][vc_single_image image="31997"][vc_column_text]Important: Use the “new” from the “Project contexts”, not from “Active solutions platform”. Copy settings from “any CPU”:[/vc_column_text][vc_single_image image="31998"][vc_column_text]I do this for x86 and x64 and then return to the main IDE.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="7 Testing x86 and x64"][vc_column_text]Select “x86” and press “Start”:[/vc_column_text][vc_single_image image="31999"][vc_column_text]It works! The application starts (but I get a warning).[/vc_column_text][vc_column_text]Select “x64” and press “Start”:[/vc_column_text][vc_single_image image="32000"][vc_column_text]I got a warning, but expected an error. This is normal and will be fixed in the next section. OK, now the situation has been improved a lot. We can select the platform, and sometimes we get a warning and sometimes an error. I said earlier that I should fix this, and now this seems to be a proper time to do that.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="8 Setting PATH for Kvaser.CanLib WIN32 and WIN64"][vc_column_text]I want VS2017 to automatically select the correct version of “Kvaser.CanLib.dll” when I build my project. I have found one method to do it (there might be more methods). In my directory structure for the project, there is a file we can edit: CANlib_VS2017_DEMO.csproj.user (ProjName.csproj.user) But I can not find it! Where is it? OK, no problem. It is not created by default, only when needed. Let us create it! This file is little like Harry Potter’s “Room of Requirement”; it can be almost whatever we want it to be. Open “Project” - “ProjName Properties…”:[/vc_column_text][vc_single_image image="32001"][vc_column_text]Go to the section “Reference Paths” and add the path to the WIN32 “Kvaser.CanKib dll”. Please remember to press the button “Add Folder”.[/vc_column_text][vc_single_image image="32002"][vc_column_text]I save my project and close VS2017. Now, when I check my project directory, I can find the file “ProjName.csproj.user”. Open it in a text editor, and my file looks like this: (Please note, this file can contain a lot of information, so it is necessary to locate the part where the “ReferencePath” has been defined.)[/vc_column_text][vc_code_raket code="JTNDJTNGeG1sJTIwdmVyc2lvbiUzRCUyMjEuMCUyMiUyMGVuY29kaW5nJTNEJTIydXRmLTglMjIlM0YlM0UlMEElM0NQcm9qZWN0JTIwVG9vbHNWZXJzaW9uJTNEJTIyMTUuMCUyMiUyMHhtbG5zJTNEJTIyaHR0cCUzQSUyRiUyRnNjaGVtYXMubWljcm9zb2Z0LmNvbSUyRmRldmVsb3BlciUyRm1zYnVpbGQlMkYyMDAzJTIyJTNFJTBBJTIwJTIwJTNDUHJvcGVydHlHcm91cCUzRSUwQSUyMCUyMCUyMCUyMCUzQ1JlZmVyZW5jZVBhdGglM0VDJTNBJTVDUHJvZ3JhbSUyMEZpbGVzJTIwJTI4eDg2JTI5JTVDS3Zhc2VyJTVDQ2FubGliJTVDZG90bmV0JTVDd2luMzIlNUNmdzQwJTVDJTNDJTJGUmVmZXJlbmNlUGF0aCUzRSUwQSUyMCUyMCUyMCUyMCUzQ1JlZmVyZW5jZVBhdGglM0VDJTNBJTVDUHJvZ3JhbSUyMEZpbGVzJTIwJTI4eDg2JTI5JTVDS3Zhc2VyJTVDQ2FubGliJTVDZG90bmV0JTVDd2luMzIlNUMlM0MlMkZSZWZlcmVuY2VQYXRoJTNFJTIwJTIwJTBBJTIwJTIwJTNDJTJGUHJvcGVydHlHcm91cCUzRSUwQSUzQyUyRlByb2plY3QlM0UlMEE="][vc_column_text]I am now adding some lines, and when I am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W5jZVBhdGglM0UlMEElMjAlMjAlMjAlMjAlM0NSZWZlcmVuY2VQYXRoJTNFYyUzQSU1Q1Byb2dyYW0lMjBGaWxlcyUyMCUyOHg4NiUyOSU1Q0t2YXNlciU1Q0NhbmxpYiU1Q2RvdG5ldCU1Q3g2NCU1Q25ldHN0YW5kYXJkMi4wJTVDJTNDJTJGUmVmZXJlbmNlUGF0aCUzRSUwQSUyMCUyMCUzQyUyRlByb3BlcnR5R3JvdXAlM0UlMEElM0MlMkZQcm9qZWN0JTNFJTBB"][vc_column_text]I added a PropertyGroup with a condition (x64). This group will override the first PropertyGroup if I have selected x64 as platform. It is important that you add the x64 group after the general group. Please, remember to check the path to the two DLL files.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="9 Selecting platform x86, x64 and AnyCPU"][vc_column_text]I can now select x86 (win32) and x64 (win64) as active platforms, in both cases the application starts correctly and CANlib is available and working. If everything worked well, you will also be able to create an C# dotNET CANlib application in Visual Studio 2017. We have now enabled CANlib in Visual Studio 2017, created a C# .NET project and tested it for both x86 and x64. ΟΕΔ  (Q.E.D.  Quod erat demonstrandum)[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_header_raket header_type="h2" header="10 Thoughts and FAQ"][vc_header_raket header_type="h3" header="10.1 Can I use AnyCPU? "][vc_column_text]When I select AnyCPU as a platform, I get a warning or an error! When the computer starts Visual Studio, if I have selected AnyCPU, the software will decide whether to use the 32bit or 64bit version of the DLL. Yes, AnyCPU might work, but if I run the built application on another machine, with a different setup, it might not work. (Dynamic loading of the DLL might work, please check this external link for more information: https://stackoverflow.com/questions/108971/using-side-by-side-assemblies-to-load-the-x64-or-x32-version-of-a-dll)[/vc_column_text][vc_header_raket header_type="h3" header="10.2 Safest setup? "][vc_column_text]If I select x86 (WIN32) built application, it will run on both WIN32 and WIN64 machines.[/vc_column_text][vc_header_raket header_type="h3" header="10.3 Do I need WIN64?"][vc_column_text]If your application needs it, CANlib will work perfectly, but only on WIN64 machines. However, today (2021), the majority of Windows PCs are win64. Thanks for reading this! If you have any questions or comment regarding this paper, please send a mail to [email protected][/vc_column_text][/vc_column][/vc_row] [post_title] => Using CANlib Visual Studio 2017 C# .NET Standard 2.0 [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => using-canlib-visual-studio-2017-c-net-standard-2-0 [to_ping] => [pinged] => [post_modified] => 2021-03-18 14:15:55 [post_modified_gmt] => 2021-03-18 14:15:55 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?post_type=developer_blog&p=31981 [menu_order] => 0 [post_type] => developer_blog [post_mime_type] => [comment_count] => 0 [filter] => raw ) [6] => WP_Post Object ( [ID] => 31889 [post_author] => 22955 [post_date] => 2021-03-01 19:34:10 [post_date_gmt] => 2021-03-01 19:34:10 [post_content] => [vc_row][vc_column][vc_single_image image="31891"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]Kvaser partner Mach System’s has a new configurable CAN-LIN gateway ECU with up to two CAN/CAN FD channels, a LIN channel, and several multi-purpose digital/analogue inputs and outputs. The control unit can be used as a stand-alone data converter between a CAN/CAN FD network and LIN bus, or as a remote I/O module to interface sensors and actuators to CAN and LIN systems.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]Commented Miroslav Machacek, Managing Director of Mach Systems s.r.o: “We saw a gap in the market for an industrial/automotive-grade ECU with CAN-LIN gateway functionality, particularly for demanding environments such as tractors or other machinery. Later this year, the plan is to homologate it in Europe for use in road vehicles.”[/vc_column_text][vc_column_text]The Kvaser Hybrid dual channel interface makes for an ideal partner to configure the ECU over CAN or test the ECU’s behaviour. For more information, contact Mach Systems or view more product details here.[/vc_column_text][/vc_column][vc_column width="1/2"][vc_single_image image="31890"][/vc_column][/vc_row] [post_title] => Mach Systems introduces a CAN-LIN Gateway ECU [post_excerpt] => New configurable CAN-LIN gateway ECU with up to two CAN/CAN FD channels, a LIN channel, and several multi-purpose digital/analogue inputs and outputs. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => mach-systems-introduces-a-can-lin-gateway-ecu [to_ping] => [pinged] => [post_modified] => 2022-12-23 02:01:48 [post_modified_gmt] => 2022-12-23 02:01:48 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=31889 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [7] => WP_Post Object ( [ID] => 31896 [post_author] => 6 [post_date] => 2021-02-26 08:43:45 [post_date_gmt] => 2021-02-26 08:43:45 [post_content] => [vc_row][vc_column][vc_single_image image="21662"][vc_column_text]Kvaser's latest software release extends support for CAN FD, such as virtual CAN FD and ISO-TP FD channels within J2534. A new autobaud programming feature enables sampling at high frequencies. Notable changes and additions include: Kvaser Drivers for Windows and Linux CANlib SDK J2534 support now includes CAN FD and ISO-TP FD virtual channels, which will need to be enabled using the latest J2534 Options Tool. An updated file handling API (kvDiag API) now allows developers to run autobaud programming to sample at high frequencies. See the new chapter in CANlib Help for details. The SDK has been updated to the latest BLF format (4.9.4.0), compatible with CAN FD. The new converter format ensures that users won’t set parameters that aren’t supported. For MDF4 files, a new feature ensures that no existing files will ever be overwritten. A new predefined bitrate, with 80% sample point - better suited to CAN FD - can now be found within the IDE that’s included in Kvaser’s CANlib SDK. Python CANlib package Continued improvements to accommodate CAN FD, such as the new predefined bitrate with 80% sample point. If you are using CAN FD and haven’t yet updated to the latest version of Python CANlib, we suggest you do so. SocketCan Drivers Our Linux implementation has been updated according to SocketCAN's most recent release candidate. Full release notes are available and all files are available for download now on the Kvaser Downloads page.[/vc_column_text][/vc_column][/vc_row] [post_title] => Kvaser’s February 2021 Software Release [post_excerpt] => Kvaser's latest software release extends support for CAN FD, such as virtual CAN FD and ISO-TP FD channels within J2534. A new autobaud programming feature enables sampling at high frequencies. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => kvasers-september-2020-software-release-2 [to_ping] => [pinged] => [post_modified] => 2022-04-04 10:19:13 [post_modified_gmt] => 2022-04-04 10:19:13 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=31896 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [8] => WP_Post Object ( [ID] => 31728 [post_author] => 38 [post_date] => 2021-02-25 19:28:39 [post_date_gmt] => 2021-02-25 19:28:39 [post_content] => [vc_row][vc_column][vc_single_image image="31729"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text] Udoka Electronics, an independent software provider based in the Gothenburg region, has joined Kvaser’s TA network. Founded by Olof Wolgast, Udoka Electronics’ software tools are the product of his many years of experience developing embedded control systems or ECUs for the likes of Volvo and GM.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="2/3"][vc_column_text]‘Efficient and intuitive’ is how Wolgast describes Sumac, a new calibration and measurement tool that can be used throughout the design cycle.[/vc_column_text][/vc_column][vc_column width="1/3"][vc_single_image image="31808"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]“Sumac lacks the overhead of 20-years of complicated user requests and software development – it isn’t overengineered and is fast to learn,” says Wolgast, who in addition to automotive OEMS and suppliers considers research institutes and small companies developing machinery with embedded control systems e.g., two and three-wheel vehicles, golf carts, electric lawnmowers, chainsaws etc, as ideal potential customers.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]Udoka’s first software suite, Acam, automates A2L creation from C/C++, merge, address update and filter. Both packages can be used independently, fitting into existing toolchains, but they also work well together with Sumac automatically reloading the latest A2L file produced by Acam - useful when building rapid prototypes or with a team working according to agile processes.[/vc_column_text][vc_column_text]For more information, please visit udokaelectronics.com.[/vc_column_text][/vc_column][vc_column width="1/2"][vc_single_image image="31730"][/vc_column][/vc_row] [post_title] => Udoka Electronics joins Kvaser’s TA network [post_excerpt] => Udoka Electronics, an independent software provider based in the Gothenburg region, has joined Kvaser’s TA network. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => udoka-electronics-joins-kvasers-ta-network [to_ping] => [pinged] => [post_modified] => 2024-04-03 06:52:32 [post_modified_gmt] => 2024-04-03 06:52:32 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=31728 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [9] => WP_Post Object ( [ID] => 31499 [post_author] => 23 [post_date] => 2021-01-30 00:53:09 [post_date_gmt] => 2021-01-30 00:53:09 [post_content] => [vc_row][vc_column][vc_single_image image="31504"][vc_column_text]Kvaser Technical Associate, Warwick Control Technologies, has released the CAN CAN FD LIN Simulation Kit, a new package that pairs Warwick Control’s X-Analyser network analysis software with the Kvaser Hybrid Pro for device/network simulation, including SAE J1939, NMEA2000 and CANopen higher layer protocol simulation.  The Kvaser Hybrid’s two channels can be mapped to X-Analyser in any combination of these network protocols, making it a versatile and cost-effective toolset for testing CAN, CAN FD and LIN systems. It is also possible to simulate CAN and CAN FD networks on one interface channel using the Kvaser t-script programming language, whilst conducting network monitoring in X-Analyser on the other channel.  Kvaser’s TRX IDE has a t-script compiler and a console in which status messages can be fed back by language commands such as printf. Programming examples, such as how to integrate CANdb files and control the LEDs on the Kvaser Memorator, come with the kit but Warwick Control also provides a t-programming course for those needing help to unleash the power of their Kvaser Pro interfaces! The kit comprises:[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]
  • X-Analyser Professional software
  • Kvaser Hybrid Pro interface
  • A 4 channel Hub for CAN CAN FD and LIN with external power
  • Programming examples for network simulation in Kvaser’s t-script programming language
  • A carrying case
[/vc_column_text][vc_column_text]For details, please visit the X-Analyser website or contact Warwick Control at [email protected].[/vc_column_text][/vc_column][/vc_row] [post_title] => All-in-one CAN, CAN FD & LIN Simulation Kit [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => all-in-one-can-can-fd-lin-simulation-kit [to_ping] => [pinged] => [post_modified] => 2021-02-02 00:53:48 [post_modified_gmt] => 2021-02-02 00:53:48 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=31499 [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] => 32321 [post_author] => 38 [post_date] => 2021-03-23 18:39:59 [post_date_gmt] => 2021-03-23 18:39:59 [post_content] => [vc_row][vc_column][vc_single_image image="32324"][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]MathWorks and Kvaser are hosting a joint webinar to support customers using MATLAB's Vehicle Network Toolbox to transition to CAN FD. This webinar will walk through the challenges of migrating to CAN FD, showing how to leverage the technology using MathWorks’ Vehicle Network Toolbox and Kvaser hardware. The presenters will introduce the basic concepts of CAN FD, compare classical CAN to CAN FD and show how to decode and visualise CAN FD signals, with a demonstration of the new MATLAB features for CAN FD. The 1-hour session, designed for engineers working at the software level, will be co-presented by Jaremy Pyle, Development Manager, Automotive Connectivity at MathWorks and Kent Lennartsson, Research Manager at Kvaser AB. Wednesday, April 7 8a PST / 11a ET / 17:00 CET 1-Hour Webinar (includes 15min Q&A)[/vc_column_text][vc_button_raket title="Register Now" text="" page_id="https://attendee.gotowebinar.com/register/5553864542155748363?source=Kvaser"][/vc_column][/vc_row] [post_title] => Webinar: CAN FD Data Acquisition and Visualization with MATLAB and Kvaser Hardware [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => webinar-can-fd-data-acquisition-and-visualization-with-matlab-and-kvaser-hardware [to_ping] => [pinged] => [post_modified] => 2022-06-14 12:15:27 [post_modified_gmt] => 2022-06-14 12:15:27 [post_content_filtered] => [post_parent] => 0 [guid] => https://www.kvaser.com/?p=32321 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [comment_count] => 0 [current_comment] => -1 [found_posts] => 469 [max_num_pages] => 47 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => 1 [is_privacy_policy] => [is_404] => [is_embed] => [is_paged] => 1 [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_favicon] => [is_posts_page] => 1 [is_post_type_archive] => [query_vars_hash:WP_Query:private] => 6c4b5969ea18a396da154a53c38de7b1 [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

Webinar: CAN FD Data Acquisition and Visualization with MATLAB and Kvaser Hardware

23/03/2021

MathWorks and Kvaser are hosting a joint webinar to support customers using MATLAB’s Vehicle Network Toolbox to transition to CAN… Read More

Read More
How to connect to a specific Kvaser CAN channel

How to connect to a specific Kvaser CAN channel

22/03/2021

In this document I will show how to connect to a unique Kvaser CAN channel, using a nickname instead of… Read More

Read More
Using CANlib  Visual Studio 2017 C#.NET (canlibCLSNET)

Using CANlib Visual Studio 2017 C#.NET (canlibCLSNET)

09/03/2021

In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a C# .NET… Read More

Read More
Using CANlib  Visual Studio 2017 VB canlibCLSNET

Using CANlib Visual Studio 2017 VB canlibCLSNET

08/03/2021

In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a Visual Basic… Read More

Read More
Using CANlib Visual Studio 2017 VB .NET Standard 2.0

Using CANlib Visual Studio 2017 VB .NET Standard 2.0

05/03/2021

In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a Visual Basic… Read More

Read More
Using CANlib  Visual Studio 2017  C# .NET Standard 2.0

Using CANlib Visual Studio 2017 C# .NET Standard 2.0

05/03/2021

In this document I will show you how to enable CANlib in Visual Studio 2017 when creating a C# .NET… Read More

Read More

Mach Systems introduces a CAN-LIN Gateway ECU

01/03/2021

Kvaser partner Mach System’s has a new configurable CAN-LIN gateway ECU with up to two CAN/CAN FD channels, a LIN… Read More

Read More
Kvaser’s February 2021 Software Release

Kvaser’s February 2021 Software Release

26/02/2021

Kvaser’s latest software release extends support for CAN FD, such as virtual CAN FD and ISO-TP FD channels within J2534.… Read More

Read More
Udoka Electronics joins Kvaser’s TA network

Udoka Electronics joins Kvaser’s TA network

25/02/2021

Udoka Electronics, an independent software provider based in the Gothenburg region, has joined Kvaser’s TA network. Founded by Olof Wolgast,… Read More

Read More
All-in-one CAN, CAN FD & LIN Simulation Kit

All-in-one CAN, CAN FD & LIN Simulation Kit

30/01/2021

Kvaser Technical Associate, Warwick Control Technologies, has released the CAN CAN FD LIN Simulation Kit, a new package that pairs… Read More

Read More