RMCLink COM Component

RMCLink.WriteImageFromFile Method

Loads the controller image from the specified file, writing it to the controller and applies it. By default, the image will be saved to flash and the controller will be restarted. The controller image file must have been created using the ReadImageToFile method. For saving and restoring the controller image using an array in memory instead of using a file, use the ReadImage and WriteImage methods. This method is only supported on the RMC75E, RMC150E, and RMC200 controllers.

Syntax

Visual Basic (Declaration)

Sub WriteImageFromFile ( _

   flags As Long, _

   fileName As String _

)

 

Visual Basic (Usage)

Dim instance As RMCLink

Dim flags As Long

Dim fileName As String

 

instance.WriteImageFromFile flags, fileName

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)

fileName

File name and path to load the controller image from.

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

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.

rmcEImageResetFailed = 1040

Unable to reset Image Area for download.

rmcEImageDownloadFailed = 1041

Unable to download controller image.

rmcEImageInvalid = 1042

Timeout applying downloaded image.

rmcEImageApplyTimeout = 1043

Image format is invalid.

rmcEImageApplyState = 1044

Unexpected state encountered while applying image.

rmcEImageApplyResetReq = 1045

Image not applied because restart required.

rmcEImageApplyFlashError = 1046

Error writing to flash memory while applying image.

rmcEImageApplyRunMode = 1047

Image cannot be applied without restart while in RUN mode.

rmcEImageApplyHWMismatch = 1048

Image not applied because of hardware mismatch.

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.

rmcEFileNotFound = 1058

Unable the find the specified file.

rmcEPathNotFound = 1059

Unable the find the specified file path. Check that the drive and folder specified exist.

rmcEAccessDenied = 1060

Access denied to the file or path. Verify that the file is not opened by another application and that you have access to the folder and file.

rmcEDriveNotReady = 1061

Removable drive not ready. Verify that media has been inserted into the removable drive.

Example

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

Visual Basic 6 / VBA

Option Explicit
 
Public Sub Sample()
    ' Declare and create the RMCLinkServer COM object.
    Dim srv As New RMCLinkServer 
  
    ' Create a new RMCLink object for the controller.
    Dim rmc As RMCLink
    Set rmc = srv.CreateEthernetLink(dtRMC70, "192.168.0.22") 
  
    ' Connect to the controller.
    rmc.Connect 
  
    ' Load the image from 'RMCImage.bin' and apply it to the controller.
    rmc.WriteImageFromFile 0, "RMCImage.bin" 
 
    ' Close the connection.
    rmc.Disconnect
End Sub

 

VBScript

Option Explicit
Dim src, rmc
 
' First we need to create the RMCLinkServer COM object.
Set srv = CreateObject("RMCLink.RMCLinkServer")
 
' Create a new RMCLink object for the controller.
' NOTE: VBScript does not support enumerations, so we use the literal value (dtRMC70=2).
Set rmc = srv.CreateEthernetLink(2, "192.168.0.22")
 
' Connect to the controller.
rmc.Connect
 
' Load the image from 'RMCImage.bin' and apply it to the controller.
rmc.WriteImageFromFile 0, "RMCImage.bin" 
 
' Close the connection.
rmc.Disconnect

 

JScript

// First we need to create the RMCLinkServer COM object.
var srv = new ActiveXObject("RMCLink.RMCLinkServer");
 
// Create a new RMCLink object for the controller.
// NOTE: JScript does not support enumerations, so we use the literal value (dtRMC70=2).
var rmc = srv.CreateEthernetLink(2, "192.168.0.22");
 
// Connect to the controller.
rmc.Connect();
 
// Load the image from 'RMCImage.bin' and apply it to the controller.
rmc.WriteImageFromFile(0, "RMCImage.bin");
 
// Close the connection.
rmc.Disconnect();

 

See Also

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


Send comments on this topic.

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