Show Posts
|
|
Pages: [1] 2
|
|
1
|
International / Software / Re: Aiuto arduino ethernet server da sd
|
on: January 11, 2013, 02:48:06 pm
|
|
i pulsantoni perchè erano la prima immagine che avevo a portata di mano.
mi pareva di aver letto da qualche parte che i javascript non funzionassero su arduino ethernet, evidentemente mi sbagliavo, stavo cercando una soluzione mentre ce l' avevo sotto al naso...
|
|
|
|
|
2
|
International / Software / Re: Aiuto arduino ethernet server da sd
|
on: January 11, 2013, 12:31:26 pm
|
(ho cambiato sketch) ho provato in questo modo ma non funge: #include <String.h> #include <SPI.h> #include <Ethernet.h> #include <Flash.h> #include <SD.h> #include <TinyWebServer.h>
int led=13; const int pagina = 0;
const int SD_CS = 4; const int ETHER_CS = 10; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 177 }; // ip in lan byte gateway[] = { 192, 168, 1, 1 }; byte subnet[] = { 255, 255, 255, 0 }; boolean file_handler(TinyWebServer& web_server); boolean index_handler(TinyWebServer& web_server);
TinyWebServer::PathHandler handlers[] = { {"/", TinyWebServer::GET, &index_handler }, {"/" "*", TinyWebServer::GET, &file_handler }, {NULL}, };
const char* headers[] = {"Content-Length",NULL}; TinyWebServer web = TinyWebServer(handlers, headers);
boolean has_filesystem = true; Sd2Card card; SdVolume volume; SdFile root; SdFile file;
void send_file_name(TinyWebServer& web_server, const char* filename) { if (!filename) { web_server.send_error_code(404); web_server << F("Could not parse URL"); } else { TinyWebServer::MimeType mime_type = TinyWebServer::get_mime_type_from_filename(filename); web_server.send_error_code(200); web_server.send_content_type(mime_type); web_server.end_headers(); if (file.open(&root, filename, O_READ)) { Serial << F("Read file "); Serial.println(filename); const char* filename = pagina; web_server.send_file(file); file.close(); } else { web_server << F("Could not find file: ") << filename << "\n"; } } }
boolean file_handler(TinyWebServer& web_server) { char* filename = TinyWebServer::get_file_from_path(web_server.get_path()); send_file_name(web_server, filename); free(filename); return true; }
boolean index_handler(TinyWebServer& web_server) { send_file_name(web_server, "INDEX.HTM"); return true; }
void setup() { Serial.begin(9600); pinMode(SS_PIN, OUTPUT); // set the SS pin as an output digitalWrite(SS_PIN, HIGH); // and ensure SS is high pinMode(ETHER_CS, OUTPUT); // Set the CS pin as an output digitalWrite(ETHER_CS, HIGH); // Turn off the W5100 chip! (wait for pinMode(SD_CS, OUTPUT); // Set the SDcard CS pin as an output digitalWrite(SD_CS, HIGH); // Turn off the SD card! (wait for card.init(SPI_FULL_SPEED, SD_CS); volume.init(&card); root.openRoot(&volume); Ethernet.begin(mac, ip, gateway, subnet); web.begin(); Serial << F("Ready to accept HTTP requests.\n"); pinMode(led, OUTPUT); }
void loop() { web.process(); if ( pagina == "ON.HTM" ){ digitalWrite(led, HIGH); } else{ digitalWrite(led, LOW); } }
P.S= questo sketch è di pablos, lo ho trovato in un topic non capisco cosa non va, forse nella const char* sotto il serial print che manda sulla seriale la pagina richiesta dal client. ho allegato anche i file htm che uso( l' index è solo un redirect per andarte alla pagina off, ma invece che modificare lo sketch ho usato questa via)
|
|
|
|
|
3
|
International / Software / Get
|
on: January 10, 2013, 11:18:37 am
|
|
Per le GET ringrazio pablos, ma non ho ancora capito come fare sulla pagina html. Mettiamo il caso che io crei un pulsante, dove lo mando? In poche parole: riesco a ricevere i dati, ma non riesco inviarli dalla pagina.
|
|
|
|
|
4
|
International / Software / Aiuto arduino ethernet server da sd
|
on: January 09, 2013, 12:45:57 pm
|
E' da qualche tempo che guardo sulla mia ethernet shield per giocarci un po'. Ho cercato su internet ma non ho trovato niente. Ho creato un server html con arduino, quando vado sull' indirizzio IP, arduino mi rimanda subito alla pagina home.htm, contenente nella root dell' SD e da quella pagina poi vado, con collegamenti ipertestuali o immagini(tradotte in Base64 e inserite nelle pagine htm), in altre pagine del mio piccolo web server. Vorrei trovare il modo (grazie per esempio a dei pulsanti) di riportare un valore sullo sketch di arduino in modo da poter controllare per esempio un' uscita, o mandare via seriale un messaggio. lo sketch che uso in questo momento è questo: #include <SPI.h> #include <Ethernet.h> #include <SD.h> #define maxLength 25 byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 1, 177 }; byte gateway[] = { 192, 168, 1, 1 }; byte subnet[] = { 255, 255, 255, 0 }; File htmlFile; EthernetServer server(80); void setup() { Ethernet.begin(mac, ip, gateway, subnet); server.begin(); if (!SD.begin(4)) { return; } } void loop() { char* file_to_load = "home.htm"; String inString = String(maxLength); EthernetClient client = server.available(); if (client) { boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); if (inString.length() < maxLength) { inString += c; } if (c == '\n' && currentLineIsBlank) { if (inString.indexOf(".htm") > -1) { String new_file_load; int rootIndex = inString.indexOf("/"); new_file_load = inString.substring((rootIndex+1), (rootIndex+13)); int endIndex = new_file_load.indexOf(" "); if (endIndex > -1) { new_file_load = new_file_load.substring(0, endIndex); } if (new_file_load != "") { new_file_load.toCharArray(file_to_load,12); } } client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); break; } if (c == '\n') { currentLineIsBlank = true; } else if (c != '\r') { currentLineIsBlank = false; } } } delay(1); client.stop(); } } void read_file( char* page_html, EthernetClient client ) { htmlFile = SD.open( page_html ); if (htmlFile) { while (htmlFile.available()) { client.write(htmlFile.read()); } htmlFile.close(); } }
Gamer3500
|
|
|
|
|
6
|
International / Hardware / Re: Aiuto Arduino nano
|
on: October 19, 2012, 03:54:22 pm
|
|
ecco erano i driver di arduino uno che contrastavcano quelli del nano perchè il pc li riconosce entrambi come dispoitivo usb to seriale generico e crede di avere già i driver, disinslallo arduino uno e metto nano... però così ogni volta che cambio arduino...
Grazie di tutto, gamer
|
|
|
|
|
10
|
International / Hardware / Re: Aiuto Arduino nano
|
on: October 19, 2012, 02:43:24 pm
|
|
io sono andato sulle proprietà del bus(quello nella foto) ho messo i drive della cartella di arduino ide, li ha riconosciuti e ho riavviato il pc, ma della com o di un dispositivo sconosciuto nessuna traccia
|
|
|
|
|
11
|
International / Hardware / Re: Aiuto Arduino nano
|
on: October 19, 2012, 02:33:33 pm
|
|
ho installato il driver quando ho messo arduino uno. il problema non è nel fatto che non riconosce il dispositivo, non c' è proprio neanche un dispositivo sconosciuto!
|
|
|
|
|
12
|
International / Hardware / Re: Evitare corto circuito
|
on: October 19, 2012, 02:18:36 pm
|
|
un fusibile così non servirebbe a niente, fra l' altro gliu attiny avendo un clock da 1 Mhz non consumano quasi niente già 1 A è un esagerazione, se messi a 12 V consumano circa 0,4A quindi ti conviene aspettare e prendere quello a 0,5A
Ciao, Gamer
|
|
|
|
|
13
|
International / Hardware / Re: Aiuto Arduino nano
|
on: October 19, 2012, 01:57:42 pm
|
|
Grazie uwe, per precisione è ft232rl, comunque non ho parlato di arduino uno, io ho impostato arduino nano con atmega 238, il problema è che non riconosce la com, quindi l' ide non la vede
|
|
|
|
|
14
|
International / Hardware / Aiuto Arduino nano
|
on: October 19, 2012, 08:19:30 am
|
|
Ciaoa tutti, ho acquistato un TOSduino Nano che mi è arrivato prprio oggi e, dopo averlo collegato al pc, vedo che funziona perchè c'è già montato il Blink sopra. Tutto contento, come ho fatto per gli altri arduino, apro l' ide, apro il blink, modifico un po' ol tempo di on/off vado a cercare la com e ci trovo solo quella del mio PC. allora vado in gestione attività e vedo che in effetti non c'è un' altra com ma c'è solo un nuovo dispositivo usb(schermata proprietà nella foto).
come faccio a far riconoscere a aruino ide il mio tosduino nano(arduino compatible)??
|
|
|
|
|
15
|
International / Software / Re: Aiutatemi: lettura e confronto IButtonDS1971
|
on: October 14, 2012, 08:40:41 am
|
è semplicemente questo: #include <OneWire.h> #include <LiquidCrystal.h> LiquidCrystal lcd(7,6,5,4,3,2);
void PrintBytes(uint8_t* addr, uint8_t count, bool newline=0) { for (uint8_t i = 0; i < count; i++) { Serial.print(addr>>4, HEX); Serial.print(addr&0x0f, HEX); } if (newline) Serial.println(); }
void ReadAndReport(OneWire* net, uint8_t* addr){ }
OneWire net(12);
void setup(void) { Serial.begin(9600); lcd.begin(16, 2); lcd.print("Inserire IButton"); }
void loop(void) { byte i; byte present = 0; byte addr[8]; if (!net.search(addr)) { net.reset_search(); delay(1000); return; }
Serial.print("\n"); delay(2000);
} funziona nel senso che legge il codice, ma non può ancora confrontarlo...
|
|
|
|
|