Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / dataFile.size(); returning negetive values on: August 19, 2014, 04:18:05 pm
Hi,
I have an issue with the .size() method returing negative vaues. See code exerpt below;

Code:
dataFile = SD.open(dateString);      //the days date
    if (dataFile) {
      archivosize = dataFile.size();     
      Serial.print(F("\nFileSize> "));
      Serial.println(archivosize);

The above is part of a larger routine that sends data to an ftp server so teh size of the file is required and, obviously,  when the result is negative, the ftp upload fails.

The way it works is that when the program starts it uploads a small test file  to the server  - this works -  then at midnight of each day and each subsequent day it sends teh actual data file - this works for the midnight of the first day (filesize ~20kB) but fails on the midnight of the second day (filesize ~50kB). Could the size of the file be an issue.

Any help is much appreciated.

Cheers.
2  Products / Arduino Yún / Re: Issue connecting to YUN after initial attempted configuration on: July 13, 2014, 04:08:14 pm
Hi Federico,
AN thanks for the reply. In fact i am using linux to do the configuration.

Cheers.
3  Products / Arduino Yún / Issue connecting to YUN after initial attempted configuration on: July 13, 2014, 06:22:43 am
Hi,
I am having a problem connecting to the YUNs web page after having initially attempted to configure it. Initially the instructions i had indicating a connection to the webpage via arduino.local/ however this didnt work but i could connect using 192.168.240.1 and entered the configuration page and all this went fine i then clicked the button to configure and restart the YUN but nothing seemed to happen. After a while i decided to to try to reconnect to 192.168.240.1 but couldnt and the reference to arduino YUN no longer appears in the wifi list.
The linux side does seem to be working  as i can acess it using YUN serial monitor and the arduino side seems to be  working. So not sure why i cant access configuration web page. Is there a way to reset all this. Using the various reset buttons doesnt seem to do anything.

Any help is much appreciated.

Cheers.
4  Products / Arduino Yún / USB modem and YUN on: June 29, 2014, 06:08:05 pm
HI,
Can the YUN be used with a USB modem such as the Huawei ones and what, if anything, is required to get them setup to run properly. I have a Huawei hiLink modem (E303) and this seems to work out of the box on Linux - so should be OK on the YUN?

Any Help is much appreciated.

Cheers.
5  Using Arduino / Project Guidance / Re: understanding how to do FTP transfers with GSM/GPRS shield on: May 24, 2014, 12:36:03 am
Hi Wanderson, and thanks for the reply.
Yes i have tried this code  and variations of it the result is the same  - fails at;

AT+FTPGET=1

with response;
+FTPGET:1,64

Which is again the timeout error.

The AT sequence as written also fails at;

AT+CIICR  with response;
+PDP Deact

How ever if i put in;
at+cstt="internet","username","password" before this command then it works only to fail later on at;

AT+FTPGET=1 again.

Any ideas?

Any help is much appreciated.

Cheers.

6  Using Arduino / Project Guidance / Re: understanding how to do FTP transfers with GSM/GPRS shield on: May 23, 2014, 05:41:44 pm
Hi PeterH,
And thanks for the reply - as you can tell i am not really sure what i am doing. The device i am using is a GSM/GPRS shield from Seeedstudio which is apparetnly able to do FTP  as well as HTTP etc. I am trying to do passive mode FTP. I only tried to use a TCP connection because every thing else failed - ironically that bit worked.

I can do SMS using the AT comands no prblem and i can connect to the ftp sever using a TCP socket as well, havent tried HTTP as yet which is apparently easier as it only requires a TCP connection.

I can do FTP transfers over a network using  a dedicated library like the FTP library that is used with the processing IDE which indicates that username, password, etc are all correct.

Anyway...  these are the command sequences that i have tried in the past to do FTP along with the responses - this is for an FTP get;

Code:
AT

OK
AT+CSQ

+CSQ: 23,0

OK
AT+CGATT?

+CGATT: 1

OK
AT+CSTT

OK
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","internet"

OK
AT+SAPBR=1,1

OK
AT+FTPCID=1

OK
AT+FTPMODE=1

OK
AT+FTPTYPE="A"

OK
AT+FTPSERV="ftp.xxxx.xx.xx"

OK
AT+FTPUN="user"

OK
AT+FTPPW="pass"

OK
AT+FTPGETNAME="test.log"

OK
AT+FTPGETPATH="/file/path"

OK
AT+FTPGET=1

OK

+FTPGET:1,64
AT+FTPGET=2,1024

+CME ERROR: operation not allowed

It always seems to fail at the same place and it doesnt matter wether its a PUT or a GET operation. Sometimes i get the 61 error (network error) but mostly its 64 (timeout error).

Any help you can give is very much appreciated as i have been banging my head aganist a wall with this.

Cheers.
7  Using Arduino / Project Guidance / Re: understanding how to do FTP transfers with GSM/GPRS shield on: May 20, 2014, 06:14:30 am
Hi Chagrin,
Thanks for the reply. No i dont have to use FTP i just assumed i had to because i am dealing with an ftp server - as you can tell my knowledge of this stuff is limited. Basically i just want to be able to upload a file to an ftp server but so far i have failed to get this to work so any suggestions or examples you have would be great.

Any help is much appreciated.

Cheers.
8  Using Arduino / Project Guidance / understanding how to do FTP transfers with GSM/GPRS shield on: May 19, 2014, 05:33:43 pm
Hi,
I have been having a number of issues trying to get FTP uploads/downloads to work from an FTP server using AT commands and a GSM/GPRS shield (SIM900) - i have a tried a lot of example code but nothing seems to work so i have decided to go back to squar 1 and explain what exacly i am doing and see if poeple think makes logical sence or whether my aproach is completely flawed.

As i understand it the FTP process requires two channels - one channel for data and the other channel for commands.

So....

1) Attempt to open a TCP connection to the ftp server on port 80 with the correct APN, username and password using the relavant AT commands.

2) Once a connection is made attempt to open an FTP session on port 21 with the correct  APN, username and password (same as above) using the relavent AT comands.

Does this seem like the right aproach or am i way off here.

I can get the first part to work and i can even send test data to the server although i have no idea where the data goes as there doesnt to be anywhere for it to go as i havent explicity told it to it where to go i just get a message back from the shield saying that the data has been sent.

The second part always fails due to a timeout error.

Initially i did it without setting up the TCP connection but then it seemed to me that this wouldnt work since there was no data connection.

Any help/guidance here would be much appeciated.

Cheers.
9  Using Arduino / Programming Questions / timeout error downloading a file wirelessly from an ftp server using AT commands on: May 18, 2014, 12:28:12 am
HI,
I am using an arduino uno R3 and a GSM/GPRS shield (SIM900) to download files from an FTP server using the sim900 AT commands. The code and the responses to the code from the sim900 are given below. Everything seems to work except for actually getting the data from the server which is when i get the timeout error. The main problem is that i cant "see" the server responses to see what is causing the timeout error. The timeout error is indicated by +FTPGET=1,64 (64  = timeout) should be +FTPGET=1,1 every thing after the time out obviously fails.

Can anybody see any problems with how i am doing this and maybe suggest a better way (TCP/IP??).

Any help is much appreciated.

Cheers.

Code:
#include <SoftwareSerial.h>

SoftwareSerial sim900(7, 8);

int x;
char data[1024];

void setup(){
  Serial.begin(9600);    // UART baud rate
  sim900.begin(19200);
  Serial.println("Starting FTP Download...");
 
  for (int i=0;i< 5;i++){
    delay(2000);
  }
 
  //Serial.println("AT+CGSOCKCONT=1,\"IP\",\"myapn\"");
  //Serial.flush();
 
  //response();
}

void loop() {
  sim900.println("AT"); //check AT
  sim900Reply();
  sim900.println("AT+CSQ"); //check signal strength
  sim900Reply();
  sim900.println("AT+CGATT?");
  sim900Reply();
  sim900.println("AT+CSTT");
  sim900Reply();
 
  /*sim900.println("AT+CIICR");   
  //Serial.flush();
  sim900Reply();
  sim900.println("AT+CIFSR");   
  //Serial.flush();
  sim900Reply();*/
 
  sim900.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  sim900Reply();
  sim900.println("AT+SAPBR=3,1,\"APN\",\"internet\"");
  sim900Reply();
  sim900.println("AT+SAPBR=1,1");
  sim900Reply();
  sim900.println("AT+FTPCID=1");
  sim900Reply();
  sim900.println("AT+FTPMODE=1");
  sim900Reply();
  sim900.println("AT+FTPTYPE=\"A\"");
  sim900Reply();
  sim900.println("AT+FTPSERV=\"ftp.xxxx.xx.xx\"");            //write your FTP server domain
  sim900Reply();
  sim900.println("AT+FTPUN=\"user\"");
  sim900Reply();
  sim900.println("AT+FTPPW=\"pass\"");
  sim900Reply();
  sim900.println("AT+FTPGETNAME=\"test.log\"");
  sim900Reply();
  sim900.println("AT+FTPGETPATH=\"/file/path/\"");        //write the correct directory path.
  sim900Reply();
  sim900.println("AT+FTPGET=1");                             //starts FTP session
  sim900Reply();
  sim900Reply2();
  sim900.println("AT+FTPGET=2,1024");                        // gets 1024 bytes of data
  sim900Reply();
}

void sim900Reply() {
  x=0;
  do{
    //Serial.println("in here");  //testing
    while(sim900.available()==0);
    data[x]=sim900.read();
    Serial.print(data[x]);
    x++;
  } while(!(data[x-1]=='K'&&data[x-2]=='O'));
}

void sim900Reply2() {
  x=0;
  do{
    while(sim900.available()==0);
    data[x]=sim900.read();
    Serial.print(data[x]);
    x++;
  } while(!(data[x]=='+'));
  do{
    while(sim900.available()==0);
    data[x]=sim900.read();
    Serial.print(data[x]);
    x++;
  } while(!(data[x]=='\n')||(data[x]=='\r'));
}

SIM900 reponses;
Code:
Starting FTP Download...
AT

OK
AT+CSQ

+CSQ: 23,0

OK
AT+CGATT?

+CGATT: 1

OK
AT+CSTT

OK
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","internet"

OK
AT+SAPBR=1,1

OK
AT+FTPCID=1

OK
AT+FTPMODE=1

OK
AT+FTPTYPE="A"

OK
AT+FTPSERV="ftp.xxxx.xx.xx"

OK
AT+FTPUN="user"

OK
AT+FTPPW="pass"

OK
AT+FTPGETNAME="test.log"

OK
AT+FTPGETPATH="/file/path/"

OK
AT+FTPGET=1

OK

+FTPGET:1,64
AT+FTPGET=2,1024

+CME ERROR: operation not allowed


10  Using Arduino / Programming Questions / Re: Using serialEvent() with arduino mega2560 on: March 24, 2014, 06:04:12 pm
Hi,
And thanks for all the replies.

I have now done the following;
Created a separate string for each serialEvent() to read data into and moved all the post processing to the main loop so that all the serialEvents()'s only read available data into a string.

This approach did make an improvement but was still creating strings with data written on top of each other but the frequency with which this is happening is now less - about every 20 times through the loop errors would occur. I then cheated slightly and told the post processing to ignore strings over a certain length and this has created the output i want although it is not strictly ideal as some data gets ignored but it is still getting enough to be acceptable.

I will continue to work on this to make it more accurate.

Again, thanks for all your help.

Cheers.
11  Using Arduino / Programming Questions / Re: Using serialEvent() with arduino mega2560 on: March 23, 2014, 11:12:48 pm
Hi ,
zoomkat: The data streams are delimited by line feeds and carriage returns so i collect data until a line feed is reached and don't start data collection until i receive an "L" (start of the Stream). This data is put into the String called "inString".

Caltoa: I have removed all delays apart from the one in the serialEvent() that makes sure there is something to receive and i have reduced this to  500uS. Incoming stream is at 9600 baud. This did help a little bit but still getting strings written on the end of other strings. Sometimes i get three complete strings stored in "instring".

One thing i haven't tried is to flush the hardware buffer  before reading instead of after reading it which makes more sense.

Cheers.

12  Using Arduino / Programming Questions / Re: Using serialEvent() with arduino mega2560 on: March 23, 2014, 08:22:10 pm
Hi Caltoa,
And thanks for the reply.

Year i did spot the =+ and have changed it. I will check out the links. I thought it may have a been a timing issue with respect to to much data coming in at once, so i tried putting in some delays in the serialEvent() functions but this had no effect - in fact it seemed to make it worse.

The flush function is supposed to prevent multiple reads but i am not sure if i am making the correct use of it.

Cheers.
13  Using Arduino / Programming Questions / Re: Using serialEvent() with arduino mega2560 on: March 23, 2014, 07:19:48 pm
Hi,
And thanks for the reply although i dont quite understand what you mean. As i understand it the serialEvent() functions run in-between each run of the main loop.  If there is serial data in one or more of the hardware serial buffers  serialEvent1(), serialEvent2() and serialEvent(3) will be triggered one after the other, updating the value of inString as they do so and in this case logging each time.

Have i got this wrong?

Cheers.
14  Using Arduino / Programming Questions / Using serialEvent() with arduino mega2560 on: March 23, 2014, 06:42:13 pm
Hi,
I am using arduino mega2560 R3 with 3 hardware serial inputs and the serialEvent() function. This seems to work fine when the input serial streams only occur on one serial input at a time. When serial input is occurring on all three hardware serial ports at the same time i get slightly garbled output e.g serial streams will be put on the end of the serial stream from a previous read etc.

I have included the code excerpt below and some example output when two of the three hardware serial ports are receiving at the same time.

Any help is much appreciated.

Cheers.

Code:
void serialEvent1() {
  if (Serial1.available() > 0) {
    inString =+ "1,";   
    // get the new byte:
    char inChar = (char)Serial1.read();
    while (inChar != 'L') {inChar = (char)Serial1.read();}
    // add it to the inputString:
    while (inChar != '\r') {
      while (!Serial1.available()) delay(1);
      inString += inChar;
      inChar = (char)Serial1.read();
    }
   
    Serial1.flush(); // stops multiple reads
   
    if (inString.length() > 20) {
      logTag();
      chkIfNewTag();
      inString = "";
    }
    else {
       inString = "";
    }
  }
}

void serialEvent2() {
  if (Serial2.available() > 0) {
    inString += "2,";
     // get the new byte:
     char inChar = (char)Serial2.read();
     while (inChar != 'L') {inChar = (char)Serial2.read();}
     // add it to the inputString:
     while (inChar != '\r') {
       while (!Serial2.available()) delay(1);
       inString += inChar;
       inChar = (char)Serial2.read();
     }
     
     Serial2.flush(); // stops multiple reads
     
     if (inString.length() > 20) {
       logTag();
       chkIfNewTag();
       inString = "";
     }
     else {
       inString = "";
     }
   }
}

void serialEvent3() {
  if (Serial3.available() > 0) {
    inString += "3,";
     // get the new byte:
     char inChar = (char)Serial3.read();
     while (inChar != 'L') {inChar = (char)Serial3.read();}
     // add it to the inputString:
     while (inChar != '\r') {
       while (!Serial3.available()) delay(1);
       inString += inChar;
       inChar = (char)Serial3.read();
     }
     
     Serial3.flush(); // stops multiple reads
     
     if (inString.length() > 20) {
       logTag();
       chkIfNewTag();
       inString = "";
     }
     else {
       inString = "";
     }
   }
}

void logTag() {
  tagCnt++;
  //Serial.println(tagCnt,DEC);    //testing
  DateTime now = RTC.now();
  sprintf( timeString, "%d:%d:%d", now.hour(), now.minute(), now.second());
  // if the file is available, write to it:
  //tagString = "LR 0000 0000001234567890";
  //dataFile = SD.open(dateString,FILE_WRITE);
  //Serial.println(dateString);
  if (dataFile) {
    dataFile.print(timeString);
    dataFile.print(",");
    dataFile.println(inString);
    dataFile.flush();
    // print to the serial port too:
    Serial.println(inString);
    //inString = "";
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println(F("data logging error"));
    //for (;;){}
  }
  delay(20);
}


Example output from serial terminal
3,LA 00000 LA 00000 0 900 226000106155
1,LR 0000 0000000174825LR 0000 0000000174825496
3,LA 00000 0 900 226000106LA 00000 0 900 226000106155
1,LR 0000 0000000LR 0000 0000000174825496
3,LA 00000 LA 00000 0 900 226000106155
1,LR 0000 0000000174825LR 0000 0000000174825496
3,LA 00000 0 900 226000106LA 00000 0 900 226000106155
1,LR 0000 0000000LR 0000 0000000174825496
1,LR 0000 000000017482596
3,LA 00000 0 900 226000106155
1,LR 0000 0000000174825496
1,LR 0000 0000000174825496
3,LA 00000 0 900 226000106155
1,LR 0000 0000000174825496
3,LA 00000 0 900 226000106155
3,LA LA 00000 0 900 226000106155
1,LR 0000 000000017482549 0000000174825496
3,LA 00000 0 900 226000106155
1,LR 0000LR 0000 00000LR 0000 0000000174825496
3,LA 00000 0 900 226000106155
1,LR 0000 00000001LR 0000 0000000174825496
3,LA 00000 0 900 226000106155
1,LR 0000 000000017482LR 0000 0000000174825496
1,LR 0000 0000000174825496
3,LA 00000 0 900 22LA 00000 0 900 226000106155


15  Using Arduino / Project Guidance / Re: seeedstudio gprs v2.0 shield works with arduino but not with mega 2560 on: November 19, 2013, 04:22:01 pm
Hi Paul,
Thanks for the information - much appreciated.

Cheers.
Pages: [1] 2