/* Parse a master request, execute the command and build a response. */
void modbus_execute_command(struct modbus_slave *dev, uint8_t *request, uint8_t *response)
/* Parse a master request, execute the command and build a response. */
void modbus_execute_command(struct modbus_slave *dev, uint8_t *request, uint8_t *response)
{
	uint8_t func_index;
	modbus_get_function(dev, request, &func_index);
	response[MODBUS_ADDRESS_PLACE] = dev->slave_id;
	response[MODBUS_FUNCTION_PLACE] = commands_array[func_index];
	if(commands_array[func_index] <= READ_ANALOG_INPUT_REGISTERS)
		modbus_read(dev, request, response);
	else
		modbus_write(dev, request, response);
}