WiFly RN-XV Bad Packets

I've been wrestling with the WiFly RN-XV connected to the Arduino via the Wireless SD Shield for a while

I have the WiFly connected via hardware serial (Pins 1 & 2) and debugging going through software serial

I continue to have problems with bad data. The strange thing is that data sent out by the WiFly is fine, but any data I try sending to the WiFly from another device (Mac, iPhone, etc)...the data frequently gets garbled.

So I put in my own CRC32 data in the packet data and wrote my own data check and resend code, but it's just amazingly frustrating that I am only sending small packets of 30 to 50 bytes at a time and I still have this issue.

I've tried both UDP and TCP, but even TCP exhibits the same problem. And the problem becomes extremely severe if I try sending data to the WiFly over a busy Wifi network versus a quiet one.

One a quiet network, I might only have to resend a packet 1 out of 10 times. On a busy network I seem to have to resend just about every packet, and every packet has to be resent 4 or 5 times before it gets into the WiFly intact.

Any ideas of what might be going on here?

I have the WiFly connected via hardware serial (Pins 1 & 2) and debugging going through software serial

Hardware serial is on pins 0 and 1, I guess you meant that.

Any ideas of what might be going on here?

What kind of software do you use? The WiFly library or do you communicate directly with the module? Can you show us your code?

I use the same combination and never experienced similar problems.

What does garbled mean? Are additional characters inserted, do characters get lost or ar some character turned into other ones? Can you show us examples of correct input and garbled output?

Hi. Thanks for the reply. Yes, I meant to say pins 0 and 1. Sorry about that. I am using the WiFlyHQ library to talk to the chip

Are there any other recommended libraries out there?????)

I will have to make a simple test case I can post the code for everyone to look at shortly......

You might first see if you can get reliable comms between 2 PCs [or 2 terminal emulators
on the same PC] using SoftSerial directly, without the RN-XV in there. For some reason,
I never had any luck whatsoever with SoftSerial for reliable comms, although other
people seem to be using it. If that works ok, add the RN-XV. So, do the basics separately,
then put them together.

The other thing to check is the sort of bypassing they use on your shield, and check that
against what it says in the RN-XV datasheet. Some of these new devices specify upwards
to 3 bypass caps, plus a 500 uF electrolytic, on the Vcc pin.

@oric_dan: My experience with SoftwareSerial is similar, although it works in some cases at 9600 baud. I never got the RN-XV to communicate reliably using SoftwareSerial, seems to be quite picky in this aspect. But the OP stated he uses hardware serial to communicate with the RN-XV and that working very reliable for me for more than a year, never had anything like he described.

@epinc: Do you have the examples I requested? We might get some hint of what's the possible reason for your problems from the symptoms showing up.

Well, and there it goes. I've been troubleshooting this for a while, and then when i went to clean up my code enough for public posting and scrutiny, I found a bug where I was appending data to a buffer for parsing, and it turns out that after I had successfully grabbed a packet, I wasn't moving the buffer pointer to the correct position for the next batch under certain conditions. I can't believe I missed it all this time. But thanks for putting the point to me that I needed to post my code, else I wouldn't have taken the time to clean it up as much as I did.

Sketch Arduino for Wifly RN-XV modem configuration without Wifly library and
with front-end: https://dl.dropboxusercontent.com/u/101922388/WiflySanUSB.zip