<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[SDS PLC/PAC: Měření Energie & OnlineTechnology.cz - Ovladani pomoci UDP paketu odeslaneho z PHP]]></title>
	<link rel="self" href="https://forum.sds.an-d.cz/extern.php?action=feed&amp;tid=260&amp;type=atom" />
	<updated>2012-05-23T07:18:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.sds.an-d.cz/viewtopic.php?id=260</id>
		<entry>
			<title type="html"><![CDATA[Re: Ovladani pomoci UDP paketu odeslaneho z PHP]]></title>
			<link rel="alternate" href="https://forum.sds.an-d.cz/viewtopic.php?pid=1870#p1870" />
			<content type="html"><![CDATA[<p>Taaak to nevím. Nemohu sloužit. Je to laborování na dlouhé večery. Možná jen popostrčení co jsem kdysi použil v .NET......</p><p>Z nápovědy PHP bych asi použil toto:</p><p>A simple example how to send a raw udp packet</p><p>&lt;?php<br />$frame = array(<br />&nbsp; &nbsp; array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1),<br />&nbsp; &nbsp; array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1),<br />&nbsp; &nbsp; array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),<br />&nbsp; &nbsp; array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),<br />&nbsp; &nbsp; array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),<br />&nbsp; &nbsp; array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),<br />&nbsp; &nbsp; array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1),<br />&nbsp; &nbsp; array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1)<br />);</p><p>send_frame($frame, 1500);</p><p>/**<br /> * Sends 18x8 MCUF-UDP packet to target host.<br /> *<br /> * see also:<br /> * wiki.blinkenarea.org/index.php/MicroControllerUnitFrame<br /> *<br /> * @param array&nbsp; &nbsp; $frame 18x8 &#039;0&#039; or &#039;1&#039;<br /> * @param int&nbsp; &nbsp; $delay delay in msec<br /> * @param string&nbsp; &nbsp; $host target host<br /> * @param int&nbsp; &nbsp; $port target port (udp)<br /> */<br />function send_frame($frame, $delay, $host=&quot;192.168.0.23&quot;, $port=2323) {<br />&nbsp; &nbsp; $header = &quot;\x23\x54\x26\x66\x00\x08\x00\x12\x00\x01\x00\xff&quot;;<br />&nbsp; &nbsp; $buf = $header;<br />&nbsp; &nbsp; for ($i=0;$i&lt;8;$i++) {<br />&nbsp; &nbsp; &nbsp; &nbsp; for ($j=0;$j&lt;18;$j++) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($frame[$i][$j]) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $buf.=&quot;\xff&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else&nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $buf.=&quot;\x00&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);<br />&nbsp; &nbsp; socket_sendto($socket, $buf, strlen($buf), 0, $host, $port);<br />&nbsp; &nbsp; socket_close($socket);<br />&nbsp; &nbsp; usleep($delay*1000);<br />}<br />?&gt;</p><br /><p>Data naplnit něčím jako je toto:</p><p>&nbsp; &nbsp; ReDim SendData(67 + (Values.Length / 2) * 8)<br />&nbsp; &nbsp; SendData(0) = &amp;H0<br />&nbsp; &nbsp; SendData(1) = &amp;H41<br />&nbsp; &nbsp; SendData(2) = &amp;H4E<br />&nbsp; &nbsp; SendData(3) = &amp;H2D<br />&nbsp; &nbsp; SendData(4) = &amp;H44<br />&nbsp; &nbsp; SendData(5) = &amp;H2E<br />&nbsp; &nbsp; SendData(6) = &amp;H63<br />&nbsp; &nbsp; SendData(7) = &amp;H7A<br />&nbsp; &nbsp; SendData(8) = &amp;H2F<br />&nbsp; &nbsp; SendData(9) = &amp;H53<br />&nbsp; &nbsp; SendData(10) = &amp;H44<br />&nbsp; &nbsp; SendData(11) = &amp;H53<br />&nbsp; &nbsp; SendData(12) = &amp;H2<br />&nbsp; &nbsp; SendData(13) = &amp;H6<br />&nbsp; &nbsp; SendData(14) = &amp;H0<br />&nbsp; &nbsp; SendData(15) = &amp;H77<br />&nbsp; &nbsp; SendData(16) = &amp;H72<br />&nbsp; &nbsp; SendData(17) = &amp;H72<br />&nbsp; &nbsp; SendData(18) = &amp;H61<br />&nbsp; &nbsp; SendData(19) = &amp;H6D<br />&nbsp; &nbsp; SendData(20) = &amp;H0<br />&nbsp; &nbsp; SendData(21) = &amp;H0<br />&nbsp; &nbsp; SendData(22) = &amp;H0<br />&nbsp; &nbsp; SendData(23) = &amp;H0<br />&nbsp; &nbsp; SendData(24) = &amp;H0<br />&nbsp; &nbsp; SendData(25) = &amp;H0<br />&nbsp; &nbsp; SendData(26) = &amp;H0<br />&nbsp; &nbsp; SendData(27) = &amp;H1</p><p>&nbsp; &nbsp; &#039;delka hesla<br />&nbsp; &nbsp; SendData(28) = &amp;H0<br />&nbsp; &nbsp; SendData(29) = &amp;H0<br />&nbsp; &nbsp; SendData(30) = &amp;H0<br />&nbsp; &nbsp; SendData(31) = gPSW.Length<br />&nbsp; &nbsp; &#039;kodovani hesla<br />&nbsp; &nbsp; For n = 0 To 31<br />&nbsp; &nbsp; &nbsp; If n &lt; gPSW.Length Then<br />&nbsp; &nbsp; &nbsp; &nbsp; SendData(32 + n) = &amp;HA5 Xor Asc(Mid(gPSW, n + 1, 1))<br />&nbsp; &nbsp; &nbsp; Else<br />&nbsp; &nbsp; &nbsp; &nbsp; SendData(32 + n) = &amp;H0<br />&nbsp; &nbsp; &nbsp; End If<br />&nbsp; &nbsp; Next</p><p>&nbsp; &nbsp; &#039;pocet paru<br />&nbsp; &nbsp; D2H(Values.Length / 2, dword)&nbsp; &#039;rozlozi na hex pary<br />&nbsp; &nbsp; SendData(64) = Val(dword(0))<br />&nbsp; &nbsp; SendData(65) = Val(dword(1))<br />&nbsp; &nbsp; SendData(66) = Val(dword(2))<br />&nbsp; &nbsp; SendData(67) = Val(dword(3))</p><p>&nbsp; &nbsp; &#039;pary 4x index + 4x value<br />&nbsp; &nbsp; nn = 0<br />&nbsp; &nbsp; For n = 68 To 68 + ((Values.Length / 2) - 1) * 8 Step 8<br />&nbsp; &nbsp; &nbsp; D2H(Values(0, nn), dword)&nbsp; &#039;index do ram<br />&nbsp; &nbsp; &nbsp; SendData(n + 0) = Val(dword(0))<br />&nbsp; &nbsp; &nbsp; SendData(n + 1) = Val(dword(1))<br />&nbsp; &nbsp; &nbsp; SendData(n + 2) = Val(dword(2))<br />&nbsp; &nbsp; &nbsp; SendData(n + 3) = Val(dword(3))<br />&nbsp; &nbsp; &nbsp; D2H(Values(1, nn), dword)&nbsp; &#039;hodnota<br />&nbsp; &nbsp; &nbsp; SendData(n + 4) = Val(dword(0))<br />&nbsp; &nbsp; &nbsp; SendData(n + 5) = Val(dword(1))<br />&nbsp; &nbsp; &nbsp; SendData(n + 6) = Val(dword(2))<br />&nbsp; &nbsp; &nbsp; SendData(n + 7) = Val(dword(3))<br />&nbsp; &nbsp; &nbsp; nn = nn + 1<br />&nbsp; &nbsp; Next</p>]]></content>
			<author>
				<name><![CDATA[j@m]]></name>
				<uri>https://forum.sds.an-d.cz/profile.php?id=5</uri>
			</author>
			<updated>2012-05-23T07:18:12Z</updated>
			<id>https://forum.sds.an-d.cz/viewtopic.php?pid=1870#p1870</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Ovladani pomoci UDP paketu odeslaneho z PHP]]></title>
			<link rel="alternate" href="https://forum.sds.an-d.cz/viewtopic.php?pid=1757#p1757" />
			<content type="html"><![CDATA[<p>Vite nekdo jak presne sestavit UPD paket v PHP pomoci funkce socket_create <a href="http://php.net/manual/en/function.socket-create.php">http://php.net/manual/en/function.socket-create.php</a> tak, aby paket byl ve spravnem tvaru, jak je pozadovano zde ? <a href="http://wiki.merenienergie.cz/index.php/UDP_protocol">http://wiki.merenienergie.cz/index.php/UDP_protocol</a></p><p>Chtel bych pomoci PHP sestavit UDP paket, kterym chci sepnout rele c2. Tedy potrebuji odeslat prikaz typy write na sys[232].</p><p>Mate nekdo? Muzete prosim postnout funkcni verzi kodu? Mnohokrat diky.</p>]]></content>
			<author>
				<name><![CDATA[stejk]]></name>
				<uri>https://forum.sds.an-d.cz/profile.php?id=60</uri>
			</author>
			<updated>2012-04-21T16:53:34Z</updated>
			<id>https://forum.sds.an-d.cz/viewtopic.php?pid=1757#p1757</id>
		</entry>
</feed>
