Arduino Uno가있는 이더넷 실드의 SD 카드에서 그림의 이진 데이터를 읽은 다음 이더넷 케이블을 통해이 컴퓨터로 내 보냅니다. 코드를 실행하려고하면 이상한 오류 메시지가 표시되며 이유를 파악할 수 없습니다. Arduino 이더넷 실드에서 파일 읽기.
#include<SD.h>
#include <SPI.h>
#include <String.h>
#include <Ethernet2.h>
byte mac[]={0xB0,0xCD,0xAE,0x0F,0xDE,0x10};
IPAddress ip(169,254,95,37); //client ip for Andrew-Laptop
//IPAddress ip(169,254,155,102); //client ip for school laptop
IPAddress server(169,254,95,36); //server ip for Andrew-Laptop
//IPAddress server(169,254,155,101); //server ip for school laptop
EthernetClient client;
int whatToDo=0;
void setup(){
for(int a=3;a<=7;a++){
pinMode(a,OUTPUT);
digitalWrite(a,LOW);
}
Serial.begin(9600);
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
if(SD.begin(4)) digitalWrite(7,HIGH);
Ethernet.begin(mac,ip);
delay(1000);
digitalWrite(6,HIGH);
delay(1000);
if(client.connect(server, 12345)){
digitalWrite(5,HIGH);
}
}
char bufSize[1024];
void loop(){
if(whatToDo==0){
File myFile=SD.open("Img.png",FILE_READ);
while(myFile.available()){
String msg=myFile.readString();
int buf=1024;
char new_msg=msg.toCharArray(bufSize,sizeof(bufSize)); //ERROR LINE
//client.write(myFile.read());
client.write(new_msg);
}
//client.write(msg);
whatToDo=1;
}else{
digitalWrite(3,HIGH);
delay(500);
digitalWrite(3,LOW);
delay(500);
if(whatToDo==1){
client.write("");
client.write("Done");
whatToDo+=1;
}
}
}
내가 점점 오전 오류는 다음과 같습니다
SDTestHost : 36 : 오류 :이 일한다고 무시하지 무효 값 문자 new_msg = msg.toCharArray (bufSize buf의,는 sizeof (bufSize buf의)); 그것을 무시하지 종료 상태 1 무효 값이 나는 client.write의 기본을하는 시간에 하나 이상의 데이터 바이트를 보낼
되어야한다 (file.read()); 버퍼 크기를 변경하는 방법을 알 수 없습니다.