code: def read(self, num_bytes):
          
          self.check_pyb()
          try:
              return self.pyb.serial.read(num_bytes)
          except (serial.serialutil.SerialException, TypeError):
              # Write failed - assume that we got disconnected
              self.close()
              raise DeviceError('serial port %s closed' % self.dev_name_short)
docs: Reads data from the pyboard over the serial port.