Pages: [1]   Go Down
Author Topic: SD library and UDP Client (problem sending data)  (Read 764 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Code:
//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,
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 502
Posts: 19086
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
       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?
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 502
Posts: 19086
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Do mean:

Code:
       udpClient.writeDatagram(myByte, 1);
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 502
Posts: 19086
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you post the whole thing? Save us looking up all the "blah blah blah" stuff (libraries, declarations etc.)
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have a Chipkit max32 set up with a wifi shield and sd card.
I'm sorry. Did you have an Arduino question?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: