Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

CR300 FTPClient control, not robust?


jsilva Jan 8, 2019 07:24 PM

Hi there, 

i'm facing some issues with FTPClient command in CR300 logger that seems to be causing logger watchdog errors.

My requirements are:

- Must read 5 analog ports and store data at 1hz

- Must send it over GPRS to my FTP server

- i need to add a "ID,PASS" string on the first line of each file

- The server if monitoring and dealing with the files (reading and moving it)

The datatable is simple:

DataTable(Dados,True,-1)
  DataInterval(0,1,Sec,10)
  Sample(1,WindSpeed,FP2)
  Sample(1,WindDir,FP2)
  Sample(1,Temperature,FP2)
  Sample(1,RH,FP2)
  Sample(1,Barometro,IEEE4)
  Sample(1,BattV,FP2)
EndTable

At Begining of the program, it creates a 'temp.dat' file in CPU and add ID,PASS\r\n in the first line:

BeginProg
   SW12(0) ' Turn on gprs modem
   Netstat = PPPOpen
   ' Create file with ID,PASS
   Fhandle = FileOpen("CPU:temp.dat","W",0)
   FileWrite(Fhandle,ID & CHR(44) & PASS & CHR(10),0)
   FileClose(Fhandle) 

The main scan runs at 2Hz, reads the ports and call Dados table:

Scan(500,mSec,1,0)
 Battery(BattV)
 PanelTemp(PTemp_C,400)

CurrentSE(WindSpeed,1,mV2500,1,False,10000,60,3.75,-15) If WindSpeed < 0 Then WindSpeed = 0 EndIf CurrentSE(WindDir,1,mV2500,2,False,10000,60,22.4375,-89.75) If WindDir < 0 Then WindDir = 0 EndIf VoltSe(Temperature,1,mV2500,3,False,10000,60,1,0) Temperature = 0.1*Temperature-40 VoltSe(RH,1,mV2500,4,False,10000,60,1,0) RH = RH*0.1 VoltSe(Barometro,1,mv2500,5,False,500,60,0.4,260) CallTable Dados
NextScan

Then i tried to send the data:

- First send the 'temp.dat' file and rename it to 'timestamp.temp' in server
- If the file is created, then append up to "RecMaximo" (=1200 at now) to the ftp file 'timestamp.temp'
- If everything is OK, rename it to 'timestamp.dat' to be processed by the server
- If not, try delete it

SlowSequence
  Scan(10,Min,0,0)
      
      FileName = RDir & PFile & Public.Timestamp(5,1) & PExt 
      FTPSucesso = FTPClient (Host,User,Pass,"CPU:temp.dat",FileName & ".temp",9,,,,,10000)
      
      If FTPSucesso Then 'FTP file created
        FTPDados = FTPClient (Host,User,Pass,"Dados",FileName & ".temp",9,0,RecMaximo,Sec,-1013,75000)
        
        If FTPDados = -1 Then ' Send data OK
          FTPSucesso = FTPClient (Host,User,Pass,FileName & ".temp",FileName,5,,,,,10000)
        EndIf
        If FTPDados = -2 Then  'Trying to delete temp file if send fail (possibly corruped data on file)
          FTPSucesso = FTPClient (Host,User,Pass,"",FileName & ".temp",4,,,,,10000)
        EndIf 
      EndIf
  NextScan

 Vars to be able to compile if you want:

 

Public BattV
Public PTemp_C
Public WindSpeed
Public WindDir
Public Temperature
Public RH
Public Barometro
Public RecMaximo = 1200   

Const PASS  = "NGFKVM"
Const ID = "CAS0232"
Const Host  = "ftp.server.com.br"
Const User  = "ftpuser"
Const Pass  = "ftppassword"
Const RDir  = "/directory/"
Const PFile = "file_"
Const PExt  = ".dat"

Public Netstat As String *500
Public Fhandle As Long
Public FTPSucesso As Boolean
Public FTPDados 
Public FileName As String * 200

 

As you can see, i don't have any control over the data sended by FTP, it all being done by the FTPClient.

This code is running but it's not reliable, some problems that i'm facing with:

- It runs flawless for days, then it stops complety, i need to restart the program, logger still running, just fails every FTP attempt

- Sometimes Logger restarts with watchdog error, all CPU: Memory are the Fully used, no free space anymore, it still logging data but  i need to format the memory to logger start to send data again. 

The datatable data interval is directly related to the frequency of fails, so seems to be some internal data management problem in FTPClient().

 Any ideas? I have a very reliable program running on CR800 logger, but uses somes functions that CR300 don't support..


Terri Jan 14, 2019 08:31 PM

What is the OS version?

What is the hardware connection? USB, internal or external Cell modem, etc?


jsilva Jan 16, 2019 11:38 AM

OS 6.01 on remote site, wondering if i can update it by tcp connection, never done that.

the modem is connected  by RS-232.

i have an testbench logger with 7.05 now, i'm leaving the same program running to see if OS update will solves the error.

An watchdog info .txt file - Last watchdog info i've downloaded

Log in or register to post/reply in the forum.