Datalogger file management, 1 sending a file, Sending a file – Campbell Scientific Java PakBus Software Development Kit User Manual
Page 20

Java PakBus® Software Development Kit
6. Datalogger File Management
The CR1000, CR3000, and CR800 series dataloggers implement file systems
in flash (CPU drive), memory protected RAM (USR drive), and, optionally, in
compact flash cards (CRD drive). These file systems are used to hold program
files as well as other files that are created or used by the datalogger program. In
order to manage these files, the following transactions are provided:
class SendFileTran
Allows the application to send a file to one of
the datalogger file systems.
class GetFileTran
Allows the application to read the contents of
one of the files in the datalogger file system.
class FileControlTran
Allows the application to perform various
operations on files or file systems such as:
• Compiling programs to run now and/or
specifying the program to run on power
up
• Stopping or pausing the currently
running program
• Deleting files
• Formatting devices
class ListFilesTran
Allows the application to receive a list of files
that are stored on the all of the datalogger's
file systems.
6.1 Sending a File
A file can be sent to a datalogger to be stored in its file system by using the
SendFileTran class. The file to be sent is specified using an InputStream
object. The following example demonstrates this process:
import com.campbellsci.pakbus.*;
import java.net.*;
import java.io.*;
class Example6 implements SendFileClient
{
private Network network;
private Socket socket;
private boolean complete;
private Datalogger my_cr1000;
public void run() throws Exception
{
// create the connection and the network
socket = new Socket("192.168.4.225",6785);
network = new Network(
(short)4079,
socket.getInputStream(),
socket.getOutputStream());
// create the station
my_cr1000 = new Datalogger((short)1085);
12