Read "Diagnostic Realtime Logs" in BASIC

flexy

#1

Hi,

I would like to know if it is possible in a BASIC program to read the contents of the “Diagnostic Realtime Logs”. I would like to do actions based on events that are found in this log.

I use a Flexy 205.

Thanks
Christian


#2

Hello Christian,

You can access the logs using an export block descriptor. Once you have the file you can then parse the file in basic.

The EBD for the Realtime logs is $dtRE$ftT

Here is an example for parsing data from an EBD. https://developer.ewon.biz/content/how-parse-file The example is getting GSM data but the concept should be the same for accessing the Logs.

Deryck
Deryck


#4

Hi Deryck,

To find the “Realtime Logs”, what is the name of the file?

Thanks again
Christian


#5

Here is no persistent file for the logs. The export block descriptor $dtRE$ftT will generate the logs and allow you to parse the data.


#6

Here is a sample of some code that we have used in the past to accomplish this.

// This function will check for any alarms that have occured in the last minute
// or any alarm status changes that have occured in the last minute. If there
// was an alarm then we will do something. If it was an alarm status change then we will do something else

FUNCTION CheckAlarms()

strToCheck$="ALM" // looking for active alarm
strCheckForRTN$ = "RTN"
strCheckForEND$ = "END"
foundALM%=0
foundRTN%=0

OPEN "exp:$dtAH $ftT $st_s60 $et_s0" FOR TEXT INPUT AS 1 // open the alarm history file for the last minute

$Loop:
A$ = Get 1 // read first line
IF (A$<>"") THEN // check to see if it is blank
//Print A$
E% = INSTR 1,A$,strToCheck$ // check in the first line for the status of ALM
IF E% <> 0 THEN // If not 0 (means that the string was found),
//PRINT A$
foundALM%=1
ENDIF

E% = INSTR 1,A$,strCheckForRTN$ // check in the first line for the status of ALM
F% = INSTR 1,A$,strCheckForEND$ // check in the first line for the status of END
IF E% <> 0 Or F% <> 0 THEN // If not 0 (means that the string was found),
//PRINT A$
foundRTN%=1
ENDIF

GOTO $Loop // not found so read the next line
ENDIF

CLOSE 1 // close the file

IF foundRTN%<>0 THEN

// do something since we found a RTN alarm status change
ENDIF

IF foundRTN%<>0 Or foundALM% <>0 THEN

// Found a RTN alarm and a ALM so do something else

ENDIF

ENDFN


#7

Hi tedsch,

Thanks for your code :grinning:

With your code, I did this function for my tests.

FUNCTION CheckRE()
CLOSE 1
Counter% = 0
flagEndLoop%=0
//OPEN “exp:$dtRE $ftT $st_m10 $et_0” FOR TEXT INPUT AS 1 // Start time does not work
//OPEN “exp:$dtRE $ftT $stL$et_0$ut” FOR TEXT INPUT AS 1 // Start time does not work
OPEN “exp:$dtRE $ftT” FOR TEXT INPUT AS 1 // open Realtime Logs

$Loop:
A$ = Get 1 // read line
IF (A$<>"") THEN // check to see if it is blank
PRINT A$;
Counter% = Counter% + 1
ELSE
PRINT “Blank detected”
flagEndLoop% = 1
ENDIF

IF (NOT flagEndLoop% AND Counter% <= 10 ) THEN GOTO $Loop //Check end of loop

CLOSE 1 // close file
ENDFN

Thanks again
Christian


#8

Hi deryck,

The “export block descriptor” works well but I have to read every record of the “Realtime Logs” every time.

I tried with $ft “Start time”, $et and “End time” and also with $ut “Update last time” but none seems to work with $dtRE$ftT. (see the other post)

Do you have an idea for not passing the entire file each time?

Thank you
Christian


#9

Not sure why you could not get the start time to work in the EBD. Did you try changing it to a seconds value instead of minutes?

As a side note do you know about the Export Block Descriptor Helper> It is located here https://ewonsupport.biz/ebd/ and can help with trying to build the EBD strings.

Also watch out for repeating lines in the logs. I found in the past if something was repeating in the log multiple times that sometimes the logs would just show an abbreviated repeat x times statement instead of what actually happened. So if you are looking for a specific string just keep in mind that if that event repeats multiple times in a row the log might not show the string you are looking for.


#10

Hi tedsch,

Thanks for the link of the “Export Block Descriptor Helper”.

Via this utility, I now understand that the parameters “Start time” and “End time” are not available for the data type “Real Time Diagnostic” :cry:

Thanks
Christian


#11

@CFrancoeur,

The EBD would be the only option to access the Logs since the Basic IDE does not get direct access. It looks like @tedsch helped you out with the EBD and the start and end time. You are correct those parameters do not apply to the Real Time Diagnostic file.

Deryck