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.

CR800 datalogger with telit kt863p6 gsm terminal cannot send files over ftpclient


miko Sep 19, 2019 02:14 PM

Hi All,

I'm trying to transfers cr800 data over ftpclient but, whatever I did cannot solve the problem. My codes are below, by the way for ftpclient should I use a simcard with static ip? Cr800 os is last version 32.03

"

Const APN="mgbs"
'Const APN="internet"
Const FTP_ADDR="*****"
Const FTP_LOGIN="*****"
Const FTP_PASSW="**********
Const Ist_No="020019"
Const yukseklik = 2.25

Public GlobGunRad
Public Guneslenme_mV,Guneslenme,Gunessuresi,DirekRAD
Public Sicaklik,NNem
Public rzgorthiz,rzgortyon',rzgmaxyon,rzgmaxhiz
Public BASINC
Public PTemp,batt_volt,ftp_success As Boolean,ftp_success_count
Public baglan,kes,gonder,
Public GSMSTR As String * 50,
Public Zaman(9),Yil As String * 16,Ay As String * 16,Gun As String * 16,saat As String * 16,dakika As String * 16,temp As String * 16
Public Flag(2) As Boolean,modem_absolute As Boolean
Public Active_File As String * 20
Public METEOR_File As String * 20
Public OLD_File As String * 20
Public Resend_File As String * 20
Public FileHandle1,readfile1
Public ftp_repeat,ftp_resend,serial_counter,first_start
Public Copy_IPInfo As String * 200,Last_IP As String * 50
DataTable (ham,1,1)
DataInterval (0,5,Min,5)
WindVector (1,rzgorthiz,rzgortyon,FP2,False,0,0,1)
FieldNames ("rzgorthiz,rzgortyon") ',rzgortyonStd
'StdDev (1,RuzgarHIZ,FP2,False)
Maximum(1,rzgorthiz,FP2,False,False)
FieldNames ("rzgmaxhiz")
SampleMaxMin (1,rzgortyon,FP2,False)
FieldNames ("rzgmaxyon")
Minimum (1,batt_volt,FP2,0,False)
EndTable

DataTable (OnDakika,1,-1)
DataInterval (0,5,Min,5)
Sample(1,ist_no,IEEE4)
Sample (1,yukseklik,FP2)
Average (1,GlobGunRad,FP2,False)
FieldNames ("GlobGunRad")
Sample (1,Gunessuresi,FP2)
Sample (1,Sicaklik,FP2)
Sample (1,NNem,FP2)
Sample (1,ham.rzgortyon,FP2)
Sample (1,ham.rzgorthiz,FP2)
Sample (1,ham.rzgmaxyon,FP2)
Sample (1,ham.rzgmaxhiz,FP2)
'Average (1,DirekRAD,FP2,False)
'Sample (1,BASINC,IEEE4)
'Average(1,PTemp,FP2,False)
'Minimum (1,batt_volt,FP2,0,False)
EndTable


Sub GSM_AC
PortSet (3,0)
EndSub
Sub GSM_KAPA
PortSet (3,1)
EndSub

Sub met_file_save
FileHandle1=FileOpen ("USR:meteor_file.txt","w",0)
FileWrite (FileHandle1,METEOR_File,0)
FileClose (FileHandle1)

EndSub
Sub met_file_read
FileHandle1=FileOpen ("USR:meteor_file.txt","r",0)
readfile1= FileReadLine(FileHandle1,METEOR_File,30)
FileClose (FileHandle1)
EndSub

Sub FileCheck

FileHandle1=FileOpen ("USR:"+Active_File,"r",0)
If FileHandle1=0 Then

FileHandle1=FileOpen ("USR:"+Active_File,"w",0)
FileClose (FileHandle1)
EndIf
FileClose (FileHandle1)
EndSub
Sub FileYaz
FileHandle1=FileOpen ("USR:"+Active_File,"a+",-1)
temp=ist_no
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
FileWrite (FileHandle1,Yil,0)
FileWrite (FileHandle1,"|",0)
FileWrite (FileHandle1,Ay,0)
FileWrite (FileHandle1,"|",0)
FileWrite (FileHandle1,Gun,0)
FileWrite (FileHandle1,"|",0)
FileWrite (FileHandle1,saat,0)
FileWrite (FileHandle1,"|",0)
FileWrite (FileHandle1,dakika,0)
FileWrite (FileHandle1,"|",0)
temp=yukseklik
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.GlobGunRad
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.Gunessuresi
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.Sicaklik
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.NNem
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.rzgortyon
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.rzgorthiz
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.rzgmaxyon
If temp="NAN" Then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,"|",0)
temp=OnDakika.rzgmaxhiz
if temp="NAN" then temp="-9999"
FileWrite (FileHandle1,temp,0)
FileWrite (FileHandle1,CHR(13)+CHR(10),0)
FileClose (FileHandle1)
EndSub


Sub Logger_set
SetStatus("USRDriveSize",2500000)
SetStatus("pppinterface",1)
SetStatus("BaudRateRS232",9600)
SetStatus("pppDial","*99**1#") 'Fixed
' SetStatus("pppDialresponse","CONNECT") 'Fixed if modem set to numeric response
' SetStatus("pppUsername", "")
' SetStatus("ppppassword", "")
PPPClose 'Again as setting the above may retrigger autoconnection
EndSub

BeginProg
Call Logger_set
Call met_file_read
serial_counter=0
Scan (5,Sec,0,0)

If TimeIntoInterval (9,10,Min) Then Flag(1) = true
If TimeIntoInterval(0,10,min) Then Flag(2)= true

RealTime (Zaman())
PanelTemp (PTemp,250)
Battery (batt_volt)

If Flag(1)=true Then
PortSet(9,1) 'Turn on switched SW12
EndIf

'Kipp&Zonen_CMP6,CMP11 or Lastem_DPA153 8.60uV Pyranometer measurements sn:128297
'VoltDiff(Global_Rad,1,mV25,1,True,0,_50Hz,116.4144,0)
VoltSe (GlobGunRad,1,mV25,5,1,0,_50Hz,116.4144,0)
If GlobGunRad<=0 Then GlobGunRad=0

'Kipp&Zonen_CSD3 Sunsine Duration measurements SlrW:
'VoltSe (DirekRAD,1,mV2500,3,1,0,_50Hz,1.0,0)
'PortSet(4,1)

'VoltSe (Guneslenme_mV,1,mV2500,4,1,0,_50Hz,1.0,0)
'If Guneslenme_mV >= 500 Then

'Lastem_DPD504 Sunsine Duration measurements SlrW:
VoltSe (DirekRAD,1,mV2500,3,1,0,_50Hz,6.25,-375)
'PortSet(4,1)

VoltSe (Guneslenme_mV,1,mV5000,4,1,0,_50Hz,1.0,0)
If Guneslenme_mV >= 2000 Then

Guneslenme =1
Gunessuresi=Gunessuresi+0.08333334
'Gunessuresi_s=Gunessuresi_s+0.08333334
'Gunessuresi_g=Gunessuresi_g+0.08333334
Else
Guneslenme =0
EndIf

'HC2-S3 Hava NNem ve Sicaklik sensoru
If Flag(2)=true Then
'Delay (0,100,mSec)
VoltSe (Sicaklik,1,mV2500,1,1,0,_50Hz,0.1,-40)
VoltSe (NNem,1,mV2500,2,1,0,_50Hz,0.1,0)
If NNem<=0 Then NNem=0
If NNem>=100 Then NNem=100

''CS100 HAVA BASINC
'VoltSe(BASINC, 1, mV2500,3, False, 0, _50Hz,0.2,600)

'Delay (0,100,mSec)
PortSet(9,0) 'Turn off switched SW12
Flag(1)=false
Flag(2)=false
EndIf
'PortSet(4,0)

'Vector A100M Ruzgar Hiz
PulseCount(rzgorthiz, 1, 1, 0, 1, 0.1, 0.15)
If (rzgorthiz = 0.15) Then (rzgorthiz = 0)

'THIES 4.3351.10 Ruzgar Hiz
'PulseCount(rzgorthiz, 1, 1, 0, 1,0.04599,0.2366)
'If (rzgorthiz = 0.2366) Then (rzgorthiz = 0)

'NRG 40C Ruzgar Hiz
'PulseCount(rzgorthiz, 1, 1, 1, 1, 0.760, 0.39)
'If (rzgorthiz=0.39) Then (rzgorthiz=0)

'NRG 200P Ruzgar Yon
BrHalf(rzgortyon, 1, mV2500, 6, VX1, 1,359, False, 5000, _50Hz, 359, 0)
If (rzgortyon < 1) Then (rzgortyon = 1)
If (rzgortyon > 359) Then (rzgortyon = 0)

'Enter other measurement instructions
'Call Output Tables
'Example:
CallTable ham
CallTable OnDakika
'CallTable Saatlik
'CallTable Gunluk

If IfTime (0,600,Sec) Then Gunessuresi=0
''If IfTime (0,60,Min) Then Gunessuresi_s=0
''If IfTime (0,24,Hr) Then Gunessuresi_g=0



NextScan
SlowSequence

Scan (10,Sec,3,0) '******* GUNLUK TABLO OLUSTURMA
RealTime (Zaman())
saat=Zaman(4)
dakika=Zaman(5)
Gun=Zaman(3)
Ay=Zaman(2)
Yil=Zaman(1)
Old_File=Active_File
If Len (Ay)=1 Then Ay="0"+Ay
If Len (Gun)=1 Then Gun="0"+Gun
temp=Ist_No+"_"

If Yil<>"0" Then
Active_File= temp+Gun+Ay+Yil+"_G.txt"
EndIf

If OLD_File <>Active_File Then
METEOR_File=OLD_File
If first_start =1 then
Call met_file_save
EndIf
EndIf
If OLD_File=Active_File AND first_start =0 Then
Call met_file_read
first_start =1
EndIf

If IfTime (10,600,Sec) Then
Call FileCheck
Call FileYaz
EndIf



NextScan

SlowSequence

Scan (1,Min,3,0) '******* FTP GONDERME

If ftp_repeat=1 Then
PPPOpen

ftp_success=FTPClient (FTP_ADDR,FTP_LOGIN,FTP_PASSW,"USR:"+METEOR_File,METEOR_File,0)

If ftp_success=false
ftp_success_count=ftp_success_count+1

If ftp_success_count < 10 Then
ftp_repeat=1
Else
ftp_repeat=0
PPPClose
Call gsm_kapa
Delay (0,2,Sec)
Call gsm_ac
Delay (0,15,Sec)
EndIf

Else
ftp_repeat=0
EndIf
Copy_IPInfo= status.IPInfo
If Len(Copy_IPInfo) >100 Then
Last_IP= Left (Copy_IPInfo,30)
EndIf

PPPClose
EndIf

If IfTime (9,24,Hr) Then
If METEOR_File <> ""
PPPOpen
ftp_success=FTPClient (FTP_ADDR,FTP_LOGIN,FTP_PASSW,"USR:"+METEOR_File,METEOR_File,0)
If ftp_success=false
ftp_repeat=1
ftp_success_count=0
EndIf
EndIf
PPPClose

EndIf



NextScan

SlowSequence

Scan (30,Sec,3,0)

If ftp_resend=1 Then

PPPOpen
ftp_success=FTPClient (FTP_ADDR,FTP_LOGIN,FTP_PASSW,"USR:"+Resend_File,Resend_File,0)
Copy_IPInfo= status.IPInfo
If Len(Copy_IPInfo) >100 Then
Last_IP= Left (Copy_IPInfo,30)
EndIf
PPPClose
Call gsm_kapa
Delay (0,2,Sec)
Call gsm_ac
Delay (0,15,Sec)
Resend_File=""
ftp_resend=0
EndIf

NextScan

SlowSequence

Scan (5,Sec,3,0)
Select Case serial_counter
Case 0 To 9
serial_counter=serial_counter+1
Case 10
Call gsm_kapa
serial_counter=serial_counter+1
Case 11 To 15
Call gsm_ac
serial_counter=serial_counter+1


Case 16
SerialOpen (COMRS232,9600,0,0,500)
serial_counter=serial_counter+1
Case 17
GSMSTR="+++"
SerialOut (ComRS232,GSMSTR,"",0,1000)
serial_counter=serial_counter+1
Case 18
GSMSTR="AT&F"+CHR (13)+CHR (10)
SerialOut (ComRS232,GSMSTR,"",0,1000)
serial_counter=serial_counter+1
Case 19
GSMSTR="AT+IPR=9600"+CHR (13)+CHR (10)
SerialOut (ComRS232,GSMSTR,"",0,1000)
serial_counter=serial_counter+1
Case 20
GSMSTR="AT+CGDCONT=1,"+CHR (34)+"IP"+CHR (34)+","+CHR (34)+APN+CHR (34)+CHR (13)+CHR (10)
SerialOut (ComRS232,GSMSTR,"",0,1000)
serial_counter=serial_counter+1
Case 21
GSMSTR="ATS0=2"+CHR (13)+CHR (10)
SerialOut (ComRS232,GSMSTR,"",0,1000)
serial_counter=serial_counter+1

Case 22
GSMSTR="AT&W"+CHR (13)+CHR (10)
SerialOut (ComRS232,GSMSTR,"",0,1000)
serial_counter=serial_counter+1

Case 23
PPPClose
serial_counter=serial_counter+1

Case 24
PPPOpen
serial_counter=serial_counter+1
Case 25
PPPClose
serial_counter=serial_counter+1
Case 26
SerialClose (COMRS232)
serial_counter=serial_counter+1


Case 27
'buraya modem ama kapama routinleri yaz
If saat>=9 AND saat<10 Then
modem_absolute=true
Else
modem_absolute=false
EndIf


If batt_volt < 12.0 AND modem_absolute=false Then
Call GSM_Kapa

EndIf

If saat>=7 AND saat<13 Then

If batt_volt >=12.3 Then

Call GSM_Ac
EndIf
If modem_absolute=true Then

Call GSM_Ac
EndIf
EndIf

If (saat>=13 OR saat<7) AND modem_absolute=false Then
Call GSM_kapa

EndIf

EndSelect

NextScan
EndProg"

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