Difference between revisions of "Talk:Сериен порт"
From Ilianko
(→C#) |
(→php) |
||
Line 1: | Line 1: | ||
==php== | ==php== | ||
+ | Инсталира се ser2net и се конфигурира ser2net.conf | ||
− | + | После се достъпва като стандартен сокет | |
− | |||
− | |||
− | |||
− | |||
− | |||
<code><pre> | <code><pre> | ||
− | |||
− | |||
if(isset($_POST['message'])) | if(isset($_POST['message'])) | ||
{ | { | ||
− | $fp = | + | $fp =fsockopen("localhost", 2000); |
+ | |||
if( !$fp) { | if( !$fp) { | ||
echo "Error";die(); | echo "Error";die(); | ||
} | } | ||
+ | fread($fp, 128); | ||
+ | fwrite($fp, "$_POST[message]"); | ||
+ | $status = fread($fp, 128); | ||
+ | fclose($fp); | ||
+ | |||
− | |||
− | |||
} | } | ||
Line 28: | Line 26: | ||
<form name="serial" action="" method="post"> | <form name="serial" action="" method="post"> | ||
Message: <input name="message" type="text"><input type="submit" value="Send"> | Message: <input name="message" type="text"><input type="submit" value="Send"> | ||
+ | |||
+ | <?= (isset($status))? $status:'' ?> | ||
</form> | </form> | ||
</body> | </body> | ||
</html> | </html> | ||
</pre></code> | </pre></code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== [http://ilianko.com/files/Serial.zip C#] == | == [http://ilianko.com/files/Serial.zip C#] == |
Revision as of 16:31, 25 February 2013
php
Инсталира се ser2net и се конфигурира ser2net.conf
После се достъпва като стандартен сокет
if(isset($_POST['message']))
{
$fp =fsockopen("localhost", 2000);
if( !$fp) {
echo "Error";die();
}
fread($fp, 128);
fwrite($fp, "$_POST[message]");
$status = fread($fp, 128);
fclose($fp);
}
?>
<html><head></head>
<body>
<form name="serial" action="" method="post">
Message: <input name="message" type="text"><input type="submit" value="Send">
<?= (isset($status))? $status:'' ?>
</form>
</body>
</html>