Show Posts
Pages: 1 2 3 [4] 5 6 ... 510
46  Development / Other Software Development / Re: Library Conflict on: July 09, 2014, 09:31:25 am
Your code is rather short. I imagine that once it works you will grow your project, right? That means you definitely need more memory. Once I switched to MEGA I grew my project sizes considerably, so with their capabilities smiley
47  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 09, 2014, 09:29:40 am
Tim,

Do you think that refers to data that the client sends not receives? I thought it would be receives but you could be equally correct. Yes, that was the broken promise. You can see that clearly the earlier version of connected() has available() in the return value:

Code:
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()));

I don't understand all the other states as there is zero explanation in the code.

But somehow it doesn't work, not with original firmware on the shield. I tried it. They must have tried to make it work, and posted the description that it considers connected if the client receive is not empty (not send).

The sample code on connected() ref page also indicates that connected() helps tell whether server has disconnected from client, not the other way around. That sample code, which I tested with arduino 1.0.5 r2 and latest firmware on the shield, just fails to run. The "if" statement makes the execution visit connected() line too soon and I only get 1-2 characters. I can only get everything when I change the "if" to "while", trapping execution at the client.read.

All I did was I used my ssid, pass, server address, nothing else. If a sample code doesn't work, I don't trust the library very much. There is no comment capability on that ref page either. They say if you have questions, post on software dev board. I did. We'll see.
48  Development / Other Software Development / Re: Library Conflict on: July 09, 2014, 09:15:00 am
If at a given moment there is only 81 bytes left, yes it's running out of memory. Every function call drains memory too but you can't put freememory inside sha library call so you don't know exact numbers. Get a MEGA. Also do some code optimization when your code gets larger.
49  Development / Other Software Development / Re: WiFi library call WiFiClient::connected() code error? on: July 09, 2014, 02:06:34 am
I upgraded to IDE 1.0.5 r2 with its own wifi lib, upgraded firmware as well. Connects to servers but the sample code on this ref page will only grab one character back because the connected() quits even when there is still bytes in buffer, opposite of the ref page claim.

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

The sample code on this page, when I filled in my parameters, flat out fails to get more than one or two characters from server, because it uses if not while on the available(). If I switch to while then I get everything. It's clear, ref is bad or code is bad or both.

I think the only way this may succeed is to say HTTP/1.1 and not say connection-type: close (default is keep-alive), i.e. hogging the connection while doing nothing! Of course I tried, and it "works".

50  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 09, 2014, 01:45:47 am
Tim, I think I found the problem. I upgraded firmware and used the 1.0.5 r2 wifi library.

Arduino sample code inside of loop: A while loop is used. I got every character. I don't understand. Why should I use while instead of using if?
Code:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

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

    // do nothing forevermore:
    while(true);
  }

I changed while into if
Code:
  if (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

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

    // do nothing forevermore:
    while(true);
  }

I ended up with only one character. This only means that connected() will return false if connection is broken but there are still characters in the buffer. This IS OPPOSITE of what arduino reference says. Just another classic Arduino quality issue.

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

I just don't trust arduino that much anymore. I might use while but there is really no excuse with a broken promise the connected will return true if there is still message left.
51  Using Arduino / General Electronics / Re: Why is IOH connector off grid ? on: July 08, 2014, 11:33:30 pm
I am leaning towards using compatible boards that don't say arduino or use the infinity+- symbols. If I happen to have got one that says that, I call it knock-off. If it has no arduino printed on it, I call it compatible board. Yeah, no one is policing this.
52  Using Arduino / Storage / Re: can arduino read current size/capacity of one SD card? on: July 08, 2014, 11:31:51 pm
Counting block sizes is not your job. You call a function to do it. The function just takes it time to count. Read sdfat sample code. It's all in there. I hate to state the obvious, when you open the sample code called sdinfo.ino
53  Using Arduino / General Electronics / Re: using a SSR photoelectric sensor on: July 08, 2014, 10:46:48 pm
Stick multimeter test leads against BK and WH leads and have it on conductivity mode. Then wave your hand at the sensor. You may hear the multimeter beeping for connection made. I meant "is this sensor made for a factory machine?" not "do you intend to use this sensor for a factory machine?". Sorry for the loose language.
54  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 08, 2014, 10:44:19 pm
Thanks Tim. My code downloads all if I comment out the if (!client.connected()) break; and just wait until timeout. I'm trying to find a grace way to detect server disconnection. I tried to use arduino IDE 1.0.5 r2 but can't get connection. I guess I need to update my firmware, which bothers me (dozens in remote locations and firmware update is difficult). I ended up keeping my wifi library for 1.0.5 r2. I found out if I have wifi in sketchbooks/libraries and in arduino/libraries, it only uses the one in sketchbooks folder.
55  Using Arduino / Storage / Re: can arduino read current size/capacity of one SD card? on: July 08, 2014, 10:38:52 pm
My experience is that counting free blocks is a lot faster after you format the sd card with sd formatter 4. fat16lib pointed this out. Saved my project. Ditch the SD.h library and use sdfat.h

I never felt the need to go back to SD.h once I switched over
56  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.
57  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.
58  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?
59  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.
60  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.
Pages: 1 2 3 [4] 5 6 ... 510