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.

CRBasic: Command to get time since last data collection


Marcel Dec 4, 2013 04:07 PM

Hi,

Is there a way in CRBasic to get the time since the last data collection? I'd like to reset my GSM modem as soon as there was no data collection for some time.

Cheers,
Marcel


jtrauntvein Dec 5, 2013 04:48 PM

There is no means in CRBasic of which I am aware that records the last time that data collection took place. That said, there are other reasons beyond data collection (such as sending a program file or retrieving files from the logger file system or being connected with the station in the connect screen) for which LoggerNet may keep the link alive. So it seems that the question that should be asked is if there is a method by which the CRBasic program can recognise that LoggerNet is no longer using a link. The answer to this question is that there is such a method provided certain conditions are met.

CRBasic has an instruction, Route(address), that will look up the neighbour address used to reach the specified PakBus address. Provided that the datalogger is configured as a router (The "Is Router" check box in the devconfig deployment/advanced panel is checked), the datalogger will return a value of zero if there is no route in the routing tables for the specified address (if the datalogger is not configured as a router, the return value will be the same as the specified address). If LoggerNet is therefore configured to hang up the link (the "PakBus Port Always Open" control for the PakBus port is not checked in the set up screen), then a call to Route() for this address sometime after the link has been hung up will return a value of zero.


Sam Dec 8, 2013 08:30 AM

As Jon mentioned you could use Route() or Routes() who's change in state can lag by link's verify interval if the link is not cleanly shut down. You could potentially look at the activity of the serial port the modem is connected to. Using Task Master and corascript / cora command, you could also have LoggerNet regularly set a public variable used like a communication watchdog counter.

Public Rte, NoRteCnt

BeginProg
Scan (1,Sec,0,0)
NextScan

SlowSequence
Scan (1,Min,3,0)
Rte = Route (4094)
If Rte = 0 Then NoRteCnt += 1 Else NoRteCnt = 0
If NoRteCnt > 60 Then
'do something to restart link
EndIf
NextScan
EndSequence
EndProg

Public NoActiveCnt

BeginProg
Scan (1,Sec,0,0)
NextScan

SlowSequence
Scan (1,Min,3,0)
If Status.CommActiveRS232 = FALSE Then NoActiveCnt += 1 Else NoActiveCnt = 0
If NoActiveCnt > 60 Then
'do something to restart link
EndIf
NextScan
EndSequence
EndProg


Marcel Dec 9, 2013 06:54 AM

Those are good hints! Thanks a lot.
Marcel

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