User file location on Groov Epic?


#1

I’m trying to read a text file off of the user file area of an Epic controller with my PAC Control strategy. The file is called ‘Config.txt’ and I’ve uploaded it to the Epic using the Groov Manage interface. I placed it as an unsecured file.

I’ve read these types of files before on a PAC Controller and in that case the comm handle to open the file for reading would simply be:

“file:r,Config.txt”

The above is not working when trying to open the communication handle. Is there a folder location where the unsecured files are stored that I’m missing here? I’m unable to get my Open Communication command to work.


#2

The insecure files are located in /home/dev/unsecured and the secure files are at /home/dev/secured


#3

Here is a working chunk of code to append a line to a txt file on the Epic in the unsecured file area. I am running Epic firmware 1.2 Earlier versions may experience problems with the file write, see kb87590

  // here is the data string to append to the csv file
  taccDataString = "10/11/2018,02:48:15,123.4,56789.1" + Chr(13) + Chr(10); // Data line with a carriage return / line feed

  // build the header line.  This is only used if the file doesn't yet exist.  Its nice to have a header at the top
  taccHeaderString = "DATE, TIME, FLOW, DAYTOTAL" + Chr(13) + Chr(10);      // Header with a carriage return / line feed

  // see if the file exists by trying to open it read-only
  // if it dosn't exist, write a header line
  taccFilespec = "file:r,/home/dev/unsecured/testwrite.txt";
  SetCommunicationHandleValue(taccFilespec, tchFile);       // read only
  taccWriteStatus = OpenOutgoingCommunication( tchFile );   // open the handle 
  CloseCommunication(tchFile);                              // close the file handle and check status
  if (taccWriteStatus <> 0) then
    // write the header if there is no file yet
    taccFilespec = "file:a,/home/dev/unsecured/testwrite.txt";  // open for append or create
    SetCommunicationHandleValue(taccFilespec, tchFile);
    taccWriteStatus = OpenOutgoingCommunication(tchFile);
    if (taccWriteStatus == 0) then
      taccTransmitStatus = TransmitString(taccHeaderString, tchFile);   // write the header line
    endif
    CloseCommunication(tchFile);                 
  endif

  // Write the data line
  taccFilespec = "file:a,/home/dev/unsecured/testwrite.txt";
  SetCommunicationHandleValue(taccFilespec, tchFile);
  taccWriteStatus = OpenOutgoingCommunication(tchFile);
  if (taccWriteStatus == 0) then
    taccTransmitStatus = TransmitString(taccDataString, tchFile);
  endif
  CloseCommunication(tchFile);                 

Code Comments -
I’ve hard coded the data. You would build the data line with your real values.
I’ve also hard coded the filename, and in several places at that, which would not be good practice.
I’ve got some error handling, but not all conditions.
The file is open read-only to determine if it exists. If it doesn’t the header line is written. Then the data line is written.