Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: UDPsendreceivestring adds previous message letters on: February 18, 2011, 04:31:10 pm
Thank you John Wasser- I did a clear buffer line as a temp fix but I like your solution better... it is the proper way. smiley-cool
2  Using Arduino / Networking, Protocols, and Devices / Interactive UDP send receive string on: February 18, 2011, 12:45:17 pm
Hello all knowing Forum,

My set up is a Mega 2560 with the EtherShieldSD. I have the EtherShieldSD hard wired to my WiFi Router. My Iphone has a UDP test tool on it and it is WiFi tethered to my LAN. I am using the Arduino 22 IDE. The Router is a Linksys wrt54g with open source DDWRT Bin files. It is operating in Client-Bridge mode to my main router which is a stock Linksys.

The next step is to get the Iphone off my LAN, but it needs to be solid before I start worrying about NAT traversal!

Code:
udp.send("Hello World", remoteIp, remotePort );   // the message to send

What would be the line of code to send a message that is not 'pre prepared" from the Serial Monitor???

I have it working so I can SEND any message from my Iphone UDP tool TO the Arduino... but typing into the Serial Monitor to send a Message BACK to the Iphone UDP tool, I get nada...

Thank you!

The whole sketch for reference- a slightly modified version of the original UDPsendreceivestring:

Code:
/*
  UDPSendReceive.pde:
 This sketch receives UDP message strings, prints them to the serial port
 and sends an "acknowledge" string back to the sender
 
 A Processing sketch is included at the end of file that can be used to send
 and received messages for testing with a computer.

created feb 15 2011
by Will Foster
based on the original
 
 created 21 Aug 2010
 by Michael Margolis
 
 This code is in the public domain.
 */


#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <Udp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xa2, 0xda, 0x00, 0x1d, 0xb8 };
byte ip[] = { 10, 10 , 10 , 122 };

unsigned int localPort = 8888;      // local port to listen on

// the next two variables are set when a packet is received
byte remoteIp[4];        // holds received packet's originating IP
unsigned int remotePort; // holds received packet's originating port

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back


void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

  Serial.begin(9600);
}

void loop() {
  
  char packetBuffer[] = "                                     "; //Clear the buffers so as not to leave text behind from one messag to the next

  // if there's data available, read a packet
  int packetSize = Udp.available(); // note that this includes the UDP header
  if(packetSize)
  {
    packetSize = packetSize - 8;      // subtract the 8 byte header
    Serial.print("Received packet of size ");
    Serial.println(packetSize);

    // read the packet into packetBufffer and get the senders IP addr and port number
    Udp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, remoteIp, remotePort);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    Udp.sendPacket( ReplyBuffer, remoteIp, remotePort);
  }
  delay(10);
}
3  Using Arduino / Networking, Protocols, and Devices / UDPsendreceivestring adds previous message letters on: February 16, 2011, 06:07:10 pm
All Knowing Forum!

I am using the standard UDP send receive string sketch and I have these problems-

Problem#1
I have UDP tool on my Iphone and succesfully SENT a message to the Arduino set up... but I could not use the Serial Monitor to SEND a message back to the Iphone.

Problem #2
The next test message I sent FROM the Iphone was shorter than the first message, and it left on the letters from the first message??? TEST was the first message and JOY was the second message, so it displayed on the Serial Monitor as JOYT...

I tested it several more times and it always did the same thing, I could correctly send longer messages, but when I went to a shorter message, it always left on the extra letters from the previous message!

(all working on my LAN{arduino hardwired by computer to USB com to Arduino/EthernetSD to Router} and the Phone by WiFi tether to my Network)

The goal is to send UDP text messages back and forth from the Iphone UDP tool to my computer.

ANY HELP?

THANKS!

Code:
/*
  UDPSendReceive.pde:
 This sketch receives UDP message strings, prints them to the serial port
 and sends an "acknowledge" string back to the sender
 
 A Processing sketch is included at the end of file that can be used to send
 and received messages for testing with a computer.
 
 created 21 Aug 2010
 by Michael Margolis
 
 This code is in the public domain.
 */


#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <Udp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xa2, 0xda, 0x00, 0x1d, 0xb8 };
byte ip[] = { 10, 10 , 10 , 122 };

unsigned int localPort = 8888;      // local port to listen on

// the next two variables are set when a packet is received
byte remoteIp[4];        // holds received packet's originating IP
unsigned int remotePort; // holds received packet's originating port

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back


void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

  Serial.begin(9600);
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.available(); // note that this includes the UDP header
  if(packetSize)
  {
    packetSize = packetSize - 8;      // subtract the 8 byte header
    Serial.print("Received packet of size ");
    Serial.println(packetSize);

    // read the packet into packetBufffer and get the senders IP addr and port number
    Udp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, remoteIp, remotePort);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    Udp.sendPacket( ReplyBuffer, remoteIp, remotePort);
  }
  delay(10);
}

4  Forum 2005-2010 (read only) / Troubleshooting / Re: Can't upload to Arduino Mega 2560 on: January 22, 2011, 05:39:23 pm
I just completed my RMA too, I hope the new board is solid. Good Luck on your Projects!

OH YES- I heard back from the the Bootloader Developer. He said don't put !!! anywhere in your code. There is a bug when you use 3 exclamations in a row, no matter how you use them, the bootloader tries to go to a monitor mode and breaks the sketch. no !!!  smiley-razz
5  Forum 2005-2010 (read only) / Troubleshooting / Re: Can't upload to Arduino Mega 2560 on: January 21, 2011, 01:56:07 pm
no response from the developer yet- but I talked to spark fun where is bought it and sent them my tests... I did the "general test" and the "tone test" direct from the Arduino IDE version 22... both with failed results. Sparkfun said it was the bootloader too and has a tutorial to re-burn here:
http://www.sparkfun.com/tutorials/247

the tutorial is for an UNO, so the only change you need to make is in the FUSE file with this:
#############################################
mega2560.name=Arduino Mega 2560

mega2560.upload.protocol=stk500v2
mega2560.upload.maximum_size=258048
mega2560.upload.speed=115200

mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
mega2560.bootloader.path=stk500v2
mega2560.bootloader.file=stk500boot_v2_mega2560.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F

mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=16000000L
mega2560.build.core=arduino

#############################################

You also need to download WINAVR from SourceForge AND one of these tools:
http://store.atmel.com/PartDetail.aspx?q=p:10500054

Or the one that SparkFun has listed in the Tutorial- but I think the tool from Atmel would be less buggy- since it is made for the chip in the Mega 2560 smiley-wink

can you say YIKES!
6  Forum 2005-2010 (read only) / Troubleshooting / Re: Can't upload to Arduino Mega 2560 on: January 20, 2011, 04:32:45 pm
I have similar problems and many other people do too- it seems an issue with the bootloader. I have searched and no one on the forum can give a straight answer how to re burn the 2560 bootloader. there are 100 half answers. i found the developer who actually programed the bootloader and sent him an email a few hours ago for a step by step guide specifically for the 2560. I hope to have a difinitive answer soon! ;D

if you find something first please post here, I am listening.
7  Forum 2005-2010 (read only) / Development / Re: Shield pin usage list on: January 20, 2011, 01:10:54 am
Ok, you guys are the pin experts... I have found 100 different takes on this... so what is the answer:

I have an Arduino Mega 2560 and and EthernetSD- V5 it looks like from your "Shield" website.

Does one have to run jumpers and bend out the pins for 10,11,12 and 13 and jump them to 50,51,52 and 53??? :'(

please help the noob!  :smiley
8  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Documentation Ethernet: Client class on: January 15, 2011, 02:54:10 pm
Im trying to write a sketch that will send a UDP packet off the arduino ethernet shield (arduino Mega 2560 and ethernetSD).

I'm not seeing any traffic. How do I tell that i am setting up my socket correctly? I am using ethernet.begin() , I am passing MAC,IP,gateway,Subnet parameters.

is that all I need to do to get a good socket?

Thank you!
9  Forum 2005-2010 (read only) / Interfacing / Re: Beginner Question - Connecting Ethernet Shield on: November 12, 2010, 04:48:12 pm
Thank you all in advance- this is a great forum.

Here is my code for an ethernet Client- the Colision LED is lite and i can't see the ethernet connection on my LAN. I am using Wireshark to look at the LAN. My goal is to get the Arduino to pass data to the Internet via UDP. I have the latest EtherShield with SD and Wiz chip, which has a full TCP-IP stack on it I believe. YES, I am a Noob learning EE, Networking and C++ all at once to build my prototype- yikes. :-[

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xa2, 0xda, 0x00, 0x1d, 0xb8 };
byte ip[] = { 192, 168, 1, 104 };
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte server[] = { 66, 249, 91, 104 }; // Google


Client client(server, 80);

void setup()
{
  Ethernet.begin( mac, ip, gateway, subnet );
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;smiley-wink
      ;
  }
}
10  Forum 2005-2010 (read only) / Interfacing / Re: Sd card logger shield with Ethernet shield on: November 09, 2010, 05:02:24 pm
Thank You SIR  ;D
11  Forum 2005-2010 (read only) / Interfacing / Re: Sd card logger shield with Ethernet shield on: November 09, 2010, 04:35:20 pm
simple question- Yes, I am a NOOB... so thank you for a response :o
on the mac address in the sketch- 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED- my mac address is 90, A2, DA... etc. Does the sketch need to read 90DE, A2AD, DABE... etc or just simply replace the 4 digit string sequence with my mac address 2 digit string sequence?
12  Forum 2005-2010 (read only) / Interfacing / Re: New SeeedStudio Solar Shield on: October 27, 2010, 07:44:34 pm
Thank you my brother- that answers two questions! yes, I need to get a new battery holder for 6 Volts AND I need to include pictures as recommended!!! What Seeed gave me is an actual 9 Volt battery holder. ;D
13  Forum 2005-2010 (read only) / Interfacing / New SeeedStudio Solar Shield on: October 27, 2010, 02:45:21 pm
the new seeedstudio solar charging shield comes with a 9 volt battery terminal and leads... however the schematic and datasheet both say 6 volt max... do I need to step it down or is the datasheet out dated with the new version? anyone else recently get one?
14  Forum 2005-2010 (read only) / Frequently-Asked Questions / How to "see" what is going on with the board? on: November 12, 2010, 05:00:47 pm
I ama noob, so please excuse- I have the arduino 21 application, and arduino Mega and a new EtherShield SD with Wiz chip. after i upload my sketch, how do i see any out put from the ethernet connection? The Network cable is plugged from the Arduino to my linksys router, but the sketch is not working, so how do i see what it is doing or not doing?
Pages: [1]