<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>通道号归档 - Kvaser</title>
	<atom:link href="https://www.kvaser.cn/support/developer-blog/tag/%e9%80%9a%e9%81%93%e5%8f%b7/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.kvaser.cn/support/developer-blog/tag/通道号/</link>
	<description>先进的CAN总线解决方案专家</description>
	<lastBuildDate>Wed, 18 Dec 2024 10:14:22 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.kvaser.cn/wp-content/uploads/2024/06/favicon-3.ico</url>
	<title>通道号归档 - Kvaser</title>
	<link>https://www.kvaser.cn/support/developer-blog/tag/通道号/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>CAN手柄 vs 通道号</title>
		<link>https://www.kvaser.cn/developer-blog/can-handle-vs-channel-number/</link>
		
		<dc:creator><![CDATA[Magnus Carlsson]]></dc:creator>
		<pubDate>Wed, 03 Jun 2015 17:22:12 +0000</pubDate>
				<guid isPermaLink="false">http://www.kvaser.cn/?post_type=developer_blog&#038;p=7694</guid>

					<description><![CDATA[<p>The post <a href="https://www.kvaser.cn/developer-blog/can-handle-vs-channel-number/">CAN手柄 vs 通道号</a> appeared first on <a href="https://www.kvaser.cn">Kvaser</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>在撰写&#8221;<a href="http://www.kvaser.cn/developer-blog/canlib-channel-number-card-number/">CANlib通道号还是卡号？</a>&#8220;一文时，有用户评论要求阐明CanHandle和通道号之间的区别，因为它们都可从零开始。</p>
<p>CAN通道使用CANlib中的<code>canOpenChannel()</code>函数打开，将通道号作为第一个参数。</p>

		</div>
	</div>
<pre class="code-toolbar1 code-wrapper line-numbers"><code class="language-c">CanHandle handle;
canStatus stat;

int canLibChannelNumber = 0;

handle = canOpenChannel(canLibChannelNumber, canOPEN_ACCEPT_VIRTUAL);
if (handle &lt; 0) {
  printf(&quot;canOpenChannel failed, status=%d\n&quot;, stat);
}</code></pre>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>这将返回一个可以是任何非负数的句柄（在第一次调用它时通常为零）。手柄稍后会被用到，如当读取下一个可用的CAN报文时。如果调用<code>tocanOpenChannel()</code>失败，将返回负错误代码，而不是有效的句柄。</p>

		</div>
	</div>
<pre class="code-toolbar1 code-wrapper line-numbers"><code class="language-c">long id;
unsigned char data[8];
unsigned int dlc, flags;
unsigned long timestamp;

stat = canRead(handle, &amp;id, data, &amp;dlc, &amp;flags, &amp;timestamp);
if (stat != canERR_NOMSG) {
  printf(&quot;Failed, status == %d\n&quot;, stat);
}</code></pre>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>句柄是内部的正数，不能手动编辑。如前所述，CANlib中返回的<code>CanHandle</code>可能与通道号混淆，但新版库，如kvrlib，则会返回一个更大更随机的数字，以降低混淆的风险。</p>
<p>我建议我们应该养成习惯将句柄声明为<code>CanHandle</code>（而不是int），从而清楚地标记句柄。在此建议的同时，也鼓励大家始终检查返回状态，就像上面对<code>canRead()</code> 所做的那样。当出现错误时，这将有助于缩短调试时间。</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://www.kvaser.cn/developer-blog/can-handle-vs-channel-number/">CAN手柄 vs 通道号</a> appeared first on <a href="https://www.kvaser.cn">Kvaser</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CANlib通道号还是卡号？</title>
		<link>https://www.kvaser.cn/developer-blog/canlib-channel-number-card-number/</link>
		
		<dc:creator><![CDATA[Magnus Carlsson]]></dc:creator>
		<pubDate>Wed, 06 May 2015 17:00:00 +0000</pubDate>
				<guid isPermaLink="false">http://www.kvaser.cn/?post_type=developer_blog&#038;p=7403</guid>

					<description><![CDATA[<p>本文是共包括4部分的技术博客的最后一部分。此博客介绍通过kvmlib，使用第二代Kvaser Memorator数据记录仪，配置和读取已记录的数据</p>
<p>The post <a href="https://www.kvaser.cn/developer-blog/canlib-channel-number-card-number/">CANlib通道号还是卡号？</a> appeared first on <a href="https://www.kvaser.cn">Kvaser</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>当与CANlib交互时，许多功能需要通道的句柄支持。这个通道通常被称为“CANlib通道”，因为这是其在Kvaser硬件中的标签。</p>

		</div>
	</div>
<div class="single-image"><img decoding="async" src="https://www.kvaser.cn/wp-content/uploads/2015/03/devicesinkvaserhardware.png" class="vc_single_image-img  attachment-large" alt="" title="devicesInKvaserHardware" srcset="https://www.kvaser.cn/wp-content/uploads/2015/03/devicesinkvaserhardware.png 694w, https://www.kvaser.cn/wp-content/uploads/2015/03/devicesinkvaserhardware-324x179.png 324w, https://www.kvaser.cn/wp-content/uploads/2015/03/devicesinkvaserhardware-416x230.png 416w, https://www.kvaser.cn/wp-content/uploads/2015/03/devicesinkvaserhardware-300x166.png 300w" sizes="(max-width: 694px) 100vw, 694px" /></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>如果要从Eagle设备上的第一个通道发送CAN报文，我们应该打开CANlib通道3 <code>canopenChannel(3, canOPEN_EXCLUSIVE)</code>。 CANlib中的某些功能与设备上的实际通道无关，因此你可以使用任何设备通道都同样成功。例如，要打开或关闭设备LED，可以调用<code>kvFlashLeds(hnd, kvLED_ACTION_ALL_LEDS_ON)</code>，其中<code>hnd</code>可以是CANlib通道3或4的句柄。那么为什么需要卡号？从历史的角度来看，没有通过Kvaser CANlib与Kvaser设备的所有交互都直接指向驱动程序。在这种情况下，不能使用CANlib通道号，因此需要新的数字来指示，例如“第二个设备”使用驱动程序<code>kcany</code>。这个新号码被称为“卡号”，并在选择设备通道时显示在Kvaser硬件中。</p>

		</div>
	</div>
<div class="single-image"><img decoding="async" src="https://www.kvaser.cn/wp-content/uploads/2015/03/cardnumberinkvaserhardware.png" class="vc_single_image-img  attachment-large" alt="" title="cardNumberInKvaserHardware" srcset="https://www.kvaser.cn/wp-content/uploads/2015/03/cardnumberinkvaserhardware.png 694w, https://www.kvaser.cn/wp-content/uploads/2015/03/cardnumberinkvaserhardware-324x179.png 324w, https://www.kvaser.cn/wp-content/uploads/2015/03/cardnumberinkvaserhardware-416x230.png 416w, https://www.kvaser.cn/wp-content/uploads/2015/03/cardnumberinkvaserhardware-300x166.png 300w" sizes="(max-width: 694px) 100vw, 694px" /></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>在上图中，我们可以看到，作为通道设备5的Kvaser Memorator Pro 5xHS连接到CANlib通道6和卡号2。 CANlib通道和卡号都是从零开始(正如程序员通常所做的那样)，但是因随机生成机制，卡号在Kvaser硬件中显示(仅在Kvaser硬件中)得看起来像是从1开始。所以我们的设备实际上连接到了CANlib通道6卡号1，这意味着我们需要发出命令<code>hydra_flash.exe -C1 imagefile.img</code>以升级此设备的固件。如今，其已成为历史，因为我们通过调用CANlib (<code>canGetChannelData(channel, canCHANNELDATA_CARD_NUMBER, buffer, bufsize)</code>)函数可获得索引卡号0。这也是Python模块kvDevice的工作内容，其可在使用卡号的其它库(如kvmlib)进行交互时位你提供协助。不过，了解了其工作原理会很有意思。</p>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<h3>如果您有任何意见，请发送邮件至support@kvaser.com和我们取得联系。</h3>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://www.kvaser.cn/developer-blog/canlib-channel-number-card-number/">CANlib通道号还是卡号？</a> appeared first on <a href="https://www.kvaser.cn">Kvaser</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
