Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Networking, Protocols, and Devices / Arduino Ethernet can't send more than 3 null bytes in a row? on: June 26, 2013, 03:27:48 pm
I was trying to use an Arduino Ethernet to send an OSC packet to a program over UDP.
One of the requirements for OSC is that you're about to have up to 4 NULL bytes in a row to fill white space.
Apparently, when an Arduino sees 3 NULL bytes in a row, it cuts off all the rest of the data in the packet!
If you wan to see this for yourself, try this Arduino program I wrote.
Change the IP addresses to something sane, then fire up Wireshark, look at the packet when it gets sent, and you'll see that everything after byte 20 in the char array is missing.

I'm not trying to solve this problem any more as I found a different solution, but I thought I'd point this out as I think it's either a bug, or a limitation of the Wiznet chip.

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 <EthernetUdp.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[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
IPAddress ip_remote(192, 168, 1, 100);

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

// 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
//char oscBuffer[] = "/track2/connect ,i     1";
char oscBuffer[] = "/track2/connect ,i     1";

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

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

  Serial.begin(9600);
  //Serial.println(oscBuffer);
  Udp.beginPacket(ip_remote, 7000);
  //Udp.write("/track1/connect/i1");
  oscBuffer[0] = 0x2f;
  oscBuffer[1] = 0x74;
  oscBuffer[2] = 0x72;
  oscBuffer[3] = 0x61;
  oscBuffer[4] = 0x63;
  oscBuffer[5] = 0x6b;
  oscBuffer[6] = 0x31;
  oscBuffer[7] = 0x2f;
  oscBuffer[8] = 0x63;
  oscBuffer[9] = 0x6f;
  oscBuffer[10] = 0x6e;
  oscBuffer[11] = 0x6e;
  oscBuffer[12] = 0x65;
  oscBuffer[13] = 0x63;
  oscBuffer[14] = 0x74;
  oscBuffer[15] = 0x00;
  oscBuffer[16] = 0x2c;
  oscBuffer[17] = 0x69;
  oscBuffer[18] = 0x00;
  oscBuffer[19] = 0x00;
  oscBuffer[20] = 0x00;
  oscBuffer[21] = 0x00;
  oscBuffer[22] = 0x00;
  oscBuffer[23] = 0x01;
 
  Serial.println(" ");
  for (int i=0; i<24; i++) {
    Serial.println(byte(oscBuffer[i]));
  }
 
  Udp.write(oscBuffer);

  Udp.endPacket(); 
}

void loop() {
}

2  Using Arduino / LEDs and Multiplexing / Re: Smaller Darlington array replacement on: May 09, 2013, 08:58:37 am
Thanks!
What about with a 1W LED?
Would a ULN2803A be able to handle that?
3  Using Arduino / LEDs and Multiplexing / Smaller Darlington array replacement on: April 26, 2013, 12:42:23 pm
I'm looking to control some LEDs that could be between 1W and 3W.
I've been using the ULN2803A but it's kind of big, I only need 3 channels.
ULN2001 is slightly smaller but not by much.
What would be a good replacement?
4  Using Arduino / Project Guidance / Re: Hardware architecture for UDP in WIFI on: January 05, 2013, 08:49:13 pm
The Atmega 32UC3 has a stack that supports both TCP and UDP but no one has implemented a high level library in Arduino which can access the UDP functionality.
5  Using Arduino / Networking, Protocols, and Devices / Re: Arduino WiFi Shield UDP Support on: December 22, 2012, 01:27:41 pm
Count me as one more person who bought the Arduino WiFi shield thinking it would have a simple UDP example like the Ethernet shield did and then found out it didn't. Whoops. Hopefully someone figures this out soon.
6  Using Arduino / Networking, Protocols, and Devices / Re: XBee S6 WiFi with Wireless SD Shield howto on: November 04, 2012, 09:36:29 am
It looks like the way to get that library working it to make sure the XBee is in API mode, AP=2.
7  Using Arduino / Networking, Protocols, and Devices / XBee S6 WiFi with Wireless SD Shield howto on: November 01, 2012, 12:29:25 am
I've been trying to get the XBee WiFi working with an Arduino Uno using a Wireless SD shield.
I've managed to get the XBee to connect to an-secured AP.
I did this by sending commands from the Serial Monitor.
I've also gotten it working using Arduino code.

Here's my notes for how to get it working with the Serial Monitor:
1. Plug the Wireless SD Shield into the Arduino Uno.
2. Set the Serial Select toggle switch on the Wireless SD shield to USB.
3. Plug the XBee S6 WiFi module into the shield.
4. Add a 470uf cap into the shield going from XBee pin 10 (GND) to pin 1 (3.3V).
This is because the XBee WiFi has an initial power spike when the Arduino is first turned on that is too high for the Arduino to handle (see page 14 of manual: http://ftp1.digi.com/support/documentation/90002124_F.pdf )
5. Upload this sketch to the Arduino:
Code:
void setup() {
}

void loop() {
}
6. Open the Serial Monitor
7. Set line ending pull down to No Line Ending.
8. Type +++ and press Send. The XBee should reply with OK.
9. Set line ending  pull down to Carriage Return.
10. Type ATIDFoo and press Send, where Foo is the name of your un-secured AP. The XBee should reply with OK.
11. Wait 10-20 seconds and you should try pinging whatever DHCP address you would expect the device to be added by the router.

Here's the version of the instructions for getting it working with some Arduino code so the computer can be removed from the equation:
1. Plug the Wireless SD Shield into the Arduino Uno.
2. Set the Serial Select toggle switch on the Wireless SD shield to USB.
3. Plug the XBee S6 WiFi module into the shield.
4. Add a 470uf cap into the shield going from XBee pin 10 (GND) to pin 1 (3.3V).
This is because the XBee WiFi has an initial power spike when the Arduino is first turned on that is too high for the Arduino to handle (see page 14 of manual: http://ftp1.digi.com/support/documentation/90002124_F.pdf )
5. Upload this sketch to the Arduino:
Code:
void setup() {
  Serial.begin(9600);
  Serial.print("+++");
  delay(5000);
  Serial.println("ATIDFoo");
}

void loop() {
}
Note: For the line Serial.println("ATIDFoo");, the Foo should be replaced by the name of your un-secured AP.
6. Set the Serial Select toggle switch on the Wireless SD shield to MICRO.
7. Push the reset button on the Wireless SD shield.
8. Wait 10-20 seconds and you should try pinging whatever DHCP address you would expect the device to be added by the router.

It was quite a journey getting to this point.

I started out thinking the code built into the Arduino WiFi library should 'just work' if I plugged an XBee WiFi into the Wireless SD Shield:
http://arduino.cc/forum/index.php/topic,127202.msg975073.html#msg975073

Of course that's not the case since the XBee WiFi uses a completely different chipset.

So I switched to trying to get this XBee WiFi port from the mbed working:
https://github.com/Akira-Hayasaka/XBeeWiFi_Arduino

It's a work in progress, it doesn't even have an Arduino sketch, just C++ code.
Eventually I got it to compile:
http://arduino.cc/forum/index.php/topic,129822.msg976983.html#msg976983

I still haven't gotten that library to work.
Ultimately I imagine the existing XBee library would be more efficient than what I'm doing, but for now this is the only method I have that works.
I haven't seen any tutorials on how to integrate all these tricks together to get past the pitfalls for this particular XBee so I thought I would post all my notes here. Maybe I'll turn this into a tutorial soon, probably once I've explored a bit more about how to do something more interesting with the XBee WiFi.
8  Using Arduino / Programming Questions / Re: [SOLVED] Referencing objects defined in an external header from a header on: October 30, 2012, 09:43:08 am
Had to dig a bit but found the regex that looks for the include files PdeProcessor.java.
Interesting stuff.
Thanks a lot.
9  Using Arduino / Programming Questions / [FIXED] Re: Referencing objects defined in an external header from a header on: October 29, 2012, 11:45:26 pm
Wow, thanks.
Ok, WHY did that fix it?
10  Using Arduino / Programming Questions / [SOLVED] Referencing objects defined in an external header from a header on: October 29, 2012, 11:38:39 pm
So I'm trying to get the XBee Wifi working with Arduino.
I found this wrapper library that someone ported from mbed:
https://github.com/Akira-Hayasaka/XBeeWiFi_Arduino

Unfortunately I think they made some mistakes.
Here's the sketch I wrote just to try compiling the code:
Code:
#include "XBeeWiFi.h"

void setup() {
}

void loop() {
}

The first of many errors is this:
In file included from Engenius.cpp:1:
/Users/jacob/Documents/Arduino/libraries/XBeeWiFi/XBeeWiFi.h:118: error: 'IPAddress' has not been declared

IPAddress comes from the Ethernet.h file in the standard Arduino libs.
So what I think is going on has to do with how they do their includes in the header file:
https://github.com/Akira-Hayasaka/XBeeWiFi_Arduino/blob/master/XBeeWiFi.h

I tried changing this include:
#include "../Ethernet/Ethernet.h"

To this:
#include <Ethernet.h>

Which still doesn't see the library.

After digging around in some other libraries I've noticed that you don't seem to be able to include external header files from separate libraries in your header file.
However, you can include external header files in the .cpp file.

Here's a great example of that. In this library they're including the SPI.h file in the .cpp file:
https://github.com/adafruit/Adafruit-WS2801-Library/blob/master/Adafruit_WS2801.cpp

Why does it work like that?
Are you just not allowed to reference objects defined in an external header file in your header file?
Is this a dark corner of C I never learned about?
Or is this some avr-gcc specific restriction?
Or is it an Arduino specific restriction?
11  Using Arduino / Networking, Protocols, and Devices / Re: WiFi shield not present on: October 28, 2012, 10:23:29 pm
This is also a really helpful link for getting the Xbee WiFi working with the Wireless SD shield:
http://arduino.cc/forum/index.php/topic,114936.0.html
12  Using Arduino / Networking, Protocols, and Devices / Re: WiFi shield not present on: October 20, 2012, 02:04:54 am
http://arduino.cc/forum/index.php?topic=126065.0

Alright at least I'm not the only one making this mistake.

I found out about the XCTU software so I at least need to configure the Xbee first.
Having some trouble getting it working with my XBee Explorer USB but hopefully this post is going to help with that:
https://forum.sparkfun.com/viewtopic.php?f=14&t=29697

Eventually I'm going to try out this code:
https://github.com/Akira-Hayasaka/XBeeWiFi_Arduino
13  Using Arduino / Networking, Protocols, and Devices / Re: WiFi shield not present on: October 14, 2012, 02:36:21 pm
What exactly are you expecting links to?

Code (from a standard Arduino library):
http://arduino.cc/en/Tutorial/ScanNetworks

XBee module:
http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/point-multipoint-rfmodules/xbee-wi-fi#overview

Wireless SD shield:
http://arduino.cc/en/Main/ArduinoWirelessShield

I guess the Wireless SD shield doc doesn't explicitly say it will work with the XBee S6 as it mainly mentions the S2 family and the ZigBee stuff, but I don't see any reason it shouldn't support it either. I was under the impression it was just a convenience form factor for plugging the XBee module in and didn't actually do anything special.
14  Using Arduino / Networking, Protocols, and Devices / WiFi shield not present on: October 14, 2012, 02:11:40 pm
So I just got a Wireless SD Shield which I've mated with an Arduino Uno and an XBee S6.
I uploaded a few of the wireless sketches like ScanNetworks and ConnectWithWPA but no matter which one I use it doesn't work.
When I open up the Serial terminal this is what I see:
WiFi shield not present
Which is strange seeing as how the lights on the Wireless Shield definitely are on.
I've tried it on both the Micro and USB settings and neither works.
What am I doing wrong here?
15  Using Arduino / Installation & Troubleshooting / Re: Smoke of death on: June 19, 2012, 05:14:16 pm
Thanks for pointing out those preferences, really useful.
I was able to program the board using the pocket programmer!
I enabled verbose output and then uploaded to a different board, changed the command to match my board and programmer, made sure to remove the -P option since I don't need it through ICSP, and it totally works.

Maybe I'll pick up a new FTDI chip and see if I can fix the board at some point.
Pages: [1] 2 3 ... 5