串行通信的Arduino到PHP [英] Serial Communication Arduino to PHP

查看:156
本文介绍了串行通信的Arduino到PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm在其中我想通过串行通讯从Arduino的发送传感器数据到PHP的一个项目工作。

I´m working on a project in which I want to send sensor data from Arduino via Serial Communication to PHP.

可惜我不能读PHP串行端口。然而,另一个方向(PHP来的Arduino)完美的作品。
I'm使用 php_serial.class。从雷米·桑切斯PHP ,由RIZWAN卡西姆修改。 I'm依赖从readPort() - 的功能。

Unfortunately I can not read the Serial Port in PHP. However the other direction (PHP to Arduino) works perfectly. I´m using the php_serial.class.php from Rémy Sanchez, modified by Rizwan Kassim. I´m dependant from the readPort() - function.

I'm有一个Arduino UNO和Apache WAMP - 服务器在Mac OS X工作
我应该意识到没有以太网屏蔽串行连接。在进一步的步骤,我不得不从串口接收到的数据保存在MySQL数据库。
我确实看到一对夫妇涉及这个问题的条目,但他们鸵鸟政策真正帮助我。我曾尝试了这么多。
我敢肯定,有人有一些工作codeS和可以将它们上传。
我究竟做错了什么?
我希望有人将张贴code,或有一个提示!

I´m working with an Arduino UNO and Apache WAMP-Server on Mac OS X. I should realise the serial connection without Ethernet shield. In further steps I have to save the received data from the serial port in a MySql database. I have indeed seen a couple of entries covering this issue, but they don´t really help me. I have tried so much. I´m sure, someone has some working codes and can upload them. What am I doing wrong? I hope someone will post the code or has a tip!

顺便说一句, 是从一个人的视频谁成功了。但我不能得到codeS ....
预先感谢您的咨询!

By the way, here is a video from a guy who succeeded. But I can´t get the codes.... Thanks in advance for your advice!

映入眼帘的Fab

推荐答案

在php_serial.class.php是种坏了,我不得不去适应它得到一个读出来,这样反而利用读卡器以下方法:
$内容=; $ I = 0;

the php_serial.class.php is kind of broken, i had to adapt it to get a reading out of it, so instead of using the following from the reader method: $content = ""; $i = 0;

                    if ($count !== 0)
                    {
                            do {
                                    if ($i > $count) $content .= fread($this->_dHandle, ($count - $i));
                                    else $content .= fread($this->_dHandle, 128);
                            } while (($i += 128) === strlen($content));
                    }
                    else
                    {
                            do {
                                    $content .= fread($this->_dHandle, 128);
                            } while (($i += 128) === strlen($content));
                    }

我曾经就这

     //trigger_error("reading 0 ".$i, E_USER_WARNING);
     $content .= fread($this->_dHandle, $count);


     return str_split($content);

然后重新构建在PHP中的字节串

then reconstruct the byte string in php

这篇关于串行通信的Arduino到PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆