RMCLink.Interop .NET Assembly

RMCLink.ReadImageToFile Method

Reads the entire controller image and saves it to a file. This file can then be written and applied to another controller of the same physical configuration using the WriteImageFromFile method. For saving and restoring the controller image using an array rather than a file, use the ReadImage and WriteImage methods. This method is only supported on the RMC75E, RMC150E, and RMC200 controllers.

Syntax

Visual Basic (Declaration)

Public Sub ReadImageToFile ( _

   flags As Integer _

)

 

Visual Basic (Usage)

Dim instance As RMCLink

Dim flags As Integer

Dim fileName As String

 

instance.ReadImageToFile(flags, fileName)

 

C#

public void ReadImageToFile (

   int flags,

   string filename

)

 

Visual C++/CLI

public:

void ReadImageToFile (

   int flags,

   String^ fileName

)

Parameters

flags

Options to use when building the controller image. Refer to the RMCTools documentation on the Image Area for a current list of options. As of this writing no options have been defined. Specify zero (0) to use default options.

fileName

File name and path to save the controller image into.

Remarks

This method is synchronous, which means that it will not return until the read is completed, which may take several seconds. If this method is called on the main thread, then the application will likely be unresponsive until this method completes. For applications where this is not acceptable, this and other synchronous methods should be called from a worker thread, and may use the CancelRequest method to cancel an in progress request.

Exceptions

Exception Type

Condition

ArgumentNullException

The fileName parameter refers to a null (Nothing in Visual Basic) object.

ArgumentOutOfRangeException

The flags parameter is out of range, or the fileName parameter is blank.

CancelledException

This read was cancelled by a call on another thread to one of the Disconnect and CancelRequest methods.

InvalidOperationException

One of the following circumstances occurred:

  • The link is not currently connected. The Connect method must be called before attempting to read from the controller.

  • The Image Area is not supported by this controller. The controller must be an RMC75E, RMC150E, or RMC200 with firmware supporting the image read/write.

  • The controller has copy protection enabled, and therefore the upload image could not be built.

Check the Message property of the exception for a description of the exception.

ReadWriteFailedException

The read failed due to a communication failure. Check that the remote device is powered up, check the communication wiring, and check the communication configuration of both the local and remote devices. Check the Message property of the exception for a description of the communication failure.

System.UnauthorizedAccessException

The caller does not have the required permission. -or- fileName specified a file that is read-only.

System.IO.PathTooLongException

The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.

System.IO.DirectoryNotFoundException

The specified path is invalid, (for example, it is on an unmapped drive).

System.IO.IOException

An I/O error occurred while creating or writing to the file.

System.NotSupportedException

fileName is in an invalid format.

Example

The following code example illustrates the use of the ReadImageToFile method.

Visual Basic

Imports RMCLinkNET
  
Module Example
    Sub Main()
        Dim image() As Integer
  
        ' Create a new RMCLink object for the first controller.
        Dim rmc As RMCLink = RMCLink.CreateEthernetLink(DeviceType.RMC70, "192.168.0.22") 
  
        ' Connect to the controller.
        rmc.Connect() 
  
        ' Read the image and save it to 'RMCImage.bin'.
        rmc.ReadImageToFile(0, "RMCImage.bin")
  
        ' Disconnect from the controller. 
        rmc.Disconnect()
    End Sub
End Module

 

C#

using System;
using RMCLinkNET;
 
namespace Example
{
    public class Program
    {
        static void Main()
        {
            int[] image;
 
            // Create a new RMCLink object for the first controller.
            RMCLink rmc = RMCLink.CreateEthernetLink(DeviceType.RMC70, "192.168.0.22");
 
            // Connect to the controller.
            rmc.Connect(); 
 
            // Read the image and save it to 'RMCImage.bin'.
            rmc.ReadImageToFile(0, "RMCImage.bin");
 
            // Disconnect from the controller.
            rmc.Disconnect();
       }
    }
}

 

Visual C++/CLI

using namespace System;
using namespace RMCLinkNET;
 
int main()
{
    array <int>^ image;
 
    // Create a new RMCLink object for the first controller.
    RMCLink^ rmc = RMCLink::CreateEthernetLink(DeviceType::RMC70, "192.168.0.22");
 
    // Connect to the controller.
    rmc->Connect();
 
    // Read the image and save it to 'RMCImage.bin'.
    rmc->ReadImageToFile(0, "RMCImage.bin");
 
    // Disconnect from the controller.
    rmc->Disconnect();
 
    return 0;
}

 

See Also

RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class | ReadImage| WriteImage | WriteImageFromFile


Send comments on this topic.

Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion