How can I do if I send a program to the datalogger CR1000 and if it cant compile well the datalogger run the previous program automatically in its cpu memory (what I see in file control)?
Here's an idea.
If the datalogger gets into a "no program" state, and a "default" program exists on the CPU drive, the datalogger will run that default program. Some ways a no program state can occur include stopping a program, when the logger boots up and there is no program marked to run, or when a program fails to compile. The default program must be named "default" with a matching file extension for the target datalogger. For example "default.cr1x" for a CR1000X or "default.cr300" for a CR300.
We could use this to our advantage by having every program we send it, that ends up successfully compiling, make a copy of itself to a "default" program file using the FileCopy() command. Here is a simple example.
BeginProg FileCopy (Status.ProgName,"CPU:default.cr1x") Scan (1,Sec,0,0) NextScan EndProg
We can perform a simple test to see if it works. First we will send a program called "test1.cr1x" to the CR1000X. We will see that the program successfully compiles. If we use File Control to look at the CPU drive, we will also see a "default.cr1x" file now present. Next, we will send a program file called "test2.cr1x" that contains a programming error. In the compile results we will see that the CR1000X is running default.cr1x and it also shows the programming errors of test2.cr1x. Default.cr1x is the same as test1.cr1x.
TEST1.CR1X
Public myName As String = "test1" BeginProg FileCopy (Status.ProgName,"CPU:default.cr1x") Scan (1,Sec,0,0) NextScan EndProg
TEST2.CR1X (the program error is a missing "P" from the intended "Public" variable declaration.
ublic myName As String = "test2" BeginProg FileCopy (Status.ProgName,"CPU:default.cr1x") Scan (1,Sec,0,0) NextScan EndProg
COMPILE RESULTS AFTER SENDING TEST2.CR1X
Running Program: CPU:DEFAULT.CR1X Run on Power Up Program: CPU:DEFAULT.CR1X Program State: program running Compile Time: 04/11/20 14:35:36 OS Version: CR1000X.Beta.04.02.2020.04.02.1422 ==================== CPU:DEFAULT.CR1X -- Compiled in PipelineMode. Error(s) in CPU:test2.CR1X: line 1: ublic is not defined. line 1: myName is not defined. line 1: Invalid, or out of place expression: ublic myName As String = "test2" .