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.

The end user wants to change a few parameters in DataInterval and Scan when I want to lock programming in CR1000.


nvhung Jul 8, 2009 04:22 AM

Dear All,

I am working on installing monitoring system radiation connection between EKO Instruments and CR1000.

The program is very long and complicated, So I want to lock programs by security code, but The end user wants to change a few parameters in DataInterval and Scan in during using

so, Please show me some comment that I can do it.

Thanks and Best Regards,
Nguyen Van Hung
Chief engineer
Measurement and Control Equipment Co., Ltd(MC&TT Co., Ltd)
Add: No 847 Huyen Ky, Phu Lam, Ha Dong Dist, Ha Noi, Vietnam
Mobile: +84 904 251 826
Direct : +84-4-33534933
Fax: +84-4-33534933
Email: nvhung.mctt@gmail.com


Dana Jul 8, 2009 04:11 PM

More recent operating systems have the FileEncrypt function. There is also the Include instruction.

The portions of the program you want the user to be able to access could be placed in the main program. Your proprietary code could be encrypted and referenced by an Include in the main program.

This would allow you to protect your code while giving your users access to other portions of the program.

FileEncrypt was added in OS 16. Include was added in OS 11. We just released OS 17. The OS and supporting CRBasic files are available as a download from our web site. See CRBasic's help file for information on FileEncrypt and Include. Note that currently the file must be encrypted on the datalogger. The next revision of the CRBasic Editor will allow you to encrypt the file on the PC.

Hope this helps,

Dana


jra Jul 8, 2009 05:11 PM

What is your user's interface to the CR1000? The CR1000KD or LoggerNet or ?

In addition to the Include and FileEncrypt instructions take a look at ConstTable/EndConstTable. From the Help: The ConstTable/EndConstTable instructions are used to declare one or more constants that can be changed using a keyboard display or using the datalogger's C command in terminal mode. The program is then recompiled with the new values.

The program Scan and DataInterval are constants.

Keep in mind that when the program is recompiled you will lose the stored data. Always collect data first, before making any changes.

Regards,
Janet


nvhung Jul 9, 2009 02:19 AM

Thanks.

Our customer have all the tools to interface with datalogger including PC400, Loggnet, KD1000, Now, I want to use with Loggnet, but in the future in other project when customers don't buy software copyright, How do I do it ?.

Best Regards,
Nguyen Van Hung


JBecker Jul 9, 2009 09:44 AM

Dear Dana,

which version of the CRBasic editor will support encrypting files when sending it to the logger and when will it be released? We would be very pleased about that feature!

Our Program uses the "Include " instruction to clearly arrange our Code.
But I would have to re- arrange all the code if I want to Encrypt the files, because the files are seperated in files that include Constants and Variables and Files that are containing subroutines - it is very hard to re- arrange it that way, that all(!) files will be encrypted.

Our last problem was, that we encrypted all files, but after restart, compile errors occured: It seems that encrypted files can't be included before the encryption instruction...

We are very pleased about the encryption feature, but is it hard to use it in an existing program!
Exspecially if the program is large and was not considered to be encrypted before...

best regards,

Johannes

* Last updated by: JBecker on 7/9/2009 @ 3:45 AM *


Dana Jul 9, 2009 02:55 PM

Version 3.1 of the CRBasic Editor will support a "Save & Encrypt" option. This is scheduled to be released with LoggerNet 4.0 sometime before the end of the year (barring any unforeseen obstacles!)

Our last problem was, that we encrypted all files, but after restart, compile errors occured: It seems that encrypted files can't be included before the encryption instruction...

Would you be able to give me an rough program outline? For instance,

'Variables are defined"

'DataTables are defined"

Include Encrypted1 'include file contains subroutine

'more declarations

BeginProgam
Include Encrypted2 'include file contains proprietary code
EndProg


I would like to better understand what scenario generates the compiler errors. If you can provide a rough outline, it would help.

Regards,

Dana


JBecker Jul 9, 2009 03:23 PM

...
it is like this:

*********************************

(1)Include "ConstantsVariables
(2)Include "Subroutines concerning Modem"
(3)Include "Display and DataFiles"
(4)Include "Other Constants"
(5)Include "Subroutines for writing a protocol- file"

Subroutines

BeginProg
FileEncrypt((1))
...
FileEncrypt((5))
FileEncrypt(ThisFile)

Scan
SlowSequence
SlowSequence
EndProg
*************************************

The structure above is working - but only once :-)
Only when we upload all files and start the Program.
After we re-start the datalogger, there occure errors like " &&"§§)$ not a valid expression". I think this is because the program reads the (encrypted) Include files before it knows that they are encrypted...


One Problem is, that we can't include the files in a different order, because e.g. the subrotine in(5) needs the constants from file (4) and (1).
The main Prog calls the subroutines in (5). If I would include the files after the "BeginProg" the compiler error is "subroutine declared wihtin an execution block"...
The easiest step is to seperated the display (which can be defined within the Begin/EndProg) and the datatable. Other steps would cause much more trouble.

Johannes


Dana Jul 9, 2009 07:51 PM

The structure above is working - but only once :-)

Ah... I understand. It is probably choking because it is trying to encrypt an encrypted file. I will look at it further. If this is the case, perhaps there is something we can do in a future version of the OS (since we just released OS17 for the CR1000, any subsequent release will likely be a while).

One Problem is, that we can't include the files in a different order, because e.g. the subrotine in(5) needs the constants from file (4) and (1).

Subroutines, variables, data tables, etc. all have to be defined before they are used. This is standard in programming languages, and I don't know there is much we could do to work around it.

Regards, Dana


aps Jul 9, 2009 09:06 PM

Can I add one suggestion and a little more explanation of file encryption.

The suggestion is first to look at the ConstTable option which allows you to define a list of user editable constants which they can edit and force a program recompile without needing to understand the program. The program itself can be protected using normal password techniques or encryption. This requires the least knowledge from the end user and is the safest in terms of them not breaking the program.

Coming on to the file encryption I think there is a little confusion as to what the program instruction fileencrypt does. It is not really intended to be included in a normal running program. It is only intended as a means of getting the logger to encrypt another program (or include files) that are already stored in the logger memory. To this end you only need a small run once program that simply calls fileencrypt to convert another program (or include files) into the encrypted form. (This process won't really be needed when the CRBasic editor can do this for you - it can even encrypt include files in their own right)

Once the file(s) are encrypted they can be sent out to be loaded in another logger in there own right.

Meanwhile with the latest operating system (OS17) you can have include files that are encrypted or not encrypted. So to do what is required in this application you can have one include file of constants that is not encrypted so it can be edited by the end user to change constants he/you wants, whilst the main program and other include files are encrypted to protect any propietary code and algorithms.


Dana Jul 9, 2009 10:18 PM

Re: Errors when running the program a second time... What OS are you using? I tested OS 16 & 17 with the following code (which I think is similar to what you have above) and it compiled fine, several times. No problem with trying to encrypt an already encrypted file, or including a file that is encrypted vs it being not encrypted.


Include "CPU:Encrypt_Vars.cr1"
Include "CPU:Encrypt_Subs.cr1"
Include "CPU:Encrypt_DataTables.cr1"
Include "CPU:Encrypt_Const.cr1"

BeginProg
Scan (1,Sec,3,0)
Include "CPU:Encrypt_measure.cr1")
FileEncrypt("CPU:Encrypt_Vars.cr1")
FileEncrypt("CPU:Encrypt_Subs.cr1")
FileEncrypt("CPU:Encrypt_DataTables.cr1")
FileEncrypt("CPU:Encrypt_Const.cr1")
FileEncrypt("CPU:Encrypt_measure.cr")
FileEncrypt("CPU:FileEncrypt-includetest-main.cr1")
Call TempConvert
CallTable Table
NextScan

EndProg

If you would like, you can send me your programs off-line and I will take a look --- dana @ campbellsci dot com
Also, if you are able to pare down the programs to the bits that are causing the error, that would be helpful (so I am not wading through a lot of code).

Regards, Dana


Dana Jul 9, 2009 10:35 PM

Oops, tester error. I spoke too soon.

I realized I was starting the main program by sending it via LoggerNet each time. It would seem if the main program file is already encrypted and run (for instance, using File Control to Stop/Start or power cycling the datalogger), then errors occur during compilation. If you send the unencrypted file anew, all runs fine. I will look into this further to see if this is intended behavior.

In the meantime, the workaround would be to not encrypt the main file that is calling/encrypting all the other files.

Dana


Dana Jul 9, 2009 11:39 PM

Now, I want to use with Loggnet, but in the future in other project when customers don't buy software copyright, How do I do it ?.

As Janet mentions, the Constant table can be accessed using the keyboard display or the terminal mode's "C" command. PC200W, which is available for download from our web site, has a terminal emulator. You connect to the datalogger, open the terminal emulator, press return a few times to get the "attention" of the datalogger, then type C and follow the prompts to change the value you would like.

When changes are saved the program is recompiled, so as Janet notes, you should collect any data first.

Regards,
Dana


nvhung Jul 29, 2009 09:35 AM

Dear All,

I have came back from the trip and know you discuss my issue very exciting that I have asked you.

However, You still are not concentration into my issue.

I want to use Loggnet to change value time in DataInterval and Scan functions in during using while I set up security code for program.

Please show me details as possible, or send me a demo example on the issue that I asked you.

I am looking forward to hearing from you.

Thanks and Best Regards,
Nguyen Van Hung


jra Jul 29, 2009 09:00 PM

Take a look at the posts regarding using the Constant Table. Changing the Data Interval or Scan requires recompiling the program. If you have security set in the logger you will need to enter the code to make these changes.

Post again if this does not address your issue.

Regards,
Janet


MCTT Jul 30, 2009 02:39 AM

Dear Janet,

this is an basic exmaple. But I am not successful.

Please download two file attachments.

I have used terminal emulator and type "C" Command.

but I have seen where I can change const value in CR8 program

I send two files to your mail(forum@campbellsci.com).

Best Regards,
Nguyen Van Hung

* Last updated by: MCTT on 7/29/2009 @ 8:51 PM *


jra Jul 30, 2009 02:11 PM

What OS are you running in the CR800?

Try this program:
'Declare Public Variables
Public PTemp, batt_volt
ConstTable
Const ScanRate = 1
Const DataIntervalRate = 15
EndConstTable

'Define Data Tables
DataTable (Test,1,1000)
DataInterval (0,DataIntervalRate,Sec,10)
Minimum (1,batt_volt,FP2,0,False)
Sample (1,PTemp,FP2)
EndTable

'Main Program
BeginProg
Scan (ScanRate,Sec,0,0)
PanelTemp (PTemp,250)
Battery (batt_volt)
CallTable Test
NextScan
EndProg

This is what is should look like in Terminal Emulator:

CR1000>C

Constant Table:
1) ScanRate = 1
2) DataIntervalRate = 15
Select the constant to change: 1
ScanRate = 1
Enter New Value for ScanRate: 2

Constant Table:
1) ScanRate = 2
2) DataIntervalRate = 15
Y) Save changes and recompile?
Select the constant to change or enter Y (Yes) to save changes and restart program: Y


I don't think the forum has an e-mail address. If you need to send an attachment you can send it to support at campbellsci dot com.

Let us know how it goes.
Janet


MCTT Jul 30, 2009 03:37 PM

Dear Janet

Thanks very much your support.

I have downloaded new OS.I am successful with your guide.

I will use FileEncrypt that complete application.

Best Regards,
Nguyen Van Hung

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