質問編集履歴
1
原因追及記載
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -144,4 +144,109 @@
|
|
|
144
144
|
</body>
|
|
145
145
|
</html>
|
|
146
146
|
```
|
|
147
|
-
〇JavaScriptファイルとCSSファイルは文字数制限に引っかかったため省略します。(必要でしたら別質問にて提示します。)
|
|
147
|
+
〇JavaScriptファイルとCSSファイルは文字数制限に引っかかったため省略します。(必要でしたら別質問にて提示します。)
|
|
148
|
+
|
|
149
|
+
→原因追及結果
|
|
150
|
+
シリアルモニタを用いて原因追及を行っています。
|
|
151
|
+
```ここに言語を入力
|
|
152
|
+
#include <SPI.h>
|
|
153
|
+
#include <Ethernet2.h>
|
|
154
|
+
#include <SD.h>
|
|
155
|
+
char *FILENAME="system_terminal.html";
|
|
156
|
+
|
|
157
|
+
// Enter a MAC address and IP address for your controller below.
|
|
158
|
+
// The IP address will be dependent on your local network:
|
|
159
|
+
byte mac[] = {
|
|
160
|
+
0x90, 0xA2, 0xDA, 0x10, 0xBF, 0x98
|
|
161
|
+
};
|
|
162
|
+
IPAddress ip(192, 168, 100, 222);
|
|
163
|
+
|
|
164
|
+
// Initialize the Ethernet server library
|
|
165
|
+
// with the IP address and port you want to use
|
|
166
|
+
// (port 80 is default for HTTP):
|
|
167
|
+
EthernetServer server(80);
|
|
168
|
+
|
|
169
|
+
void setup() {
|
|
170
|
+
// Open serial communications and wait for port to open:
|
|
171
|
+
Serial.begin(9600);
|
|
172
|
+
while (!Serial) {
|
|
173
|
+
; // wait for serial port to connect. Needed for Leonardo only
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
// start the Ethernet connection and the server:
|
|
178
|
+
Ethernet.begin(mac, ip);
|
|
179
|
+
server.begin();
|
|
180
|
+
Serial.print("server is at ");
|
|
181
|
+
Serial.println(Ethernet.localIP());
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
void loop() {
|
|
186
|
+
// listen for incoming clients
|
|
187
|
+
EthernetClient client = server.available();
|
|
188
|
+
if (client) {
|
|
189
|
+
Serial.println("new client");
|
|
190
|
+
boolean currentLineIsBlank = true;
|
|
191
|
+
while (client.connected()) {
|
|
192
|
+
if (client.available()) {
|
|
193
|
+
char c = client.read();
|
|
194
|
+
//Serial.println('111');
|
|
195
|
+
Serial.write(c);
|
|
196
|
+
//Serial.println('222');
|
|
197
|
+
if (c == '\n' && currentLineIsBlank) {
|
|
198
|
+
//Serial.println('333');
|
|
199
|
+
client.println("HTTP/1.1 200 OK");
|
|
200
|
+
client.println("Content-Type: text/html");
|
|
201
|
+
client.println("Connection: close");
|
|
202
|
+
client.println();
|
|
203
|
+
Serial.print('4');
|
|
204
|
+
File file;
|
|
205
|
+
file = SD.open(FILENAME,FILE_READ);
|
|
206
|
+
Serial.print('5');
|
|
207
|
+
if(file){
|
|
208
|
+
while(file.available()){
|
|
209
|
+
Serial.print(file.position());
|
|
210
|
+
Serial.print('6');
|
|
211
|
+
char buff=file.read();
|
|
212
|
+
Serial.print(buff);
|
|
213
|
+
client.write(buff);
|
|
214
|
+
}
|
|
215
|
+
}else{
|
|
216
|
+
Serial.println("Error!!");
|
|
217
|
+
}
|
|
218
|
+
file.close();
|
|
219
|
+
//client.write(file);
|
|
220
|
+
//break;
|
|
221
|
+
}
|
|
222
|
+
if (c == '\n') {
|
|
223
|
+
currentLineIsBlank = true;
|
|
224
|
+
}
|
|
225
|
+
else if (c != '\r') {
|
|
226
|
+
currentLineIsBlank = false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
delay(1);
|
|
231
|
+
client.stop();
|
|
232
|
+
Serial.println("client disconnected");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
```ここに言語を入力
|
|
238
|
+
server is at 192.168.100.222
|
|
239
|
+
new client
|
|
240
|
+
GET / HTTP/1.1
|
|
241
|
+
Host: 192.168.100.222
|
|
242
|
+
Connection: keep-alive
|
|
243
|
+
Cache-Control: max-age=0
|
|
244
|
+
Upgrade-Insecure-Requests: 1
|
|
245
|
+
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
|
|
246
|
+
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
|
|
247
|
+
Accept-Encoding: gzip, deflate
|
|
248
|
+
Accept-Language: ja,en-US;q=0.8,en;q=0.6
|
|
249
|
+
|
|
250
|
+
45Error!!
|
|
251
|
+
```
|
|
252
|
+
SDカード内のファイルを開封できていない可能性があります。
|