質問編集履歴

1

原因追及記載

2017/07/23 04:34

投稿

beansan
beansan

スコア13

test CHANGED
File without changes
test CHANGED
@@ -291,3 +291,213 @@
291
291
  ```
292
292
 
293
293
  〇JavaScriptファイルとCSSファイルは文字数制限に引っかかったため省略します。(必要でしたら別質問にて提示します。)
294
+
295
+
296
+
297
+ →原因追及結果
298
+
299
+ シリアルモニタを用いて原因追及を行っています。
300
+
301
+ ```ここに言語を入力
302
+
303
+ #include <SPI.h>
304
+
305
+ #include <Ethernet2.h>
306
+
307
+ #include <SD.h>
308
+
309
+ char *FILENAME="system_terminal.html";
310
+
311
+
312
+
313
+ // Enter a MAC address and IP address for your controller below.
314
+
315
+ // The IP address will be dependent on your local network:
316
+
317
+ byte mac[] = {
318
+
319
+ 0x90, 0xA2, 0xDA, 0x10, 0xBF, 0x98
320
+
321
+ };
322
+
323
+ IPAddress ip(192, 168, 100, 222);
324
+
325
+
326
+
327
+ // Initialize the Ethernet server library
328
+
329
+ // with the IP address and port you want to use
330
+
331
+ // (port 80 is default for HTTP):
332
+
333
+ EthernetServer server(80);
334
+
335
+
336
+
337
+ void setup() {
338
+
339
+ // Open serial communications and wait for port to open:
340
+
341
+ Serial.begin(9600);
342
+
343
+ while (!Serial) {
344
+
345
+ ; // wait for serial port to connect. Needed for Leonardo only
346
+
347
+ }
348
+
349
+
350
+
351
+
352
+
353
+ // start the Ethernet connection and the server:
354
+
355
+ Ethernet.begin(mac, ip);
356
+
357
+ server.begin();
358
+
359
+ Serial.print("server is at ");
360
+
361
+ Serial.println(Ethernet.localIP());
362
+
363
+ }
364
+
365
+
366
+
367
+
368
+
369
+ void loop() {
370
+
371
+ // listen for incoming clients
372
+
373
+ EthernetClient client = server.available();
374
+
375
+ if (client) {
376
+
377
+ Serial.println("new client");
378
+
379
+ boolean currentLineIsBlank = true;
380
+
381
+ while (client.connected()) {
382
+
383
+ if (client.available()) {
384
+
385
+ char c = client.read();
386
+
387
+ //Serial.println('111');
388
+
389
+ Serial.write(c);
390
+
391
+ //Serial.println('222');
392
+
393
+ if (c == '\n' && currentLineIsBlank) {
394
+
395
+ //Serial.println('333');
396
+
397
+ client.println("HTTP/1.1 200 OK");
398
+
399
+ client.println("Content-Type: text/html");
400
+
401
+ client.println("Connection: close");
402
+
403
+ client.println();
404
+
405
+ Serial.print('4');
406
+
407
+ File file;
408
+
409
+ file = SD.open(FILENAME,FILE_READ);
410
+
411
+ Serial.print('5');
412
+
413
+ if(file){
414
+
415
+ while(file.available()){
416
+
417
+ Serial.print(file.position());
418
+
419
+ Serial.print('6');
420
+
421
+ char buff=file.read();
422
+
423
+ Serial.print(buff);
424
+
425
+ client.write(buff);
426
+
427
+ }
428
+
429
+ }else{
430
+
431
+ Serial.println("Error!!");
432
+
433
+ }
434
+
435
+ file.close();
436
+
437
+ //client.write(file);
438
+
439
+ //break;
440
+
441
+ }
442
+
443
+ if (c == '\n') {
444
+
445
+ currentLineIsBlank = true;
446
+
447
+ }
448
+
449
+ else if (c != '\r') {
450
+
451
+ currentLineIsBlank = false;
452
+
453
+ }
454
+
455
+ }
456
+
457
+ }
458
+
459
+ delay(1);
460
+
461
+ client.stop();
462
+
463
+ Serial.println("client disconnected");
464
+
465
+ }
466
+
467
+ }
468
+
469
+
470
+
471
+ ```
472
+
473
+ ```ここに言語を入力
474
+
475
+ server is at 192.168.100.222
476
+
477
+ new client
478
+
479
+ GET / HTTP/1.1
480
+
481
+ Host: 192.168.100.222
482
+
483
+ Connection: keep-alive
484
+
485
+ Cache-Control: max-age=0
486
+
487
+ Upgrade-Insecure-Requests: 1
488
+
489
+ User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
490
+
491
+ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
492
+
493
+ Accept-Encoding: gzip, deflate
494
+
495
+ Accept-Language: ja,en-US;q=0.8,en;q=0.6
496
+
497
+
498
+
499
+ 45Error!!
500
+
501
+ ```
502
+
503
+ SDカード内のファイルを開封できていない可能性があります。