hello
i want to make rfid reader for scan item in a shopping storage. some time rfid read 10 or more tag in 1 second . i have to use this senario :
1 : scan RFID
2 : Open TCP Socket From Arduino To Server(port 1050 on PC)
3 : Send TAG ID + Some Data to Server
4 : if item expire date is over server response
5 : Close TCP
6 : check telnet server(port 1060 On arduino) on arduino for received some data from PC
i check telnet server and client example but if open/close tcp fast, Ethernet shield will not close port correctly and after 4-5 minute all 4 socket on shied is in open mode and cant open new socket.(open close 20 time in 1-2 second for test)
also check httpclient sample but it is tooo slow . each request take 1000~1300 mili second to open and close. request send fast to server but when i want read response in arduino it take too much time.
what is best solution for me ?
my board : Mega2560
Ethernet Shield : W5100
RFID Reader : RC522
TCP Server on PC Programming language: C#
also check httpclient sample but it is tooo slow . each request take 1000~1300 mili second to open and close. request send fast to server but when i want read response in arduino it take too much time.
int startTime = millis();
httpClient.setHttpResponseTimeout(500);
int err = 0;
err = httpClient.get(kPath); // Take 20~25 mili
if (err == 0)
{
Serial.println("startedRequest ok");
err = httpClient.responseStatusCode(); //Take 1100~1250 mili just on time,
//other read() dont take much time . if delete this line other read() take 1200~ milis !!
if (err >= 0)
{
Serial.print("Got status code: ");
Serial.println(err);
// Usually you'd check that the response code is 200 or a
// similar "success" code (200-299) before carrying on,
// but we'll print out whatever response we get
// If you are interesting in the response headers, you
// can read them here:
while(httpClient.headerAvailable())
{
String headerName = httpClient.readHeaderName();
String headerValue = httpClient.readHeaderValue();
Serial.print(headerName);
Serial.print(": ");
Serial.println(headerValue);
}
int bodyLen = httpClient.contentLength();
Serial.print("Content length is: ");
Serial.println(bodyLen);
Serial.println();
Serial.println("Body returned follows:");
// Now we've got to the body, so we can print it out
unsigned long timeoutStart = millis();
char c;
// Whilst we haven't timed out & haven't reached the end of the body
while ((httpClient.connected() || httpClient.available()) &&
(!httpClient.endOfBodyReached()) &&
((millis() - timeoutStart) < kNetworkTimeout))
{
if (httpClient.available())
{
c = httpClient.read();
// Print out this character
// Serial.print(c);
// We read something, reset the timeout counter
timeoutStart = millis();
}
else
{
// We haven't got any data, so let's pause to allow some to
// arrive
delay(kNetworkDelay);
}
}
}
else
{
Serial.print("Getting response failed: ");
Serial.println(err);
}
}
else
{
Serial.print("Connect failed: ");
Serial.println(err);
}
httpClient.stop();
int endTime = millis();
int avgTime= endTime - startTime;
Serial.println(avgTime);
if i try to read response it take too much time . when i check with socket, this server will response in 100-150 milis . but socket will down after few minute if i try to open/close socket fast . i check and w5100 all socket all are open when i see connect failed message .