Hi Everyone,
I was wondering it is possible to setup the .csipassword file from inside a program. I want to be able to enable the webserver, set the username, password and the port number too.
Turning on the webserver using SetStatus ("HTTP Enabled",-1) and SetStatus ("HTTP Service Port",8080) kind of works but it continues to recompile every time this setting is run. I understood that if it didn't change the setting it wouldn't have to recompile and I can't find a way to read the setting first to decide if I should have to set it again.
Cheers
Ryan
This is how Gary does it:
The first thing I do is create a .csipassword file using DevConfig. To do so, I connect to the logger. Then I click on the Network Services tab in Deployment panel. Then click Edit .csipasswd File. I remove the admin user and then add a username that I want. In this case, I used csi_user with a password of campbell21X with full (all) access. I then make sure that the “Hide After Save” checkbox is unchecked. Then I click Apply.
After that I use File Control to pull the .csipasswd file off of the logger and open it up with a text editor.
After that I start editing my CRBasic program. In it I create a subroutine called InitializeLogger which sets the desired settings and writes the .csipassword file. I also use PreserverVaiables.
The .csipasswd file created can be used on other dataloggers. The only change that needs to be done is to the file line of the file. It must match the station name of the logger.
The logger should only reboot/restart once.
--------
Dana added:
Note that SetStatus can be placed in the program after BeginProg but before Scan, so that it is run only once. I do this to set UsrDriveSize.
--------
This is the example program from Gary, using a Subroutine for the initialization, which is before Scan.
Const STATION_NAME = "GARY_R_CR3000_PB_3002"
Public battery_voltage
Public panel_temperature_c
Public update_complete As Boolean
Dim file_handle As Long
DataTable(TEST_DATA, 1, -1)
Sample(1, battery_voltage, FP2)
Sample(1, panel_temperature_c, IEEE4)
EndTable
PreserveVariables
Sub InitializeLogger
'Write .csipasswd file to CPU drive
'Adds two users
file_handle = FileOpen("CPU:.csipasswd", "w", 0)
FileWrite(file_handle, STATION_NAME & CHR(13), 0)
FileWrite(file_handle, "anonymous::3" & CHR(13), 0)
FileWrite(file_handle, "csi_user:nMg/PY5DVPpXUX0=:1)" & CHR(13), 0)
FileClose(file_handle)
'Set station name
SetSetting("StationName", STATION_NAME)
'Setup the web server on port 8080
SetSetting("HTTPEnabled", TRUE)
SetSetting("HTTPPort", 8080)
'Finished!
update_complete = TRUE
EndSub
BeginProg
If(update_complete <> TRUE) Then
InitializeLogger
EndIf
Scan(1, Sec, 0, 0)
PanelTemp(panel_temperature_c, _60Hz)
Battery(battery_voltage)
CallTable TEST_DATA
NextScan
EndProg