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.

FTPClient Data From Table


Thoriq Jun 19, 2023 08:43 AM

Dear All,

If we are using function FTPClient, its opted with directly stream data from table with few option for FileOption. Anyway, I need to stream the data trough server with different header format. I would like to format my data with this following header;

Timestamp Record WL1_m WL2_m WL3_m Solar_Volt Battery_Volt

But, what I get when use fileoption 8 for TOA5 format, header would be;

"TOA5","13xxx","CR300","13xxx","CR310-WIFI.Std.10.04","CPU:ProgName.CR300","25yyy","OneMin"
"TIMESTAMP","RECORD","WL_Rad1","WL_Rad2","WL_Prs1","BattV","SolarV"
"TS","RN","","","","Volts",""
"","","Smp","Smp","Smp","Smp","Smp"

I tried using TOB1 and it looks same. 

Do you have any suggestion on how we modify the header data?

Our client server couldnt read the header to parse the data to their database. They should be exactly same with required header. 

Anyway, I already tried using FileWrite option and create specific file format, the result goes to serial flash error because program force to create new same file in high interval. 

Thank you.

Regards

Thor


JDavis Jun 19, 2023 04:40 PM

If the server would accept headerless data, you could try FileOption 12.

To avoid the serial flash error, you would need a CR1000X or CR6. Those dataloggers have more RAM and can create a USR drive in RAM for high speed file writes.


Thoriq Jun 21, 2023 06:25 AM

Hi JDavis

Thanks for the replay. Unfortunately they wouldnt accept it because their server run for other data from different logger too.

I tried to modify the header by made specific string and stored in table. Then I called 2 table to be sent over ftp into 1 file. It didnt succeed. I'm interested on how two or more table data merged in to 1 RemoteFile on the FTP. Correct me if I'm wrong.


Thanks

Regards

Thoriq


JDavis Jun 21, 2023 05:29 PM

General process:

  Have custom header in a string variable.

  Have data without header in a separate string variable.

  Use OpenFile() to create a new empty file.

  FlieWrite() custom header.

  FileWrite() data to the file.

  FileClose() to close the file

  FTPClient() to send the file.

There are a couple ways to get data records into a string variable. One way is using GetRecord() with a string variable as a destination. GetRecord() only provides one line of data. So, if you need multiple lines of data, the program needs to use GetRecord() multiple times. GetRecord() and FileWrite() could be used in a loop.

The other method would be TableFile() to create a headerless file of data lines. Then the program would need to read the file into a string.

The GetRecord() method is what I recommend for your case.

Be mindful to not declare string variables much larger than needed. RAM is limited in CR300 and the data logger needs available RAM for communication buffers used by FTP.


Thoriq Jun 22, 2023 01:38 AM

This post is under review.

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