arduino+W5100+php交互问题

浏览:556 发布日期:2019/02/25 分类:求助交流 关键字: arduino W5100 服务器 交互 单片机
本人在做一个门禁系统,通过arduino的W5100 GET方法发数据给服务器,arduino串口端收到的信息如下:

arduino代码如下:
void setup() {
pinMode(IC_Card, OUTPUT);
pinMode(elec_relay, OUTPUT);
digitalWrite(IC_Card,HIGH);
Serial.begin(9600);
led_out_put("APManagement");
Serial.println("APManagement");
//Serial.println("Failed to configure Ethernet using DHCP");
// Check for Ethernet hardware present
if (Ethernet.linkStatus() == linkOFF) {
led_out_put("Ethernet cable is not connected.");
}
Ethernet.begin(mac, ip, myDns);
delay(1000);

if (client.connect(server,80)) {
led_out_put("Send Message...");
Serial.println("Send Message...");
client.println("GET /index.php/index/mcucommu/getcode1");
client.println("HTTP/1.1");
client.println("Host:192.168.76.67");
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
led_out_put("Connection Failed");
}

}

void loop() {
if(client.available()) {
char c = client.read();
Serial.print(c);
}

if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
led_out_put("disconnecting");
client.stop();

// do nothing forevermore:
while(true);
}
}
一直没有成功,我把服务器端传参都省略了。
<?php
namespace app\index\controller;
use think\Controller;
use think\Request;

class Mcucommu extends Controller{

public function getCode(){
/*- $request = Request::instance();
$mcu_ip=$request->ip(); //获取访问IP地址
$request->get();
$code=$request->param('id');
$ip_arry=config('mcu_ip'); //从配置文件获取注册MCU ip地址
$flag=false;
foreach ($ip_arry as $key => $value){
if($mcu_ip==$value){ //遍历IP地址是否存在
$flag=true;
break;
}
}
if ($flag){

return $code;

}else{
return 'error';
}-*/

return 'ok';

}

}
在电脑上访问getCode方法是好的,但单片机上就不行,IIS服务器的log也看了,GET方法和PC上的一样,但是传入和传出数据量相差很大。
最佳答案
评论( 相关
后面还有条评论,点击查看>>