RMCLink C++ Wrapper Class

CRMCLink::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

C++

HRESULT ReadImageToFile(

    UINT flags,

    LPCTSTR 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.

Return Value

Returns S_OK on success. Otherwise, an error code is returned. Possible error codes are listed below.

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.

Error Codes

Member Name

Description

E_OUTOFMEMORY

Out of memory.

E_INVALIDARG

The flags parameter has an unsupported value.

RMCLINK_E_DISCONNECTING

Link is being disconnected by another thread.

RMCLINK_E_DISCONNECTED

The link has not been connected.

RMCLINK_E_SOCK_INTERNAL

Internal socket error.

RMCLINK_E_CANCELLED

Operation cancelled by call to CancelRequest.

RMCLINK_E_TIMEOUT

Operation timed out.

RMCLINK_E_SOCK_GRACEFUL_CLOSE

TCP/IP connection closed by remote device.

RMCLINK_E_SOCK_ERROR_RD

Connection error while waiting for response from the remote device.

RMCLINK_E_SOCK_INV_RD_LEN

Connection error while waiting for response from the remote device.

RMCLINK_E_SOCK_ERROR_WR

Connection error while sending request to the remote device.

RMCLINK_E_SOCK_INV_WR_LEN

Connection error while sending request to the remote device.

RMCLINK_E_CONN_BROKEN

Connection broken.

RMCLINK_E_PARTIAL_WRITE

Unable to send full request to the remote device.

RMCLINK_E_USB_SETTIMEOUT

Internal USB driver error.

RMCLINK_E_USB_OP_ABORT

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

RMCLINK_E_USB_DISCONNECT

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

RMCLINK_E_NOT_SUPPORTED

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

RMCLINK_E_BLDIMG_TIMEOUT

Timeout waiting for image to be built.

RMCLINK_E_BLDIMG_ERROR

Controller unable to build image.

RMCLINK_E_BLDIMG_STATE

Unexpected state encountered while building image.

RMCLINK_E_BLDIMG_NOT_ALLOWED

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

RMCLINK_E_UL_FAILED

Unable to upload completed image.

RMCLINK_E_PATH_NOT_FOUND

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

RMCLINK_E_ACCESS_DENIED

Access denied to the file or path. Verify that you have access to create files in the specified folder, or if you are saving over an existing file, make sure that the existing file is not read-only or currently open by another application.

RMCLINK_E_DRIVE_NOT_READY

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

Example

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

C++

#include <windows.h>
#include <stdio.h>
#include "RMCLink.h" 
void main()
{
    // In order to create COM objects, we must initialize the COM sub-system.
    ::CoInitialize(0);
 
    // Create a new RMCLink object.
    CRMCLink* pRMC = CRMCLink::CreateEthernetLink(CRMCLink::dtRMC70, _T("192.168.0.22"));
    if ( pRMC != NULL )
    {
        // Establish the connection.
        HRESULT hr = pRMC->Connect();
        if ( SUCCEEDED(hr) )
        {
            hr = pRMC->ReadImageToFile(0, _T("RMCImage.bin"));
            if ( SUCCEEDED(hr) )
            {
                printf("Successfully saved controller image in RMCImage.bin!");
            }
 
            // Close the connection.
            pRMC->Disconnect();
        }
 
        // Free the RMCLink object we created.
        delete pRMC;
    }
 
    // Release the COM sub-system.
    ::CoUninitialize();
}

 

See Also

CRMCLink Class | RMCLink C++ Wrapper Class | CRMCLink::WriteImageFromFile | CRMCLink::ReadImage | CRMCLink::WriteImage


Send comments on this topic.

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