Then it's broke some other way.
draythomp:
Then it's broke some other way.
I wouldn't say it's broken, just a minimalist design. If what I suspect is true then a few minor tweaks to the driver will fix it.
But ... the documentation could be a bit more up-front about this so we don't have to figure it out the hard way.
So in changing all of my code from client.print to client.write my code compiles, but when I run it, it hangs on this line of code:
sprintf(servBuffB,"<font size=32>Setpoint Fermenter %d : <input type=text style=font-size:32pt size=3 name=%c value=%d /> Open</font>
", j + 1, Whereto[j], setferm[j]);
Where j is anything from 0 to 3 and :
int setferm[4] = {300,300,300,300};
String Whereto[4] = {"a","b","c","d"};
I narrowed it down to the "%c" being the reason it is crashing. I've also tried %s and %d with no luck.... I'm guessing my syntax is messed up somehow? I have other lines with just the %d in there at it works fine, but it realldoesn't seem to like my Whereto[] array. Any help is highly appreciated.
Whereto is an array of strings so in this case each entry has a two character string ('a',\0) so the %c being fed a string will try to print the pointer to the characters. I suggest making the array an array of characters or using %s in the format string. Actually though, I've never used the 'String' declaration, so I would have done something like this:
char Whereto [4] = {'a','b','c','d'}; And then the format string you have would work because each entry in the table is a character. Another way that is a little trickier is: char* Whereto ={"abcd"}; Which is a C string that is actually abcd\0 and you can still index it just fine.
However, there's folk here that understand the String declaration intimately and they can probably show you exactly how to do this. I avoid String simply because of the fragmentation when they are added together. I can't afford the memory overhead in my projects.
Wanna see something confusing? This is what I get when I change it like you said to char Whereto[4] = {'a','b','c','d'}. With text boxes in there between the ':' and the closed or the next Setpoint respectively, but they don't have values of 300 in them like they should, they are blank. I'm not sure how to make the post show that.
Setpoint Fermenter 1 : [ ] Closed
Setpoint Fermenter 2 : [ ] Setpoint Fermenter 3 : [ ] Setpoint Fermenter 4 : [ ] Closed
It's set in a loop like this:
int setferm[4] = {300,300,300,300};
char Whereto[4] = {'a','b','c','d'};
for (int j = 0; j<4; j++) //Display the current Set points for the Fermenters
{
sprintf(servBuffB,"<font size=32>Setpoint Fermenter %d : <input type=text style=font-size:32pt size=3 name=%s value=%d /> Closed</font>
", j + 1, Whereto[j], setferm[j]);
client.write(servBuffB);
}
Any ideas whats going on there?
Cruelkix:
So in changing all of my code from client.print to client.write my code compiles, but when I run it, it hangs on this line of code:sprintf(servBuffB,"<font size=32>Setpoint Fermenter %d : <input type=text style=font-size:32pt size=3 name=%c value=%d /> Open</font>
", j + 1, Whereto[j], setferm[j]);
Where j is anything from 0 to 3 and :int setferm[4] = {300,300,300,300};
String Whereto[4] = {"a","b","c","d"};I narrowed it down to the "%c" being the reason it is crashing. I've also tried %s and %d with no luck.... I'm guessing my syntax is messed up somehow? I have other lines with just the %d in there at it works fine, but it realldoesn't seem to like my Whereto[] array. Any help is highly appreciated.
Try:
char Whereto[] = {'a','b','c','d'};
and %c in the format string.
DCContrarian:
Cruelkix:
So in changing all of my code from client.print to client.write my code compiles, but when I run it, it hangs on this line of code:sprintf(servBuffB,"<font size=32>Setpoint Fermenter %d : <input type=text style=font-size:32pt size=3 name=%c value=%d /> Open</font>
", j + 1, Whereto[j], setferm[j]);
Where j is anything from 0 to 3 and :int setferm[4] = {300,300,300,300};
String Whereto[4] = {"a","b","c","d"};I narrowed it down to the "%c" being the reason it is crashing. I've also tried %s and %d with no luck.... I'm guessing my syntax is messed up somehow? I have other lines with just the %d in there at it works fine, but it realldoesn't seem to like my Whereto[] array. Any help is highly appreciated.Try:
char Whereto[] = {'a','b','c','d'};and %c in the format string.
AHH, there it is, had to change it to %c not %s. ty ty
EDIT: So I tried all sorts of changes while I was trying to trouble shoot. They one thing I never tried was changing char Whereto[] = {"a","b","c","d"}; to char Whereto[] = {'a','b','c','d'};
Just for my knowledge, what is the difference between using " vs ' ??
the single quote is used to tell the compiler it's a character and the double quotes tell it it's a string (c type, not String). So 'a' is an a and "a" is a\0 a two byte thingie that has a null at the end. "World" is W,o,r,l,d,\0
Is that clearer or did I mess it up more?
Cruelkix:
Just for my knowledge, what is the difference between using " vs ' ??
One is a character (signed 8 bit integer)
The other makes a string in memory and you get a pointer to that string. It can have many characters in it.
// These are correct
int c = '8';
char *s = "9";
char *t = "10";
// This is not correct
int s = "9";
The real problem here is printf() - it has no type checking of parameters and can crash if you get them wrong.
Draythomp/Fungus, that makes sense, thank you both for the help and explinations. I've had no formal coding training, so in general, I do a lot of things I shouldn't becuase I just don't really understand the fundementals. So all this stuff is very helpful!!
Anywho, I changed everything to client.write, and put Pin 4 to output High, and added some of zoomkat's meta refresh stuff to my project.....
12000 refreshes as of this morning and still going! New record for me thats for sure.
I'm still going to follow this thread as I am very interested to see what the final fix you guys come up with is. I feel like ya'll are very very close! You guys know way more than I do, but I enjoy following along
It's very educational; even though sometimes I have no idea what you are talking about haha.
I think we are getting closer to a fix. I think fungus may have come up with the missing piece when he discovered the "fragmentation required" message. I am hoping he will try this code and see if it gets rid of that message.
/utility/w5100.cpp
uint16_t W5100Class::getTXFreeSize(SOCKET s)
{
// Tim added variable mss
uint16_t val=0, val1=0 , mss;
// Tim added
mss = readSnMSSR(s);
if(mss > 2048)
mss = 2048;
do {
val1 = readSnTX_FSR(s);
if (val1 != 0)
val = readSnTX_FSR(s);
}
while (val != val1);
// return val;
// Tim added
return (val + mss - 2048);
}
This adjusts the return value compared to the MSS value, rather than the entire register size.
My client.free() now returns 1460 when the buffer is empty. That is exactly the max data size my router will take.
How do we tell how much the next device in line will take? And, wouldn't it also depend on the device after that as well. There's probably a hundred devices between us and our eventual destination (using the internet), wouldn't each of them have some number or other?
Because when it opens the connection, it checks! My MSS is 1460 if I use a local server. It is only my router.
If I open a connection to Yahoo, the MSS is only 1440.
Good enough?
That's actually pretty cool. Is there something in the protocol that propagates that kind of thing?
Actually, I can give your code a try, but the problem is that we may not know anything since the device I can change hasn't messed up since I made the other changes to it, and, it doesn't have any large packets (at least not that large). About all I can tell us is that it didn't break it.
I don't experience this problem either. The pin 4 thing did that for me. I send a 30 byte request once every 20 seconds. At this rate, I would never see this problem.
I can see how it would be a problem if I really started pushing the data to that connection. Let's say I sent 10,000 bytes all at once (like your test with the loop), every 20 seconds. The connection would just have to hiccup during the send, and you are at 2048 characters in the buffer.
Think about it. While you are surfing the net, how many times does a server respond immediately, and send you all the data at once?
Remember, he is having this problem only on his cellphone connection because it is bandwidth throttled.
Cell phones are a special case that may take some careful thought. At least with verizon in my area, they have 'smart buffering' that caches web pages and only downloads what it 'thinks' is necessary to help control bandwidth. I have no idea how this works, and how prevalent it is on mobile systems. I ran into it a while back when I couldn't get a page to reload. Seems the 'smart buffering' decided that I didn't really need the page because I already had it. He also hinted that it combined packets based on the contents to cut down on the number of packets routed to the phones to lower the overhead.
It took almost an hour on the phone before I finally got some techie somewhere that told me this. Now, he may have been telling me pure crap to get me off the phone and away from him, but it does make some sense. He was real clear that it was at verizon's end, not caching on the phone and he wasn't sure of the algorithm they used, but I couldn't help but think, how dumb an idea that was.
And to think, I pay for that.......
draythomp:
How do we tell how much the next device in line will take? And, wouldn't it also depend on the device after that as well. There's probably a hundred devices between us and our eventual destination (using the internet), wouldn't each of them have some number or other?
When a connection is created the smallest MSS along the route is propagated back to you (it appears in the W5100's MSS register).
I'm not sure what happens if the routing changes as the transfer progresses.
I'm still not sure why the W5100 doesn't obey MSS automatically. It doesn't seem to me like it would be more than a couple of lines of code in the internal software.
SurferTim:
I am hoping he will try this code and see if it gets rid of that message.
I'll definitely investigate the problem in the next few days and find out if we're on the right track.
I can't do it today or tomorrow because there's a project deadline and I have to shuffle the network cables around to get the sniffer to work... ![]()
@fungus: Thanks! Let me know.
For everyone: If you have a slow connection, try this link. It is the Blah Blah Har Har page. Please don't quote the section with this ip. I will remove the ip after the test. I have it public for this test only.
(ip removed)
This is going to dowload 1200 lines of text with about 50 characters per line. I used a lot of client.print() and client.println() to jam it up as much as I could. If this doesn't crash this code...
I am watching on this end for a crash.
This is my test Mega2560/Ethernet shield.
Edit: I see a few trying the link. It is doing good so far. Thanks for the help!
OK, you asked for it......heh heh