Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork213
Open
Description
I have an Opta RS485 with code compiled with the following libraries/platform:
Ethernet 1.0.0
SocketWrapper 1.0
arduino:mbed_opta 4.3.1
When running a simple http server (following a simplified version ofhttps://opta.findernet.com/en/tutorial/web-server):
#include<Arduino.h>#include<Ethernet.h>#include<opta_info.h>OptaBoardInfo *info;OptaBoardInfo *boardInfo();// IP address of the Opta server.IPAddressip(192,168,1,12);// Ethernet server on port 80.EthernetServerserver(80);voidsetup(){ Serial.begin(9600); info =boardInfo();// Check if secure informations are available since MAC Address is among them.if (info->magic ==0xB5) {// Assign static IP address. Ethernet.begin(info->mac_address, ip); }else { Serial.println("Error: Secure information not available. Cannot start server.");while (1) { } }// Start the server. server.begin(); Serial.println("Server started");}voidloop(){// Check if any client is available. EthernetClient client = server.available();if (client) {unsignedlong startTime =millis(); Serial.println("Client connected");// Read the HTTP request lineunsignedlong readStart =millis(); String request = client.readStringUntil('\r');unsignedlong readEnd =millis(); client.flush();// Check if it's a GET request to "/"unsignedlong handleStart =millis();if (request.indexOf("GET /") ==0) {sendHomepage(&client); }unsignedlong handleEnd =millis();// Close the connectionunsignedlong stopStart =millis(); client.stop();unsignedlong stopEnd =millis();unsignedlong endTime =millis(); Serial.print("Client disconnected. Total handling time:"); Serial.print(endTime - startTime); Serial.println(" ms"); Serial.print(" Request read time:"); Serial.print(readEnd - readStart); Serial.println(" ms"); Serial.print(" Homepage send time:"); Serial.print(handleEnd - handleStart); Serial.println(" ms"); Serial.print(" Client stop time:"); Serial.print(stopEnd - stopStart); Serial.println(" ms"); }}voidsendHomepage(EthernetClient *client){ String html ="<html><body>Hello, World!</body></html>"; client->println("HTTP/1.1 200 OK"); client->println("Content-Type: text/html"); client->println("Connection: close"); client->println("Content-Length:" +String(html.length())); client->println(); client->println(html); Serial.println("Homepage sent");}
Theclient.readStringUntil('\r')
is consistently around 100ms.
Total handling time: 102 ms Request read time: 101 ms Homepage send time: 1 ms Client stop time: 0 ms
Is there an issue with the mbed Ethernet library?
We want to use the Opta for repeated http requests, but the 100 ms delay is unfortunately unacceptable. Any plug-and-play alternatives or ideas for a fix are welcome. Thank you.
Metadata
Metadata
Assignees
Labels
No labels