【问题标题】:arduino ethernet server connection detectarduino 以太网服务器连接检测
【发布时间】:2015-03-29 21:58:57
【问题描述】:

我正在使用 Arduino 和配置为远程登录服务器的 Ethernet Shield。

是否可以在客户端未发送任何字符的情况下检测客户端何时连接? server.available() 方法仅在有数据可供读取时才返回客户端对象。

【问题讨论】:

    标签: arduino telnet ethernet


    【解决方案1】:

    你可以试试这个例子:

    include <SPI.h>
    #include <Ethernet.h>
    #include <CapSense.h>
    
    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local network:
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    byte ip[] = { 192, 168, 84, 3 };
    
    #define encoderGSMask B00000001
    #define encoderGSPin 8
    
    // Initialize the Ethernet server library
    Server server(8423);
    
    void setup() {   
    
     pinMode(encoderGSPin, INPUT); //Encoder GS
     digitalWrite(encoderGSPin, HIGH);
    
     Serial.begin(115200);
    
     // start the Ethernet connection and the server:
     Ethernet.begin(mac, ip);
     server.begin();  
    }
    
    void loop(){
    
       if ((PINB&encoderGSMask)==0)
       {
         server.write('S');   //Sync
         server.write(1);     //Rev 1
         server.write('B');   //Message Type
         server.write(0x01);  //Button ID
    
         delay(1000);
       }    
     }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多