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.li
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上的一样,但是传入和传出数据量相差很大。
最佳答案