Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 511
61  Development / Other Software Development / Re: Use Firefox or Chrome as interface? on: July 09, 2014, 01:50:59 pm
Web browsers are shielded from serial ports so you can't, not with some custom plug-ins that breach the security. But if you run a web server on arduino, yes, you can have a web interface. I was looking for web browsers that will fetch web pages from serial ports a while back and found nothing worth trying.
62  Development / Other Software Development / Re: Will Arduino team ever do better than this?! on: July 09, 2014, 01:49:01 pm
Back to blaming arduino, another thing I discovered the hard way:

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

Quote
Note that a client is considered connected if the connection has been closed but there is still unread data.

You think that you will take their word for it?! I did and lost 8 hours of work on it. It was intense trouble shooting. This above line simply isn't implemented in their latest code and an older version of the code didn't work either. The sample code on the page is not working either. Also not working with latest IDE and firmware. The call with return FALSE even when there are still available characters, so you end with a partial server response or just the first few characters. If you open connection again you get the rest of the response glued to the next response. I posted as separate thread on this board since they ask everyone to post here in case or ref page error. I seriously doubt they monitor the software dev. board for any sort of improvement suggestions.

This time there is a simple solution: just add available() to your if (!connected()) you will do fine.

63  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 09, 2014, 01:42:53 pm
Yes, but I have timeout already. This part just makes sure I'm not sitting on my thumbs until time out. Right now I have 30s time out starting from server connection. I could do a smarter time out to start and restart every time I receive a byte but shorten the total time to say 15s. But this (!(connected())&&(!available())) has successfully breaks out of the loop that will otherwise only break at time out.
64  Using Arduino / Networking, Protocols, and Devices / Re: Possible cause of incomplete server response and glued together responses? on: July 09, 2014, 10:34:43 am
Tim,

I am sorry if I bothered you too much. I am "asking too much" from arduino again. I did a simple test. If I just do

Code:
if ((!client.connected())&&(!client.available())) break;//just like their code before

Then it is safe to break loop and stop client and receive all characters. I'm not talking about tcp protocols. I am thinking reliability of arduino wifi library. I will just have to take for granted that any ref page information can be very old or inaccurate and I have to test every bit of code to make sure it works as arduino advertised it would. I wish the arduino team can just remove the description that conflicts with reality on that ref page or fix the function.
65  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
66  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.
67  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.
68  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".

69  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.
70  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.
71  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
72  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.
73  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.
74  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
75  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.
Pages: 1 ... 3 4 [5] 6 7 ... 511