cyg_modbus_raw_pdu

Name

cyg_modbus_raw_pdu -- Access raw PDU buffer

Synopsis

#include <cyg/modbus.h>

void cyg_modbus_raw_pdu(cyg_handle_t ctx, cyg_uint8 *len, cyg_uint8 **data);

Description

This function provides low-level access to the request PDU buffer for the backend handler code. Before calling the backend handler function the MODBUS server will have already parsed the request and will pass the relevant request data as parameters to the handler function. However, for some backend implementations it may be useful to re-use the request memory space as the holding location for the response. This can avoid the backend having to manage its own dynamic memory allocations.

The example packages/services/modbus/vsn/tests/backend_dummy.c source file provided with the package provides examples of using this cyg_modbus_raw_pdu() function in conjunction with cyg_modbus_response_nocopy() to re-use the transaction PDU buffer. For example:

  {
    cyg_uint8 len;
    cyg_uint8 *pdata;
    cyg_modbus_raw_pdu(ctx,&len,&pdata);
    ... code to fill pdata buffer ...;
    len = response_length;
    cyg_modbus_response_nocopy(ctx,len);
  }
      

2017-02-09
Documentation license for this page: eCosPro License