当前位置: 首页>>代码示例>>C++>>正文


C++ EthernetClient::read方法代码示例

本文整理汇总了C++中EthernetClient::read方法的典型用法代码示例。如果您正苦于以下问题:C++ EthernetClient::read方法的具体用法?C++ EthernetClient::read怎么用?C++ EthernetClient::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EthernetClient的用法示例。


在下文中一共展示了EthernetClient::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loop

void loop() {
  client = server.available();
  if (client) {                
    while (client.connected()) {
      if (client.available()) {
        if (client.find("GET /")) {
          
          //INICIAR CRONOMETRAGEM
          if (client.find("setCron=")) {
            int charReaded = client.read();
			if(charReaded == 49){
              iniciarCronometragem();
            }
          }
		  
		   //RETORNA O TEMPO DESDE O INICIO		  
          if (client.find("getCron=")) {
            int charReaded = client.read();
			if(charReaded == 49){
              getCronometragem();
			}
          }
        }
      }
      Serial.println();
      break;
    }
    client.println(" HTTP/1.1 200 OK ");
  }
  // give the web browser time to receive the data
  delay(1);
  client.stop();
}
开发者ID:SoftsquareBr,项目名称:telemetria,代码行数:33,代码来源:ArduinoCode2.cpp

示例2: GAE

String GAE(String link) {
	httpRequest(link);
	delay(10000);

	String readString = ""; //Reset string

	while (client.available() > 0) {

		char s = client.read();
		//Serial.print(s);			//Complete response w/ headers. For dev mode.
		if (s== '\n') {
			char c = client.read();
			//Serial.print(c);			//Parsed response. For dev mode.
			if (c == '\r') {
				while (client.connected()) {
					char z = client.read();
					readString += z;
				}
			}
		}
	}
	client.stop();
	return(readString);

}
开发者ID:niskyponics,项目名称:niskyponics-arduino,代码行数:25,代码来源:txt_messaging.c

示例3: read

void MyClientManager::read(EthernetClient client)
{
  int data_size = client.available();
  int x = 0;

  if (headeroffset != 3 && data_size + headeroffset >= HEADER_SIZE)
  {
    while (headeroffset != HEADER_SIZE && x < data_size)
    {
      header[headeroffset] = client.read();
      ++headeroffset;
      ++x;
    }

    if (headeroffset == 3 && header[2] + 1 > BUFFER_SIZE)
      reset();
  }
  else if (headeroffset == 3 && bufferoffset != header[2] && data_size + bufferoffset >= header[2])
  {
    while (bufferoffset != header[2] && x < data_size)
    {
      buffer[bufferoffset] = client.read();
      ++bufferoffset;
      ++x;
    }
  }
  else if (headeroffset == 3 && bufferoffset == header[2] && !checksumisset && data_size > 0)
  {
    checksum = client.read();
    checksumisset = true;
  }
}
开发者ID:islog,项目名称:rpleth-relay,代码行数:32,代码来源:MyClient.cpp

示例4: readStream

void Parser::readStream(EthernetClient client,char* myreadstring) {
  char c = 0; //carctère de lecture
  char tempo[255];
  bool currentLineIsBlank = true;
  int n = 1;
  int flag = 0;

  for (int k = 0; k < 50; k++) tempo[k] = 0;
  c = client.read(); //lecture du premier caractère;
  if (c != (-1)) {
    if ( c == 'G') {
      flag = 1;
      tempo[0] = c;
      while (c != '\n') {
        c = client.read(); //lecture du caractère
        delay(5);
        tempo[n] = c;
        delay(5);
        n++;
      }
    }
    else {
      tempo[0] = '¤';
      tempo[1] = '?';
      while (client.available() > 0) {
        c = client.read();
        if (c == '\n' && currentLineIsBlank) {
          while (c != '\r') { //doute
            c = client.read(); //lecture du caractère

            delay(5);
            if (c == (-1))
              break;
            tempo[n + 1] = c;
            delay(5);
            n++;
          }
        }
        else if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
  }

  if (!flag)n++;

  for (int j = 0; j < n; j++)
    myreadstring[j] = tempo[j] ;

}
开发者ID:technologiescollege,项目名称:arduino,代码行数:56,代码来源:Parser.cpp

示例5: printClient

void printClient(EthernetClient client){
  int i=0;
    char c = client.read();
    while(c != '\n' && c != '\r'){	
    buffer[i] = c;		
    i++;
    c = client.read();		
  }
  for(int j=0; j<i; j++){
  Serial.write(buffer[j]);
  }
}
开发者ID:SoftsquareBr,项目名称:telemetria,代码行数:12,代码来源:ArduinoCode2.cpp

示例6: task

void ModbusIP::task() {
    EthernetClient client = _server.available();

    if (client) {
        if (client.connected()) {
            int i = 0;
            while (client.available()){
                _MBAP[i] = client.read();
                i++;
                if (i==7) break;  //MBAP length has 7 bytes size
            }
            _len = _MBAP[4] << 8 | _MBAP[5];
            _len--;  // Do not count with last byte from MBAP

            if (_MBAP[2] !=0 || _MBAP[3] !=0) return;   //Not a MODBUSIP packet
            if (_len > MODBUSIP_MAXFRAME) return;      //Length is over MODBUSIP_MAXFRAME

            _frame = (byte*) malloc(_len);
            i = 0;
            while (client.available()){
                _frame[i] = client.read();
                i++;
                if (i==_len) break;
            }

            this->receivePDU(_frame);
            if (_reply != MB_REPLY_OFF) {
                //MBAP
                _MBAP[4] = (_len+1) >> 8;     //_len+1 for last byte from MBAP
                _MBAP[5] = (_len+1) & 0x00FF;

                byte sendbuffer[7 + _len];

                for (i = 0 ; i < 7 ; i++) {
                    sendbuffer[i] = _MBAP[i];
                }
                //PDU Frame
                for (i = 0 ; i < _len ; i++) {
                    sendbuffer[i+7] = _frame[i];
                }
                client.write(sendbuffer, _len + 7);
            }

#ifndef TCP_KEEP_ALIVE
            client.stop();
#endif
            free(_frame);
            _len = 0;
        }
开发者ID:EagleSmith,项目名称:modbus-arduino,代码行数:49,代码来源:ModbusIP.cpp

示例7: loop

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();

  // we get a request
  if (client) {
    Serial.println(F("Client connected"));
    // an http request ends with a blank line
    boolean done = false;
    while (client.connected() && !done) {
      while (client.available () > 0 && !done) {
        done = processIncomingByte (client.read ());
      }
    }  // end of while client connected

    // get ROV status values as json string
    String rovStatus = getRovStatus();

    // send a standard http response header
    client.println(F("HTTP/1.1 200 OK"));
    client.println(F("Content-Type: text/json"));
    client.println(F("Connection: close"));  // close after completion of the response
    client.println();   // end of HTTP header
    client.println(rovStatus);

    // give the web browser time to receive the data
    delay(10);
    // close the connection:
    client.stop();
    Serial.println(F("Client disconnected"));
  }  // end of got a new client
}  // end of loop
开发者ID:koppii,项目名称:NimanRov,代码行数:32,代码来源:main.cpp

示例8: efail

void efail()
{
  byte thisByte = 0;
  int loopCount = 0;

  eth_client.println(F("QUIT"));

  while(!eth_client.available()) {
    #ifdef WATCHDOG
    wdt_reset();
    #endif
    delay(1);
    loopCount++;

    // if nothing received for 10 seconds, timeout
    if(loopCount > 10000) {
      eth_client.stop();
      Serial.println(F("\r\nTimeout"));
      return;
    }
  }

  while(eth_client.available())
  {
    thisByte = eth_client.read();
    Serial.write(thisByte);
  }

  eth_client.stop();

  Serial.println(F("disconnected"));
}
开发者ID:777doogy,项目名称:Growduino-firmware,代码行数:32,代码来源:smtp.cpp

示例9: loop

void loop() {
  unsigned long time = millis();
  if (next < time) {
    Ethernet.maintain();
    next += send_delay;
    if (next <= time)
      next = time + 1;
    Serial.println("request time !");
    if (client.connected()) {
      Serial.println("already connected");
    } else {
      Serial.print("connecting results : ");
      Serial.println(client.connect("tarzan.info.emn.fr", 80));
    }
    int sent = client.println("GET /ping.php HTTP/1.1");
    sent = client.println(F("Host: tarzan.info.emn.fr"));
    client.println();
  }
  if (client.connected() && client.available() > 0) {
    Serial.println("client received data  : ");
    unsigned char buffer[buff_size + 1];
    while (client.available() > 0) {
      int read = client.read(buffer, buff_size);
      buffer[read] = '\0';
      Serial.println(read);
    }
  }
  if (radio.receiveDone()) {
  }
}
开发者ID:glelouet,项目名称:Connected_House,代码行数:30,代码来源:TcpClient.cpp

示例10: loop

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) 
  {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) 
    {
      if (client.available()) 
      {
        char c = client.read();
        Serial.write(c);

        //*******************233333333333333333333333333333333333333333333*******
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) 
        {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: textml");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("<ml>");
          break;
        }
        if (c == '\n')
        {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r')
        {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}
开发者ID:Zhuanghq7,项目名称:Socket,代码行数:60,代码来源:1.cpp

示例11: parseRequest

bool PyrobarHTTPRequestHandler::parseRequest(EthernetClient client) {
  if (client.available()) {
    if(client.readStringUntil(' ') == "GET") {
      if(client.read() == '/') {
        String dataType = client.readStringUntil('/');
        if (DEBUG_REQUEST_HANDLER) {
          Serial.print("Data Type: ");
          Serial.println(dataType);
        }
        if(dataType == pyrobarDataTypeBuffer) {
          return handleBuffer(client);
        } else if(dataType == pyrobarDataTypeFire) {
          return handleFireSequence(client);
        } else if(dataType == pyrobarDataTypeScalar) {
          return handleScalar(client);
        } else if(dataType == pyrobarDataTypeLights) {
          return handleLightsOnOff(client);
        } else {
          return false;
        }
      }
    } else {
      return false;
    }
  }
}
开发者ID:johnnylaw,项目名称:Pyrobar-arduino-libraries,代码行数:26,代码来源:PyrobarHTTPRequestHandler.cpp

示例12: getData

void getData(char *dst)
{
  Serial.println("Trying to grab data from server:");
  
  // from the server, read them and print them:
  int i = 0;
  
  while (!client.available());

  while (client.available()) {
    char c = client.read();
    Serial.print(c);
    
    if (i < 10)
    {
      dst[i] = c;
      //dst[i+1] = 0;
    }

    i++;
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while(true);
  }
}
开发者ID:torkildr,项目名称:display,代码行数:32,代码来源:ehternet_utility.cpp

示例13: loop

void loop() {
  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  // if there's no net connection, but there was one last time
  // through the loop, then stop the client:
  if (!client.connected() && lastConnected) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
  }

  // if you're not connected, and ten seconds have passed since
  // your last connection, then connect again and send data:
  if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
    httpRequest();
  }
  // store the state of the connection for next time through
  // the loop:
  lastConnected = client.connected();
}
开发者ID:KISSMonX,项目名称:gr_ethernet_examples,代码行数:26,代码来源:gr_WebClientRepeating.cpp

示例14: if

static void 
extract_status_code(struct HTTPObject *h, EthernetClient client){
    unsigned int k,multiplier,j;
    j=0;
    char c;
    const byte STATUS_CODE_START_INDEX = 9;
    const byte STATUS_CODE_END_INDEX = 11;

    while(j<=STATUS_CODE_END_INDEX && client.connected()){
        if(client.available()){
            // We want to extract the 200 from "HTTP/1.1 200 OK". The 
            // status code starts at index 9 in the string and ends at 11
            c = client.read();
            if(j<STATUS_CODE_START_INDEX){
                j++;
            }
            else if(j>=STATUS_CODE_START_INDEX && j<=STATUS_CODE_END_INDEX){
                // code = 10^2 * str[9] + 10^1 * str[10] + 10^0 * str[11]
                // Do ghetto exponentiation here.
                multiplier = 1;
                for(k = 1; k <= 2 - (j - STATUS_CODE_START_INDEX); k++){
                    multiplier *= 10;
                }
                // c - '0' => char to int
                h->statusCode += (c - '0') * multiplier;
                j++;
            }
        }
    }
}
开发者ID:joequery,项目名称:ArduinoRequests,代码行数:30,代码来源:Requests.cpp

示例15: receiveEthernet

void MorpheusSlave::receiveEthernet(EthernetClient& incoming) {
	if ( incoming.available() )  {
		char b;
		while ( incoming.available() > 0 ) {
			_lastRX = millis();
			b = incoming.read();
#if DBG
			Serial.print("B: ");
			Serial.println(b);
#endif
			if ( b == '\n' ) {
				endComm();
				break;
			}
			else if ( command == NULL ) {
				command = b;
				data = "";
			}
			else {
				data += b;
			}
		}
    }
	
	if ( _lastRX != -1 && millis() - _lastRX > RX_TIMEOUT ) {
		endComm();
	}
}
开发者ID:declanshanaghy,项目名称:Morpheus,代码行数:28,代码来源:MorpheusSlave.cpp


注:本文中的EthernetClient::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。