RMCLink COM Component

RMCLink.ReadImage Method

Reads the entire controller image into an integer array. This image can be applied to another controller of the same physical configuration using the WriteImage 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)

Function ReadImage ( _

    flags As Long _

) As Variant

 

Visual Basic (Usage)

Dim instance As RMCLink

Dim flags As Long

Dim returnValue As Variant

 

returnValue = instance.ReadImage(flags)

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.

Return Value

This variant will contain the controller image read from the controller. The data type will be a single-dimension 0-based array of Long elements. The length of this array will vary depending on the actual contents of the controller.

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

Error Code

Description

rmcEOutOfMemory = 5

Out of memory.

rmcEInvalidArg = 7

The flags parameter has an unsupported value.

rmcEDisconnecting = 1002

Link is being disconnected by another thread.

rmcEDisconnected = 1005

The link has not been connected.

rmcESocketInternal = 1008

Internal socket error.

rmcECancelled = 1010

Operation cancelled by call to CancelRequest.

rmcETimeout = 1011

Operation timed out.

rmcESocketGracefullyClosed = 1014

TCP/IP connection closed by remote device.

rmcESocketReadError = 1015

Connection error while waiting for response from the remote device.

rmcESocketInvReadLen = 1016

Connection error while waiting for response from the remote device.

rmcESocketWriteError = 1017

Connection error while sending request to the remote device.

rmcESocketInvWriteLen = 1018

Connection error while sending request to the remote device.

rmcEConnectionBroken = 1028

Connection broken.

rmcEPartialWrite = 1029

Unable to send full request to the remote device.

rmcEBadAddress = 1032

Attempt to read beyond the end of a file.

rmcENotSupported = 1035

Operation not supported on this controller type. The controller must be an RMC75E, RMC150E, or RMC200 with firmware supporting the image read/write.

rmcEBuildImgTimeout = 1036

Timeout waiting for image to be built.

rmcEBuildImgError = 1037

Controller unable to build image.

rmcEBuildImgState = 1038

Unexpected state encountered while building image.

rmcEImageUploadFailed = 1039

Unable to upload completed image.

rmcEUSBInternal1 = 1051

Internal USB driver error.

rmcEUSBOperationAborted = 1053

Unsuccessful transfer of data between the PC and the controller. Ensure that the physical connection between the PC and controller is still intact.

rmcEUSBDisconnected = 1054

The controller appears to have been disconnected from the USB port. Ensure that the physical connection between the PC and controller is still intact.

rmcEBuildImgNotAllowed = 1062

Controller unable to build upload image because copy protection is enabled.

Example

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

Visual Basic 6 / VBA

Option Explicit
 
Public Sub Sample()
    Dim image As Variant
 
    ' Declare and create the RMCLinkServer COM object.
    Dim srv As New RMCLinkServer
 
    ' Create a new RMCLink object for the first controller.
    Dim rmc As RMCLink
    Set rmc = srv.CreateUSBLink(dtRMC70, "7573091001")
 
    ' Connect to the controller.
    rmc.Connect
 
    ' Read the image into our variable.
    image = rmc.ReadImage(0)     
 
    ' Close the connection.
    rmc.Disconnect     
 
    ' Create a new RMCLink object for the second controller.
    Dim rmc2 As RMCLink
    Set rmc2 = srv.CreateUSBLink(dtRMC70, "7573091002")
 
    ' Connect to the controller.
    rmc2.Connect
 
    ' Read the image into our variable.
    rmc2.WriteImage 0, image
 
    ' Close the connection.
    rmc2.Disconnect
End Sub

 

VBScript

Option Explicit
Dim srv, rmc, rmc2, image
 
' First we need to create the RMCLinkServer COM object.
Set srv = CreateObject("RMCLink.RMCLinkServer")
 
' Create a new RMCLink object for the first controller.
' NOTE: VBScript does not support enumerations, so we use the literal value (dtRMC70=2).
Set rmc = srv.CreateUSBLink(2, "7573091001")
 
' Connect to the controller.
rmc.Connect
 
' Read the image into our variable.
image = rmc.ReadImage(0)
 
' Close the connection.
rmc.Disconnect
 
' Create a new RMCLink object for the second controller.
Set rmc2 = srv.CreateUSBLink(2, "7573091002")
 
' Connect to the controller.
rmc2.Connect
 
' Read the image into our variable.
rmc2.WriteImage 0, image
 
' Close the connection.
rmc2.Disconnect

 

JScript

// First we need to create the RMCLinkServer COM object.
var srv = new ActiveXObject("RMCLink.RMCLinkServer");
 
// Create a new RMCLink object for the first controller.
// NOTE: JScript does not support enumerations, so we use the literal value (dtRMC70=2).
var rmc = srv.CreateUSBLink(2, "7573091001");
// Connect to the controller.
rmc.Connect();
 
// Read the image into our variable.
var image = rmc.ReadImage(0);
// Close the connection.
rmc.Disconnect();
// Create a new RMCLink object for the second controller.
var rmc2 = srv.CreateUSBLink(2, "7573091002");
// Connect to the controller.
rmc2.Connect();
// Read the image into our variable.
rmc2.WriteImage(0, image);
// Close the connection.
rmc2.Disconnect();

 

See Also

RMCLinkServer Class | RMCLink Class | RMCLink COM Component | WriteImage| ReadImageToFile | WriteImageFromFile


Send comments on this topic.

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