<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Вычисление CRC16 Modbus]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12233&amp;type=atom" />
	<updated>2016-12-21T19:48:41Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12233</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Вычисление CRC16 Modbus]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109982#p109982" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?id=12240">http://forum.script-coding.com/viewtopic.php?id=12240</a><br />Готовый скрипт.</p>]]></content>
			<author>
				<name><![CDATA[MandarinKa02]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34409</uri>
			</author>
			<updated>2016-12-21T19:48:41Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109982#p109982</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Вычисление CRC16 Modbus]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109932#p109932" />
			<content type="html"><![CDATA[<p>День добрый всем. Проблема в написании скрипта для вычисления CRC16_Modbus/ Перерыл все что можно, ничего не нашел.<br />Единственное, есть скрипт на PHP для такой функции. Может кто поможет его переделать в AHK?</p><div class="codebox"><pre><code>    function modbus_crc($modbus_msg){
        $crctab16 = array(0X0000 .... тут таблица);

        $hexdata = pack(&#039;H*&#039;,$modbus_msg);
        $nLength = strlen($hexdata);
        $fcs = 0xFFFF;
        $pos = 0;
        while($nLength &gt; 0)
        {
            $fcs = ($fcs &gt;&gt; 8) ^ $crctab16[($fcs ^ ord($hexdata[$pos])) &amp; 0xFF];
            $nLength--;
            $pos++;
        }
        $inverted = sprintf(&#039;%04X&#039;, $fcs);
        $crc_modbus = substr($inverted,2,2).&quot; &quot;.substr($inverted,0,2);
        return $crc_modbus;
    }</code></pre></div><p>Входная строка типа &quot;A4 F1 14 D3&quot;<br />Непонятны пару строк:<br />$hexdata = pack(&#039;H*&#039;,$modbus_msg); перевод в бинарную строку<br />ord($hexdata[$pos] ACSII символ строки</p>]]></content>
			<author>
				<name><![CDATA[nezl0in]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34405</uri>
			</author>
			<updated>2016-12-19T13:34:24Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109932#p109932</id>
		</entry>
</feed>
