Offline
Jr. Member
Karma: 0
Posts: 76
|
 |
« Reply #15 on: December 19, 2012, 06:02:55 pm » |
Why are the files on the sdcard seen with different names? When I have a name like indexabc.html arduino loads it as indexh~1.htm and that's how I access it. Why is this happening?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #16 on: December 19, 2012, 06:06:41 pm » |
Your SD card is probably formatted with a FAT file system, which cannot handle .html as a normal extension, since normal extensions back when FAT was invented were limited to 3 characters. Files with more than 8 characters in the filename or three characters in the extension get this special treatment.
I'm guessing the tilde thing isn't happening to files that fit the 8.3 limit.
You could name your file .htm and see if it helps.
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 76
|
 |
« Reply #17 on: December 19, 2012, 06:23:02 pm » |
That did help. Thank you. Here is my problem. If I open this file on the sdcard of my phone it opens the webpage fine and displays the images perfectly fine. If I have the same exact file on the sdcard of my ethernet shield on the arduino it does not load the images. Why is this happening? Sorry to throw these html problems at you guys. Here is what the serial monitor is displaying: Free RAM: 831 Volume is FAT16
Files found in root: INDEX.HTM 2012-12-19 18:06:36 1363
Files found in all dirs: INDEX.HTM
Done GET /INDEX.HTM HTTP/1.1 INDEX.HTM Opened! GET /favicon.ico HTTP/1.1 favicon.ico
|
|
|
|
« Last Edit: December 19, 2012, 06:36:22 pm by durkinnj »
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #18 on: December 19, 2012, 06:32:28 pm » |
The problem is the file:// url. There is a great difference between http:// and file:// urls. The main issue here is that a file:// url is only valid on the device where the resource named by the url lives.
To fetch a resource like an image across the network, it needs to be on an http:// server and the referring HTML code needs to use the appropriate http:// url to fetch it.
-br
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 76
|
 |
« Reply #19 on: December 19, 2012, 06:35:18 pm » |
Well I don't know if you've read any previous posts but the problem is that this local network is not connected to the internet in anyway (not even the client browser because it is connected to the arduino network only). So while I would love to have the images hosted elsewhere, I can't.
The only other solution I can think of is to have the image files on the client device and have the webserver point the client to look in its own directory for the files. I'm kind of stuck here :/
The only other way to go with this is to actually connect the arduino to the internet. I honestly do not know how to do this as a mobile application. I'll have to use a broadband device either usb or mobile hotspot and somehow connect the arduino to it but how?
|
|
|
|
« Last Edit: December 19, 2012, 06:46:41 pm by durkinnj »
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #20 on: December 19, 2012, 06:54:57 pm » |
The web server does not have to be on the internet. It can be on the phone, or a PC, on your local network.
-br
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6540
Arduino rocks
|
 |
« Reply #21 on: December 19, 2012, 06:56:13 pm » |
I suggest you just work on serving an image. Post the html code of the page your arduino servs up. Does your server code include detecting when the image is requested?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 76
|
 |
« Reply #22 on: December 19, 2012, 07:10:43 pm » |
Thanks.
|
|
|
|
« Last Edit: December 20, 2012, 09:04:59 am by durkinnj »
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6540
Arduino rocks
|
 |
« Reply #23 on: December 19, 2012, 07:34:54 pm » |
For testing I suggest you try just sending the image to the browser when the server gets a request and skip all the other stuff. If you click on the below link IE will display the slider1.jpg file without any other html code required. start simple. http://web.comporium.net/~shb/pix/slider1.jpg
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 76
|
 |
« Reply #24 on: December 19, 2012, 08:20:09 pm » |
zoomkat, I'm also modifying your code for my application. Here is what I've done so far: //zoomkat 4-1-12 //simple button GET for servo and pin 5 //for use with IDE 1.0 //open serial monitor to see what the arduino receives //use the \ slash to escape the " in the html, or use ' instead of " //address will look like http://192.168.1.102:84 when submited //for use with W5100 based ethernet shields
#include <SPI.h> #include <Ethernet.h>
#include <Servo.h> Servo myservo; // create servo object to control a servo
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 0, 80 }; // ip in lan //byte gateway[] = { 192, 168, 1, 1 }; // internet access via router //byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(80); //server port boolean engine = false; String readString;
//////////////////////
void setup(){
pinMode(5, OUTPUT); //pin selected to control //start Ethernet Ethernet.begin(mac, ip); server.begin();
myservo.write(90); //set initial servo position if desired myservo.attach(7); //the pin for the servo control //enable serial data print Serial.begin(9600); Serial.println("server servo/pin 5 test 1.0"); // so I can keep track of what is loaded }
void loop(){ // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read();
//read char by char HTTP request if (readString.length() < 100) {
//store characters to string readString += c; //Serial.print(c); }
//if HTTP request has ended if (c == '\n') {
/////////////// Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page client.println("Content-Type: text/html"); client.println();
client.println("<HTML>"); client.println("<HEAD>"); client.println("<TITLE>Arduino GET test page</TITLE>"); client.println("</HEAD>"); client.println("<BODY>");
client.println("<H1>Zoomkat's simple Arduino button</H1>"); if(engine == false){ client.println("<a href='/?on'>ON</a>"); } else { client.println("<a href='/?off'>OFF</a>"); }
client.println("</BODY>"); client.println("</HTML>"); delay(1); //stopping client client.stop();
///////////////////// control arduino pin if(readString.indexOf("on") >0)//checks for on { myservo.write(40); digitalWrite(5, HIGH); // set pin 5 high engine = true; Serial.println("Led On"); } if(readString.indexOf("off") >0)//checks for off { myservo.write(140); digitalWrite(5, LOW); // set pin 5 low engine = false; Serial.println("Led Off"); } //clearing string for next read readString="";
} } } } } I'm trying to make it give an option of off when it's on and an option of on when it's off. What happens is if you press off it goes off but displays off again. Click it again, nothing happens except it changes back to on and then you can turn it on but then it displays on again until you click it one more time to change it to off again.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 76
|
 |
« Reply #25 on: December 20, 2012, 08:21:08 am » |
Okay I solved the problem but only on one browser. When I switch to another browser (firefox) and try to turn the pin off, it turns off for half a second and then turns right back on. I have no idea what's going on. Can someone take a look at my code and point me in the right direction? //zoomkat 4-1-12 //simple button GET for servo and pin 5 //for use with IDE 1.0 //open serial monitor to see what the arduino receives //use the \ slash to escape the " in the html, or use ' instead of " //address will look like http://192.168.1.102:84 when submited //for use with W5100 based ethernet shields
#include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 0, 80 }; // ip in lan //byte gateway[] = { 192, 168, 1, 1 }; // internet access via router //byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(80); //server port boolean engine = false; //engine status String readString;
//////////////////////
void setup(){
pinMode(5, OUTPUT); //pin selected to control //start Ethernet Ethernet.begin(mac, ip); server.begin();
//enable serial data print Serial.begin(9600); Serial.println("server pin 5 test 1.0"); // so I can keep track of what is loaded }
void loop(){ // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read();
//read char by char HTTP request if (readString.length() < 100) {
//store characters to string readString += c; //Serial.print(c); }
//if HTTP request has ended if (c == '\n') {
///////////////////// control arduino pin if(readString.indexOf("on") >0)//checks for on { digitalWrite(5, HIGH); // set pin 5 high engine = true; Serial.println("Led On"); } if(readString.indexOf("off") >0)//checks for off { digitalWrite(5, LOW); // set pin 5 low engine = false; Serial.println("Led Off"); } /////////////// Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page client.println("Content-Type: text/html"); client.println();
client.println("<HTML>"); client.println("<HEAD>"); //client.println("<META HTTP-EQUIV='refresh' CONTENT='5'>"); client.println("<TITLE>Arduino GET test page</TITLE>"); client.println("</HEAD>"); client.println("<BODY>");
client.println("<H1>Zoomkat's simple Arduino button</H1>"); if(engine == false){ client.println("<a href='/?on'>ON</a>"); } else { client.println("<a href='/?off'>OFF</a>"); }
client.println("</BODY>"); client.println("</HTML>"); delay(1); //stopping client client.stop(); //clearing string for next read readString="";
} } } } }
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #26 on: December 20, 2012, 08:35:04 am » |
//open serial monitor to see what the arduino receives Did you? Are you going to keep us in suspense?
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #27 on: December 20, 2012, 08:53:02 am » |
Just to point out that indexOf("on") and indexOf("off") look for those particular characters in ANY word, not just the words "on" or "off".
examples: long > on onboard > on one> on office > off offend > off
You should use a special character to not get it confused with anything else. @#$%^&*<>?, one of these should be incorporated with the words on/off and also with the finding of the words.
|
|
|
|
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 76
|
 |
« Reply #28 on: December 20, 2012, 09:08:43 am » |
Ah thanks guys. Problem solved.
|
|
|
|
« Last Edit: December 20, 2012, 09:28:58 am by durkinnj »
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #29 on: December 20, 2012, 09:44:25 am » |
Could you tell us how you fixed it?
You should post the working code for other people to see.
|
|
|
|
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
|