Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
modbus_receive()						modbus_receive()

Name
     modbus_receive - receive an indication request

Synopsis
     int modbus_receive(modbus_t *ctx, uint8_t *req);

Description
     The  modbus_receive() function shall receive an indication request from the
     socket of the context ctx. This function is used by a  Modbus  slave/server
     to receive and analyze indication request sent by the masters/clients.

     If  you  need to use another socket or file descriptor than the one defined
     in  the   context	 ctx,	see   the   function   modbus_set_socket   <mod-
     bus_set_socket.md>.

Return value
     The  function  shall store the indication request in req and return the re-
     quest length if successful. The returned request length can be zero if  the
     indication  request is ignored (eg. a query for another slave in RTU mode).
     Otherwise it shall return -1 and set errno.

Buffer size
     The maximum size of the request depends on the used backend, in RTU the req
     array must be MODBUS_RTU_MAX_ADU_LENGTH bytes and in TCP it  must	be  MOD-
     BUS_TCP_MAX_ADU_LENGTH  bytes.  If  you  want to write code compatible with
     both, you can use the constant MODBUS_MAX_ADU_LENGTH (maximum value of  all
     libmodbus	backends). Take care to allocate enough memory to store requests
     to avoid crashes of your server.

Example
     uint8_t req[MODBUS_MAX_ADU_LENGTH];
     rc = modbus_receive(ctx, req);

See also
     * modbus_set_socket <modbus_set_socket.md>

     * modbus_reply <modbus_reply.md>

								modbus_receive()

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=modbus_receive&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help