I am trying to read the binary data of a picture from an SD card on an Ethernet shield with an Arduino Uno, then send the binary data over an Ethernet cable to my computer. I get a weird error message when I try and run the code, and I cant figure out why.
#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;
}
}
}
The error that I am getting is:
SDTestHost:36: error: void value not ignored as it ought to be char new_msg=msg.toCharArray(bufSize,sizeof(bufSize)); exit status 1 void value not ignored as it ought to be
I want to send more than one byte of data at a time, which is the default for client.write(file.read()); and I cant figure out how to change the buffer size