input: Write a Python function to establish a connection to a hardware device using a serial port and baud rate.
  assert HardwareController().connect('COM3', 9600) == True
  assert HardwareController().connect('COM4', 4800) == False
  assert HardwareController().connect('COM1', 115200) == True
output: import serial
  
  class HardwareController:
      def connect(self, port, baud_rate):
          try:
              ser = serial.Serial(port, baud_rate)
              if ser.is_open:
                  ser.close()
                  return True
              else:
                  return False
          except serial.SerialException:
              return False