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.

Sending current and "n" previous readings


ludwigh Feb 16, 2023 03:54 PM

Hello,

I am trying to send data via HTTPPost from a TableFile as JSON where I am able to send the current reading and any number of previous readings as well (defined by a user). There have been two different responses from what I have tried so far

1. Only a single entry (recording of sensors e.x. Batt_Volt, PanelTemp, etc.) is sent at a time that keeps updating with each new transmission.

2. Multiple entries are sent at once, but they are not updated as new entries come in, meaning I get the first "n" entries to send but no new additional information is sent. But each time I restart the program the next "n" entries are sent.

From what I understand the tables are supposed to run in ring mode on default and the TableFile is written from the table entries, so the file should be updating with the table, but for some reason that is not what I am getting as a response. Does anyone have a solution to this problem. I have included an example of my test script below with examples of the things that I have tried.

Please reach out if anyone has any solutions or other ideas to solve problem. 

Thanks!

SequentialMode

Const data_table_name = "Persist" Const data_table_name2 = "Test" Const scan_rate = 10 Const scan_rate_units = sec Public PanelT Public batt_volt Units PanelT=Deg_C Units batt_volt=Volts Public http_header_api As String * 100 = "X-ApiKey:REPLACE_ME" Public file_handle Public http_header As String * 100 = "Content-Type:application/json" Public http_post_response As String * 2000 Public http_post_tx Const table_file_name = "CRD:Data" Const table_file_extension = table_file_name + ".dat" Const post_url = "https://postman-echo.com/post" Public ScanCount As Long = 0 Public file_handle2 'Public file_handle3 'Public m As String * 50 Public Condition = true Public LoopCount(2) DataTable (data_table_name,1,-1) DataInterval (0,scan_rate,scan_rate_units,10) Minimum (1,batt_volt,FP2,0,False) Sample (1,PanelT,FP2) EndTable DataTable(data_table_name2,1,10) DataInterval (0,scan_rate,scan_rate_units,10) TableFile (table_file_name,-32,0,0,0,scan_rate_units,0,0) Minimum (1,batt_volt,FP2,0,False) Sample (1,PanelT,FP2) EndTable BeginProg Scan (scan_rate,scan_rate_units,0,0) 'Do While Condition ' LoopCount(1)+=1 'Increment loop count ' If LoopCount(1) = 6 Then ' file_handle = FileOpen (table_file_extension,"w", 0): ' FileWrite (file_handle,"",0): ' FileClose (file_handle): ' Condition = false ' LoopCount(1) = 0 ' EndIf 'Loop 'ResetTable(Test) 'If ScanCount = 6 Then 'file_handle = FileOpen (table_file_extension,"w", 0): 'FileWrite (file_handle,"",0): 'FileClose (file_handle): 'ScanCount = 0 'EndIf ScanCount = ScanCount + 1 PanelTemp (PanelT,15000) Battery (batt_volt) http_post_tx = HTTPPost (post_url,table_file_extension,http_post_response,http_header + CHR(13)+ CHR(10) + http_header_api,0,0,0,32,0) 'Sprintf(m,"Scancount: %d",ScanCount) 'file_handle3 = FileOpen ("CPU:scancheck.txt","w", -1) 'FileWrite (file_handle3,m,100) 'FileClose (file_handle3) file_handle2 = FileOpen ("CPU:Response.txt","w", -1) FileWrite (file_handle2,http_post_response,0) FileClose (file_handle2) CallTable data_table_name CallTable data_table_name2 NextScan EndProg

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