« Close

Datasheets and User Guides

App Notes

Software & Driver

 

2.8.1.1 - AddressesToMBFB

Creates a Modbus Feedback (MBFB) packet. This packet can be sent to the device using LJM_MBFBComm.

Syntax

LJM_ERROR_RETURN LJM_AddressesToMBFB(
                      int MaxBytesPerMBFB,
                      int * aAddresses, 
                      int * aTypes, 
                      int * aWrites, 
                      int * aNumValues, 
                      double * aValues, 
                      int * NumFrames, 
                      unsigned char * aMBFBCommand)

Parameters

MaxBytesPerMBFB [in]
The maximum number of bytes that the Feedback command is allowed to consist of. It is highly recommended to pass the size of the aMBFBCommand buffer as MaxBytesPerMBFB to prevent buffer overflow. See LJM_DEFAULT_FEEDBACK_ALLOCATION_SIZE.

aAddresses [in]
An array of size NumFrames representing the register addresses to read from or write to for each frame.

aTypes [in]
An array of size NumFrames containing the data type of each value sent/received for each frame.
Types - 0:UINT16, 1:UINT32, 2:INT32, 3:FLOAT32  

aWrites [in]
An array of size NumFrames containing the desired type of access for each frame, which is either read(0) or write(1).

aNumValues [in]
An array of size NumFrames that contains the number of consecutive values for each frame.  Use 1 for a single (non-consecutive) value.

aValues [in]
An array of values to be transferred to/from the device. This array contains all the values for all the frames, so its size should be the sum of all elements in the aNumValues array. Each write value will be converted to its corresponding frame type defined in aTypes. LJM_UpdateValues can be used later to update this array with read values.

NumFrames [in/out]
Input as the number of frames being created. Output as the number of frames that were successfully put into the aMBFBCommand buffer, which may be less or equal to the input number. If NumFrames is altered by this function, LJM_AddressesToMBFB will return the warning code LJME_FRAMES_OMITTED_DUE_TO_PACKET_SIZE.

aMBFBCommand [out]
The resultant Modbus Feedback command. Transaction ID and Unit ID will be blanks that LJM_MBFBComm will fill in.

Returns

LJM errorcodes or 0 for no error.

Remarks

The LJM_NamesToAddresses and LJM_NameToAddress functions may be used to initialize the aAddresses and aTypes parameters from register names.

Examples

Please see the Low-level Feedback Functions overview page for an example.