Go Down

Topic: SD library and UDP Client (problem sending data) (Read 785 times) previous topic - next topic

designer

sorry if this is a noob problem, I'm a circuit designer by profession and programming is not my forte.

I have a Chipkit max32 set up with a wifi shield and sd card. I'm using SD.h library and trying to open a file and sending a single byte using UDP client.

Yes, I know this probably not a very efficient way of sending data, but we'll get to that later :)
Code: [Select]

//blah blah blah...initialize card, initialize UDP,
//no problems here, have used it many times
//
//

myFile = SD.open("tiger.bmp");
    if (myFile) {
     while( myFile.available()) {
       byte myByte;
       myByte = myFile.read();
       udpClient.writeDatagram(myByte, myFile.size());
     }
    }

//blah blah



my problem is the writeDatagram function does not like taking myByte:
WiFiUDPEchoServerSDTest.cpp: In function 'void loop()':
WiFiUDPEchoServerSDTest.cpp:459:50: error: invalid conversion from 'byte' to 'const byte*'
WiFiUDPEchoServerSDTest.cpp:459:50: error:   initializing argument 1 of 'long int UdpClient::writeDatagram(const byte*, size_t)'

I don't understand the conversion problem here, help?

Thanks,

Nick Gammon

Code: [Select]

       udpClient.writeDatagram(myByte, myFile.size());


I don't understand what you are attempting here. You want to write one byte for the length of the entire file?
http://www.gammon.com.au/electronics

Nick Gammon

Quote
... and sending a single byte ...


Do mean:

Code: [Select]

       udpClient.writeDatagram(myByte, 1);

http://www.gammon.com.au/electronics

Nick Gammon

Can you post the whole thing? Save us looking up all the "blah blah blah" stuff (libraries, declarations etc.)
http://www.gammon.com.au/electronics

designer


Thanks for your reply, I really appreciate it.The code is very long.

I'm essentially modifying the UDPEchoServer example (http://digilentinc.com/Products/Detail.cfm?NavPath=2,401,884&Prod=PMOD-WIFI  -> UDPEchoServer.pde) where during the WRITE case, I want to read a bitmap image file from the SD card and send it across the server. An Iphone is receiving the image. I've been playing around with how to send a bitmap file and trying to send a stream of bytes and redraw with Xcode.

You are correct, the length should be 1, it is only one byte.

myFile.read() will read the any file byte at a time.

PaulS

Quote
I have a Chipkit max32 set up with a wifi shield and sd card.

I'm sorry. Did you have an Arduino question?

designer

The libraries are essentially identical, and the arduino forum has provided me much more resources so I thought I would ask here. Thanks

Go Up