code: public static synchronized ModbusSlave createSerialSlave(SerialParameters serialParams) throws ModbusException {
          ModbusSlave slave = null;
          if (serialParams == null) {
              throw new ModbusException("Serial parameters are null");
          }
          else if (ModbusUtil.isBlank(serialParams.getPortName())) {
              throw new ModbusException("Serial port name is empty");
          }
  
          // If we have a slave already assigned to this port
          if (slaves.containsKey(serialParams.getPortName())) {
              slave = slaves.get(serialParams.getPortName());
  
              // Check if any of the parameters have changed
              if (!serialParams.toString().equals(slave.getSerialParams().toString())) {
                  close(slave);
                  slave = null;
              }
          }
  
          // If we don;t have a slave, create one
          if (slave == null) {
              slave = new ModbusSlave(serialParams);
              slaves.put(serialParams.getPortName(), slave);
              return slave;
          }
          return slave;
      }
docs: Creates a serial modbus slave or returns the one already allocated to this port
  
  @param serialParams Serial parameters for serial type slaves
  @return new or existing Serial modbus slave associated with the port
  
  @throws ModbusException If a problem occurs e.g. port already in use