用串口通讯,如果采用vc,vb,delphi这个问题就比较容易解决,现在有个想法就是用php来做,这样的话就出现两个大的问题,一个是页面的刷新,一个是串口通讯。请大家来讨论,这种做法可行吗?刷新页面是否可以通过ajax来做呢?
解决方案 »
- 解决bom问题,现在session又失效了,令人费解!!!!!
- 字段加索引的问题,在线等
- php冒泡排序主要应用在那些方面,如何去掌握比较好呢
- 求助:想做一个广告联盟,大概要投入多少钱?
- 一个最基础的Hello World问题!
- 各位大虾有没有关于PHP教学方面的课程超市或教学大纲!!
- 寻求ADODB连接远程服务器上的ACCESS数据库的方法~~ 在线等待~~ 分不是问题 :-)
- 谁那有好用点的英文论坛,高分求购.
- 紧急求助,在线等待!!!
- 谁知道用什么函数可以把字符型转成字符的ASCII码的10进制或16进制的数?
- 如何把mysql转化成sql server
- php网站怎么和discuz 论坛整合?
php官方站点提供了sample
link:http://jp.php.net/manual/zh/function.fopen.php
2.可以用ajax来刷新页面sample:
<?php
// HOW TO USE PHP TO WRITE TO YOUR SERIAL PORT: TWO METHODS
$serproxy=true;
if ($serproxy) {
// Use this code in conjunction with SERPROXY.EXE
// (http://www.lspace.nildram.co.uk/freeware.html)
// which converts a Serial stream to a TCP/IP stream
$fp = fsockopen ("localhost", 5331, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)";
} else {
$e = chr(27);
$string = $e . "A" . $e . "H300";
$string .= $e . "V100" . $e . "XL1SATO";
$string .= $e . "Q1" . $e . "Z";
echo $string;
fputs ($fp, $string );
fclose ($fp);
}
} elseif ($com1) {
// Use this code to write directly to the COM1 serial port
// First, you want to set the mode of the port. You need to set
// it only once; it will remain the same until you reboot.
// Note: the backticks on the following line will execute the
// DOS 'mode' command from within PHP
`mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
$fp = fopen ("COM1:", "w+");
if (!$fp) {
echo "Uh-oh. Port not opened.";
} else {
$e = chr(27);
$string = $e . "A" . $e . "H300";
$string .= $e . "V100" . $e . "XL1SATO";
$string .= $e . "Q1" . $e . "Z";
echo $string;
fputs ($fp, $string );
fclose ($fp);
}
}
?>
2. 用c编写服务在服务器运行,接收串口数据,更新数据库
3. ajax定请求检测数据库,数据更新则返回新数据,完成页面刷新(比如颜色改变、参数值改变)这样的好处就是多处监控只需要在服务器安装一套程序,方便维护。