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.

CR1000 remote file transfer via HughesNet sat.


RiverOfNoReturn Jul 7, 2009 11:03 PM

Hope someone can guide me in the right direction with this. So my current set up is A CR1000 with an NL115 attached and a direct link via RS-232 to a laptop computer running PC400 that is connected to the internet on a HughesNet satellite link. I would like to send a data table out to an FTP site on an hourly basis, but I haven't been able to get things to work. Please let me know if I am going about this all wrong. I am very new to Campbell products and programming and am not the most computer literate person in the world. I've deleted a few extraneous lines of code to make things more readable, I hope I didn't delete anything important.


'_________________________________________________

'Declare Variables and Units

Public Results(15)


'FTP Variables
Public FTPSuccess As Boolean
Public OutStat As Boolean
Public LastFileName As String * 25

'FTP Information
Const IPAddress="ftp.geology.isu.edu"
Const User="user"
Const Password="password"
Const Filename = "Table1.dat"
'_________________________________________________

Alias Results(1)=Distance_m
Alias Results(2)=Distance_cm
Alias Results(3)=Distance_ft
Alias Results(4)=RLS_status

'___________________________________________

Units Distance_m=m
Units Distance_cm=cm
Units Distance_ft=ft

'_________________________________________________

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10)
CardOut(0,58000) 'Output data to NL115
TableFile("CRD:Table1.dat",8, -1, 6, 0, Min, 0, Filename)


Maximum(1,Distance_m,FP2,False,1)
Average(1,Distance_cm,FP2,Distance_cm=0)
Average(1,Distance_ft,FP2,Distance_ft=0)
Maximum(1,RLS_Status,FP2,False,1)

EndTable
'_________________________________________________

'Main Program
BeginProg
Scan(60,Sec,1,0)

'Generic SDI-12 Sensor measurements Distance_m, Distance_mm, Distance_ft,
'RLS_Status:
SDI12Recorder(Distance_m,7,"0","M!",1,0)

'Call Data Tables and Store Data
CallTable(Table1)
'FTP Data
If Outstat Then
FTPSuccess = FTPClient (IPAddress,User,Password,LastFileName,Filename,0)
EndIf

NextScan
EndProg

* Last updated by: RiverOfNoReturn on 7/8/2009 @ 7:25 AM *


Dana Jul 8, 2009 03:59 PM

TableFile("CRD:Table1.dat",8, -1, 6, 0, Min, 0, Filename)

In the above line of code, the 7th parameter is typically a variable (preferably a Boolean). When a new TableFile has been written it will be set to True by the datalogger. If a 0 is used instead of a variable (as above), this parameter is ignored. However, using a variable instead is a good trigger for FTPClient or EmailSend.

The program conditionally runs the FTPClient instruction, based on the variable OutStat. I don't see where in the program this variable is controlled. Also,I don't see where "LastFileName" is being written to.

Here is an example program I have in my files. It ran the last time I loaded it into the datalogger(who knows if the Gremlins have edited since!)

'Measurement Variables
Public Bat, RefTemp, Temp, FTPResult As Boolean

'TableFile variables
Public OutStat As Boolean, OutStatTrig as Boolean, LastFileName As String * 20

'FTP parameter strings (as constants), Message String & Result Variable
Const IPAddress="192.123.4.56"
Const UserName="anonymous"
Const Password=""

DataTable (Test,True,-1)
DataInterval (0,15,Sec,10)
Sample (1,Bat,FP2)
Sample (1,Temp,FP2)
Sample (1,LastFileName,String)
TableFile ("USR:Test",8,-1,0,2,Min,OutStat,LastFileName)
EndTable

BeginProg
'set user drive size so files can be stored to it
SetStatus ("USRDriveSize",16384)

Scan (1,Sec,3,0)
Battery(bat)
PanelTemp (RefTemp,250)
TCDiff (Temp,1,mV2_5C,1,TypeT,RefTemp,True ,0,250,1.0,0)
CallTable (Test)

'when new file is written, set a trigger to True
'Outstat will be set to false at next CallTable,
'so this keeps a variable "true" until FTPClient
'is executed
If OutStat Then OutStatTrig=True
NextScan

'run FTPClient in slowsequence, so the rest of the program
'can go on while FTP is taking place
SlowSequence
Scan (1,Sec,3,0)
If OutStatTrig
FTPResult=FTPClient (IPAddress,UserName,Password,lastfilename,Mid(LastFileName,5,20),0)
'set trigger var to false
OutStatTrig=False
EndIf
NextScan

EndProg


You could probably use this program, and change the IPAddress, UserName & Password vars.

A good way to peek in on what the FTP is doing, is to Telnet into the datalogger and at the prompt type in 8192D. This is the trace code for FTP. You will be able to see FTP messages. Some are cryptic, but some may help you to determine where the problem is if the FTP fails (for instance, you can see if user name or password is incorrect).

Hope this helps,

Dana

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