Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added a method to read data into a char buffer so that character-base…
…d (rather than byte-based) operations don't require a cast. As requested by Tom Igoe. Part of the fix to issue 439.
  • Loading branch information
amcewen committed Jan 13, 2011
commit 5caad5bdb4492c23f553ec94bd100ff78e87604f
3 changes: 3 additions & 0 deletions libraries/Ethernet/Udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class UDP : public Stream {
// Read up to len bytes from the current packet and place them into buffer
// Returns the number of bytes read, or 0 if none are available
virtual int read(unsigned char* buffer, size_t len);
// Read up to len characters from the current packet and place them into buffer
// Returns the number of characters read, or 0 if none are available
virtual int read(char* buffer, size_t len) { return read((unsigned char*)buffer, len); };
// Return the next byte from the current packet without moving on to the next byte
virtual int peek();
virtual void flush(); // Finish reading the current packet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void loop() {
Serial.println(Udp.remotePort());

// read the packet into packetBufffer
Udp.read((byte*)packetBuffer,UDP_TX_PACKET_MAX_SIZE);
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
Serial.println("Contents:");
Serial.println(packetBuffer);

Expand Down