Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 510
61  Development / Other Software Development / Re: Library Conflict on: July 08, 2014, 08:44:45 pm
Sorry, I still don't get the concept.
Do I run those code in separate sketch? or Serial.println(freeMemory()); at the end of my sketch?
if the file runs in its own separate sketch, it will of course get a lot of free memory, right? because there is nothing in it.
 smiley-eek

That's just a sample. Try to make it run first so your files are in the correct folder etc. Then do the serial print where your memory is mostly used up, not at the end of a loop. Look for the deepest function call you can find and stick it in there.
62  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 08, 2014, 08:31:00 pm
How do you know it has been 1000 milliseconds? delay(1) is incredible inaccurate. I would try delayMicroseconds(1000); I just save millis() when I start waiting and check it in every loop.
63  Using Arduino / General Electronics / Re: using a SSR photoelectric sensor on: July 08, 2014, 08:28:09 pm
Just this one you may be in luck. If you provided the correct page, the part (1451E-6513) output is a solid state relay. The diagram is on the spec sheet page 1 bottom table, center row. Solid state relay is theorized as a switch that will connect WH and BK when actuated. So you can connect BK to arduino ground, and WH to an arduino pin set as input and enabling internal pullup resistor. Whenever the pin goes low, the photoelectric sensor is triggered. Is this for a machine in a factory?
64  Using Arduino / General Electronics / Re: Why is IOH connector off grid ? on: July 08, 2014, 08:20:53 pm
That UNO looks just like mine, maybe R2 or R1, not R3, right? I have one R2. It has problems with running SD card 50/50 time card won't start.
65  Development / Other Software Development / Re: Library Conflict on: July 08, 2014, 08:14:13 pm
Nah. Save memoryfree.h and memoryfree.cpp in a library folder like other libraries. Then run this code:

Code:
//Example sketch:

#include <MemoryFree.h>

// On Arduino Duemilanove with ATmega328:
//
// Reported free memory with str commented out:
// 1824 bytes
//
// Reported free memory with str and Serial.println(str) uncommented:
// 1810
//
// Difference: 14 bytes (13 ascii chars + null terminator)

// 14-bytes string
//char str[] = "Hello, world!";


void setup() {
    Serial.begin(115200);
}


void loop() {
    //Serial.println(str);

    Serial.print("freeMemory()=");
    Serial.println(freeMemory());

    delay(1000);
}

Both files I mentioned are on that page. You just have to create them and save.
66  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 08, 2014, 08:03:42 pm
The available() that is in the return value in an earlier version of connected() is removed in the latest version of connected()

(s == CLOSE_WAIT && !available())

vs.

(s == CLOSE_WAIT );

No the function itself is still there.

You are right, your code is too simple. It would not work with my project's extended time scale (weeks, and prefer months without on-site service). I use timeout and connected() as a shortcut but connected() seems to be the problem now.

I did switch from connection-type: keep-alive to close. Does that screw me up? In the keep-alive days, I never had a problem. I am guessing the server wonders why this little brat just won't send more requests and waits online. Now with close, the server closes connection immediately and if connected() doesn't detect there is still available bytes, then I don't get these bytes.
67  Development / Other Software Development / Re: Library Conflict on: July 08, 2014, 07:57:04 pm
There is the official ethernet shield, and also compatible ones using W5100 chips. I've used only the official one and have yet to try a compatible one (no reason they don't work). MEGA has 8KB SRAM, so a big boost. Before you try that, try the free memory code to see whether you are running out of memory.

http://playground.arduino.cc/Code/AvailableMemory

What does sha library do? Any potential pin conflict in your set up?
68  Development / Other Software Development / WiFi library call WiFiClient::connected() code error? on: July 08, 2014, 07:50:31 pm
The reference says that if there are still unread data with a closed connection, the connected() will return true.

http://arduino.cc/en/Reference/WiFiClientConnected

If this is the case for IDE 1.0.5 r2, then why did they remove the available() from the connected()?

From around Arduino IDE 1.0
Code:
uint8_t WiFiClient::connected() {

  if (_sock == 255) {
    return 0;
  } else {
    uint8_t s = status();

    return !(s == LISTEN || s == CLOSED || s == FIN_WAIT_1 ||
    s == FIN_WAIT_2 || s == TIME_WAIT ||
    s == SYN_SENT || s== SYN_RCVD ||
             (s == CLOSE_WAIT && !available()));
  }
}

If there is still stuff, available() returns true and return value becomes true.

New code in 1.0.5 r2:
Code:
uint8_t WiFiClient::connected() {

  if (_sock == 255) {
    return 0;
  } else {
    uint8_t s = status();

    return !(s == LISTEN || s == CLOSED || s == FIN_WAIT_1 ||
    s == FIN_WAIT_2 || s == TIME_WAIT ||
    s == SYN_SENT || s== SYN_RCVD ||
    (s == CLOSE_WAIT));
  }
}

available is removed. I have no way to test the theory that this removal creates problems. I'm supposed to report any error. I see this as a possible error or I just don't know enough. I posted the code on network board already with a related topic but thought if they want it posted on software dev. I'll do it again.
69  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 08, 2014, 07:01:28 pm
WiFiClient::connected() my version:

Code:
uint8_t WiFiClient::connected() {

  if (_sock == 255) {
    return 0;
  } else {
    uint8_t s = status();

    return !(s == LISTEN || s == CLOSED || s == FIN_WAIT_1 ||
    s == FIN_WAIT_2 || s == TIME_WAIT ||
    s == SYN_SENT || s== SYN_RCVD ||
             (s == CLOSE_WAIT && !available()));
  }
}

Version 1.0.5 r2

Code:
uint8_t WiFiClient::connected() {

  if (_sock == 255) {
    return 0;
  } else {
    uint8_t s = status();

    return !(s == LISTEN || s == CLOSED || s == FIN_WAIT_1 ||
    s == FIN_WAIT_2 || s == TIME_WAIT ||
    s == SYN_SENT || s== SYN_RCVD ||
    (s == CLOSE_WAIT));
  }
}

The available is removed. Of course the status() may be defined differently between versions.
My version:
Code:
uint8_t WiFiClient::status() {
    if (_sock == 255) {
    return CLOSED;
  } else {
    return ServerDrv::getClientState(_sock);
  }
}

1.0.5 r2
Code:
uint8_t WiFiClient::status() {
    if (_sock == 255) {
    return CLOSED;
  } else {
    return ServerDrv::getClientState(_sock);
  }
}

I don't understand the subtle difference of having available() and not having it in the connected(). Sounds like my older version is by the reference and the newest stuff is no longer checking the available() as it says it does on the ref.
70  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 08, 2014, 06:37:42 pm
I'm not able to upgrade any wifi shield firmware since they are all deployed in different fields.

My code that waits for server response on a connection:

Code:
//Receive server reply and log it to Debug(serial), debugfile. Returns the reply code.
int receive_server_reply(WiFiClient* my_in)
{
boolean catch_next_byte=false; // This indicates the next byte from buswave server should be captured as reply value. This is turned on only when cell_send_response_indicator character is detected (usually '*').
char HTTP_response_code[]="   "; // This stores the HTTP response code such as 200 or 500, for later recognition.
int reply=cell_send_response_network_reg_err;
unsigned int received_byte_cnt=0; // This counts received bytes from server. It is used to determine where the HTTP respond code is located.
unsigned long connect_time;
// Ready the debug file
if (!debugfile.open(debug_file_name, O_WRITE | O_CREAT | O_AT_END)) // Send data to debugfile
{
Debug->print(millis());
Debug->println(F(":Can't open debug file"));
my_in->stop();
while(1){}
}

// Wait on server response
connect_time=millis();
Debug->print(millis());
Debug->println(F(":Waiting for server response"));
while (millis()-connect_time<server_response_time)
{
char c;
if (my_in->available())
{
c= my_in->read();
Debug->write(c);
debugfile.write(c);
if ((received_byte_cnt>8)&&(received_byte_cnt<12)) HTTP_response_code[received_byte_cnt-9]=c; // Store the HTTP response code
if (received_byte_cnt==11) // Got the response code
{
if (strcmp("200",HTTP_response_code)!=0) // Cache data if response is not 200.
{
while (millis()-connect_time<server_response_time) // Still receive the rest of the response until there is none.
{
if (my_in->available())
{
c= my_in->read();
Debug->write(c);
debugfile.write(c);
}
//if (!my_in->connected()) break;
}
debugfile.println(F("Server not responding 200"));
Debug->println(F("Server not responding 200"));
reply=cell_send_response_network_reg_err;
break;
}
}
received_byte_cnt++;
}
if (catch_next_byte)
{
reply=c;
catch_next_byte=false;
}
if (c==cell_send_response_indicator) catch_next_byte=true;
//if (!my_in->connected()) break;
}

Debug->println();
Debug->print(millis());
Debug->println(F(":Disconnecting from server."));

debugfile.println();
debugfile.close();

PGM_RAM(network_msg_02,formatting_buffer);
sprintf(buffer,formatting_buffer,(int)reply);
Debug->println(buffer);
debug_log(buffer);

return reply;


After I commented out the if (!my_in->connected()) break; I have not since received an incomplete response but it's some hard waiting time. I'll report back with arduino ide 1.0.5 r2 compile result.
71  Using Arduino / Networking, Protocols, and Devices / Possible cause of incomplete server response and glued together responses? on: July 08, 2014, 04:12:31 pm
I have done this for the past couple of years without problem: Log data on fixed interval, send HTTP POST requests to a server and wait for it to respond. I extract one thing out of it and move on to log data.

But lately (I've not upgraded Arduino IDE or hardware or firmware), I have been getting partial server responses like:

HTTP/1.1 500 Internal Server Error
Date: Tue, 08 Jul 2014 20:34:22 GMT

The connection times out after about 10-18 seconds, less than my software time out of 30s in a while loop.

Then after next connection is established, I get this:
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 619
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 [no address given] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at www.-------.com Port 80</address>
</body></html>
HTTP/1.1 200 OK
Date: Tue, 08 Jul 2014 20:34:35 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=100


Apparently only the first 2 lines of the 500 error response was received during the first connection. Then minutes later, next upload gets the rest of the first response and with the second response (not complete either).

I wonder if I am to be blamed. I use:

Code:
if (!client.connected()) break;

This breaks out of a while loop that waits for server response.

What if server breaks connection when there is still unread message in the wifi shield? This will just make arduino quit reading the unread message and it gets left over for the next connection. This explanation contrasts my understand:

http://arduino.cc/en/Reference/WiFiClientConnected

I am not using the "LATEST" version of the library which this reference is about though.

Any simple explanations? I'll try to compile in arduino ide 1.0.5 r2 to see what happens.
72  Community / Bar Sport / Re: The Cracked Pot on: July 08, 2014, 12:49:39 am
First convert them to the same unit, emptiness or fullness, then do math  smiley-razz
73  Development / Other Hardware Development / Re: 32u4 based APRS Tracker on: July 07, 2014, 11:44:09 pm
Brad,

I have a picture to share. I noticed that you also have some similar features on your board: the microSD card pins are off to one side instead of centered on the pads.



I wonder if there is any way to make some changes. If we shift all pads one way, the last one gets too close to the tab. If we make them smaller, darn, it's already difficult to solder. It works, but just not perfectly. Any thoughts?
74  Community / Bar Sport / Re: Students caught out.... on: July 07, 2014, 11:11:28 pm
My city is not big. I have one RadioShack that I go when I run out of solder or need some small parts I don't have (I have "huge" stock of stuff at work and at home now).
75  Using Arduino / General Electronics / Re: Why is IOH connector off grid ? on: July 07, 2014, 10:57:52 pm
LOL, good idea to just get around those pins if you don't need them. Why didn't I think about skipping those pins? Many of my early projects using thru-hole parts, like doing two photo gates etc only needed a few pins. A 1/8" stereo socket fits on a perf board just fine, so is a thru-hole power barrel with pins. 0.1" and 0.2" spacing screw terminal blocks fit too. I've even fit coin battery holders and buzzers on them, although I had to use different rows of pins.

But to be honest, there is no way I'm going back making perf board projects. My right hand is glued to my mouse now. Sometimes I just make a design and get it printed and THEN prototype it on the PCB. Printing gets so cheap that if I make mistakes, I keep the coasters in a pile as practice material for my students.
Pages: 1 ... 3 4 [5] 6 7 ... 510