Hi, I close tablefile at midnight and send via SFTP streaming every hour. (CR6.14.4.0 CR6-WIFI.05.03)
On the server, only the file sent at midnight contains only one row:
Sonic_2025-12-16_00-00-00.dat on server:
"TIMESTAMP","RECORD","u_1","v_1","w_1","Ts_1","SS_1","ChkSumF_1","u_2","v_2","w_2","Ts_2","SS_2","ChkSumF_2" "2025-12-16 00:00:00.05",752374,0.014,0.013,0.003,18.18,"00",-1,0.028,-0.006,0.027,17.69,"00",-1
instead of data between 23:00:00.05 and 00:00:00.00 (72000 row). I think it's because the file closes at midnight on the SD card.
How can I resolve? I tried a Scan(1, Hr) and a Scan(30, Sec) with the same results.
Thanks
Code:
DataTable (Sonic,True,-1)
DataInterval(0,50,mSec,0)
TableFile ("CRD:"&Status.SerialNumber(1,1)&"_sonic_",64,-1,0,1,Day,0,0)
Sample(1, u_1,FP2)
Sample(1, v_1,FP2)
Sample(1, w_1,FP2)
Sample(1, Ts_1,FP2)
Sample(1, SS_1, String)
Sample(1, ChkSumF_1,Boolean)
Sample(1, u_2,FP2)
Sample(1, v_2,FP2)
Sample(1, w_2,FP2)
Sample(1, Ts_2,FP2)
Sample(1, SS_2, String)
Sample(1, ChkSumF_2,Boolean)
EndTable
SlowSequence
Scan (1,Hr,10,0)
FTPResult3=FTPClient(IPAddress,UserName,Password,"Sonic", serialN&"/Sonic_YYYY-MM-DD_HH-MM-SS.dat",20,0,1,Hr,-1008)
FTPResult=FTPClient(IPAddress,UserName,Password,"Slow", serialN&"/Slow_YYYY-MM-DD_HH-MM-SS.dat",20,0,1,Hr,-1008)
FTPResult2=FTPClient(IPAddress,UserName,Password,"Stat", serialN & "/Stat_YYYY-MM-DD_HH-MM-SS.dat",20,0,1,Hr,-1008)
NextScan
EndSequence
This same question came up a few weeks ago. Because the slow sequence generally lags behind the main scan, TableFile had moved on to the new file before the FTPClient happened. You want to send the previous file, not the new file.
Use variables in the last two parameters in TableFile. They are OutStat and LastFileName. OutStat is true for when scan when the file closes.
Within the main scan, after CallTable, watch the boolean variable and copy the string with the name of the file to send. You can then use that as the source in FTPClient within the slow sequence.
If OutStat Then
FileToSend = LastFileName
SendFile = True
EndIf
Even with this method, the files written at midnight to the server contain only one line.
"TIMESTAMP","RECORD","u_1","v_1","w_1","Ts_1","SS_1","ChkSumF_1","u_2","v_2","w_2","Ts_2","SS_2","ChkSumF_2" "2025-12-22 00:00:00.05",1665293,0.017,-0.001,0.023,18.69,"00",-1,-0.011,-0.009,0.024,18.91,"00",-1
The code:
Public outStat As Boolean
'Define slow Data Tables
DataTable(Slow,True,-1)
DataInterval(0,1,Sec,0)
TableFile ("CRD:"&Status.SerialNumber(1,1)&"_slow_",64,-1,0,24,Hr,0,0)
Sample(1,AirTC1,FP2)
Sample(1,RH1,FP2)
EndTable
DataTable(Stat,True,-1)
DataInterval(0,1,Sec,0)
TableFile ("CRD:"&Status.SerialNumber(1,1)&"_status_",64,-1,0,24,Hr,0,0)
Minimum(1,BattV,FP2,False,False)
Sample(1,CardStatus,String)
EndTable
DataTable (Sonic,True,-1)
DataInterval(0,50,mSec,0)
TableFile ("CRD:"&Status.SerialNumber(1,1)&"_sonic_",64,-1,0,24,Hr,outStat,0)
Sample(1, u_1,FP2)
Sample(1, v_1,FP2)
Sample(1, w_1,FP2)
Sample(1, Ts_1,FP2)
Sample(1, SS_1, String)
Sample(1, ChkSumF_1,Boolean)
EndTable
BeginProg
serialN = Status.SerialNumber
SerialOpen(ComC1,38400,3,0,138,4) 'buffer size (45 +1 char) * 3
Scan (50,mSec,1200,0)
SerialInRecord (ComC1,row1,&H02,0,&H0D0A,n1,01) '2 and 3 ascii char or &H02 and &H0D0A to get also checksum
ChkSumF_1=HexToDec(Mid(row1,44,2)) Eqv CheckSum(row1,9,42)
If ChkSumF_1 Then
u_1 = Mid(row1,3,8)
v_1 = Mid(row1,12,8)
w_1 = Mid(row1,21,8)
Ts_1 = Mid(row1,32,8)
SS_1 = Mid(row1,40,2)
Else
u_1 = NAN
v_1 = NAN
w_1 = NAN
Ts_1 = NAN
SS_1 = NAN
EndIf
CallTable Sonic
If outStat Then
TriggerSequence(2,0)
EndIf
NextScan
SlowSequence
Do
WaitTriggerSequence
FTPResult=FTPClient(IPAddress,UserName,Password,"Slow", serialN&"/Slow_YYYY-MM-DD_HH-MM-SS.dat",20,0,1,Hr,-1008)
FTPResult2=FTPClient(IPAddress,UserName,Password,"Stat", serialN & "/Stat_YYYY-MM-DD_HH-MM-SS.dat",20,0,1,Hr,-1008)
FTPResult3=FTPClient(IPAddress,UserName,Password,"Sonic", serialN&"/Sonic_YYYY-MM-DD_HH-MM-SS.dat",20,0,1,Hr,-1008)
Loop
EndSequence
EndProg
Your program is still pointing to the table name instead of the file name.