Rn-xv ftp problem

Hello i am using an rn-xv 171 and i am trying to upload data on an ftp server…

when i am using the module on gateway mode it works properly and does what i want…when i am trying to upload the commands as a code i am getting an err-?cmd and even if it connects to the wifi after a little bit it never sends the data…http://imgur.com/c1zrnRq this is the error and the code is this

int cont;
char recv[512];

void setup()
{

Serial.begin(9600);
}

void loop()
{
while (Serial.available()>0) {}
// Enters in command mode
Serial.print("$$"); check();


// Sets DHCP and TCP protocol
Serial.print("set ip dhcp 1\r"); check();
Serial.print("set ip protocol 2\r"); check();

// Configures the way to join the network AP, sets the encryption of the
// network and joins it
Serial.print("set wlan join 0\r"); check();
Serial.print("set wlan phrase 089F2DC06A\r"); check();
Serial.print("join Thomson81C748\r"); check();
Serial.print("set ftp address 185.4.135.79"); check();
Serial.print("set ftp user username"); check();
Serial.print("set ftp pass password"); check();
Serial.print("set ftp dir ./httpdocs/tasos/"); check();
Serial.print("ftp put anarxia.txt "); check();
Serial.print("hello"); 
Serial.print("set ftp timer 40"); check();

}

void check(){
cont=0; delay(1000);
// Receive the answer from the WIFI module.
while (Serial.available()>0)
{
recv[cont]=Serial.read(); delay(100);
cont++;
}
recv[cont]='\0';
// Print the answer.
Serial.println(recv);
// Clean the buffer to be able to send a command.
Serial.flush(); delay(1000);
}

is there someone that knows why this happends ? i read similar posts in the forum but i couldnt find an answer thats why i am doing this post.Thanks

Did you send the command sequence $$$ yourself in that serial monitor image? Or are all occurrences of this somehow generated by the program? The 6 dollar signs at the beginning don’t make sense.

In the check function, I would add some code to make the very first character of the recv string to be always a known unique symbol. (which isn’t used in the command protocol) So then you can identify what is the configuration command sent to the RN-XV, and what is the response from it send by the check function.

p.s. PLease make use of the [code ] [/ code] tags or use the button in the full message editor. It shortens the post and shows the code neater.

Valen:
Did you send the command sequence $$$ yourself in that serial monitor image? Or are all occurrences of this somehow generated by the program? The 6 dollar signs at the beginning don’t make sense.

In the check function, I would add some code to make the very first character of the recv string to be always a known unique symbol. (which isn’t used in the command protocol) So then you can identify what is the configuration command sent to the RN-XV, and what is the response from it send by the check function.

p.s. PLease make use of the [code ] [/ code] tags or use the button in the full message editor. It shortens the post and shows the code neater.

sry for the code tags.No thats the thing…all these are generated by the program.When i put all this commands by myself on gateway mode it works perfectly but when i use this code i am getting these erros (err-?cmd) and i dont understand why. :confused: also because i am kind of newbie could you explain me what you mean about putting a unique symbol ? i am building the code piece by piece from what i find on internet and from the help that i get.Thanks for your reply

Something like this:

void check(){
cont=0;
recv[cont]='@'; // Start with 'answer' symbol in recv string.
cont++;
delay(1000);

...

I think it is better to learn the various commands available in Arduino, and the language elements in C/C++ and play around with that. Just copying code from someone else is not going to make lightbulbs flash on in your head.

Or replace with some other character that does not exist in the command repertoire . I don’t know what the available commands are for this module.

Unfortunately nothing changed :confused: i believe that i have an idea what the problem could be.when the program is typing a command it serial prints it. When i am getting the answer with void check(),to print it to the UART i also serial print it so it sends it to the wifi module and this messes the things cause the module doesnt understand the command and gives an err-?cmd(error for false command)…does this theory sound right? Is there something that i can do to fix it?

// Print the answer.
Serial.println(recv);

The above appears to send the RN-XV response back to the RN-XV, which doesn’t make much sense.

You seem to be trying to use the serial output to send data to the serial monitor as well as to the RN-XV. You can’t. You can use the serial port to talk to only one device at a time.

You should delete this delay() call.

recv[cont]=Serial.read(); delay(100);

If i delete the delay it will make any difference? Yes i understood that and thats why i probably get these erros,cause i am sending the answer back to the module. If i erase the check() function nothing is happening…i am not getting an AOK confirmation :confused: so i have no idea what to do.

Why did you put the delay there? It serves no purpose other than to miss incoming characters.

You need two serial ports to configure the module, if you want to see the responses.

And how can i have 2? If i delete this function that shows me the response the program just prints the commands and its like it doesnt sending them to the module :confused: the weird thing is that even with the errors at some point it connects to the network but the ftp commands never work.At gateway mode when i put the commands i send the file and i print what i want in it.

We don’t know what kind of arduino model you have, but…

Markos13:
And how can i have 2? …

[https://www.arduino.cc/en/Reference/SoftwareSerial](https://www.arduino.cc/en/Reference/SoftwareSerial)

They said me about softwareserial in another forum that i asked for help. I tried to look for a tutorial or something to explain how to do it on my situation but i didnt find something :confused: i tried to do it by myself but i didnt come to any result. I have an arduino UNO and i cant use arduino mega.Please if you could provide me with some example or some hints i would really appreciate because what i am trying to do is for my university project.

Google will show you many, many examples of software serial on the web. The Arduino forum alone has thousands of posts with examples.

Note that the standard software serial doesn’t always work correctly. There is a smaller, simpler alternative: http://forum.arduino.cc/index.php?topic=251764.0

I will take a look at this,look for examples and try to understand.I will post again when i have an update :slight_smile: thanks for now.

So i didnt have any luck with the softwareserial or the example that you posted :confused: in softwareserial to work should i change with jumpers the tx-rx from the xbee communication shield and put 2 others so the module can recieve the data? I dont seem to understand :confused: