RMCLink.Interop .NET Assembly

RMCLink.WriteImage Method

Writes the specified controller image to the controller and applies it to the controller. By default, the image will be saved to flash and the controller will be restarted. The controller image must be obtained using the ReadImage method. For saving and restoring the controller image using a file, use the ReadImageToFile and WriteImageFromFile methods. This method is only supported on the RMC75E, RMC150E, and RMC200 controllers.

Syntax

Visual Basic (Declaration)

Public Sub WriteImage ( _

   flags As Integer, _

   data() As Integer

)

 

Visual Basic (Usage)

Dim instance As RMCLink

Dim flags As Integer

Dim data() As Integer

 

instance.WriteImage(flags, data)

 

C#

public void WriteImage (

    int flags,

    int[] data

)

 

Visual C++/CLI

public:

void WriteImage (

    int flags

    array<int>^ data

)

Parameters

flags

Options to use when applying the image. Refer to the RMCTools documentation on the Image Area for a current list of options. As of this writing, a single option has been defined. Specify zero (0) to use default options.

+0

Save Image to Flash, and Restart Controller to Apply

+16

Apply Image Immediately and Save To Flash  (not supported by RMC200)

data

An array of Integer values containing the controller image. The data must have been created using the ReadImage method.

Remarks

This method is synchronous, which means that it will not return until the write 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 data parameter refers to a null (Nothing in Visual Basic) object.

ArgumentOutOfRangeException

The flags parameter is out of range.

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 image is corrupt or not a recognized version.

  • The Do Not Restart Controller (+16) option was selected, but the image requires restarting the controller.

  • The Do Not Restart Controller (+16) option was selected, but the controller is not in PROGRAM mode.

  • The image downloaded is intended for a different physical controller.

ReadWriteFailedException

The write 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.

Example

The following code example illustrates the use of the WriteImage method in copying a controller image from one controller to another.

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.CreateUSBLink(DeviceType.RMC70, "7573091001") 
 
        ' Connect to the controller.
        rmc.Connect() 
 
        ' Read the image into our variable.
        image = rmc.ReadImage(0)
 
        ' Disconnect from the controller.
        rmc.Disconnect()
 
        ' Create a new RMCLink object for the second controller.
        Dim rmc2 As RMCLink = RMCLink.CreateUSBLink(DeviceType.RMC70, "7573091002")
 
        ' Connect to the controller.
        rmc2.Connect()
 
        ' Apply the image to the second controller.
        rmc2.WriteImage(0, image)
 
        ' Disconnect from the controller.
        rmc2.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.CreateUSBLink(DeviceType.RMC70, "7573091001");
  
            // Connect to the controller.
            rmc.Connect();
 
            // Read the image into our variable.
            image = rmc.ReadImage(0);
 
            // Disconnect from the controller.
            rmc.Disconnect();
 
            // Create a new RMCLink object for the second controller.
            RMCLink rmc2 = RMCLink.CreateUSBLink(DeviceType.RMC70, "7573091002"); 
 
            // Connect to the controller.
            rmc2.Connect(); 
 
            // Apply the image to the second controller.
            rmc2.WriteImage(0, image);
 
            // Disconnect from the controller.
            rmc2.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::CreateUSBLink(DeviceType::RMC70, "7573091001");
 
    // Connect to the controller.
    rmc->Connect();
 
    // Read the image into our variable.
    image = rmc->ReadImage(0);
 
    // Disconnect from the controller.
    rmc->Disconnect();
 
    // Create a new RMCLink object for the second controller.
    RMCLink^ rmc2 = RMCLink::CreateUSBLink(DeviceType::RMC70, "7573091002"); 
 
    // Connect to the controller.
    rmc2->Connect(); 
 
    // Apply the image to the second controller.
    rmc2->WriteImage(0, image); 
 
    // Disconnect from the controller.
    rmc2->Disconnect();
 
    return 0;
}

 

See Also

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


Send comments on this topic.

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