RMCLink C++ Wrapper Class CRMCLink::WriteFFile Method |
Writes to one or more floating-point (F) registers in the controller. Notice that since all RMC100 registers are integers, WriteLFile should be used instead for that controller type. Use WriteFFile when writing to floating-point RMC70, RMC150, or RMC200 registers. Compare with WriteLFile.
C++ |
HRESULT WriteFFile( UINT file, UINT element, UINT count, float const* pData ); |
file
File number of the first register to write to. See the RMCLink Register Reference for details.
element
Element number of the first register to write to. See the RMCLink Register Reference for details.
count
The number of registers to write.
data
Points to the data to write to the controller, which must be a float array of at least count elements.
Returns S_OK on success. Otherwise, an error code is returned. Possible error codes are listed below.
Notice that all RMC100 registers are integers. Therefore, using this method to write data to the RMC100 will simply round the values to integers before writing them to the controller.
For details on integer (L) and floating-point (F) registers and how to read from and write to both, see RMC100 Register Data Types or RMC70, RMC150, and RMC200 Register Data Types.
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.
Member Name |
Description |
E_OUTOFMEMORY |
Out of memory. |
E_INVALIDARG |
One of the file, element, or count parameters are out of range. |
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_CE_IOE |
Serial IOE error. |
RMCLINK_E_CE_FRAME |
Serial framing error. |
RMCLINK_E_CE_BREAK |
Serial Break error. |
RMCLINK_E_CE_OVERRUN |
Serial overrun. |
RMCLINK_E_CE_RXOVER |
Serial receive overrun. |
RMCLINK_E_CE_RXPARITY |
Serial parity error. |
RMCLINK_E_CE_TXFULL |
Serial transmitter full. |
RMCLINK_E_CONN_BROKEN |
Connection broken. |
RMCLINK_E_PARTIAL_WRITE |
Unable to send full request to the remote device. |
RMCLINK_E_READ_ONLY |
Attempt to write to read-only registers. |
RMCLINK_E_BAD_ADDRESS |
Attempt to write beyond the end of a file. |
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. |
The following code example illustrates the use of the WriteFFile 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) )
{
// Issue a Move Absolute command to Axis 0 (registers F16:0-5).
float afCmd[6];
afCmd[0] = 20; // Move Absolute (20)
afCmd[1] = 10.5; // Requested Position (10.5 in)
afCmd[2] = 12.5; // Requested Speed (12.5 in/s)
afCmd[3] = 100; // Acceleration Rate (100 in/s/s)
afCmd[4] = 100; // Deceleration Rate (100 in/s/s)
afCmd[5] = 0; // Direction (0=nearest)
hr = pRMC->WriteFFile(CRMCLink::fn70CommandArea, 0,
CRMCLink::rmc70CmdRegsPerAxis, afCmd);
if ( SUCCEEDED(hr) )
printf("Command successfully written.");
// 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 | WriteLFile
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion